The Software Optimization Cookbook: High-Performance Recipes for IA-32 Platforms, Second Edition

Chapter 10: Slow Operations

Overview

Ocasionally, a hotspot is located in a piece of code that is just plain slow. It might be a system call, an expensive sequence of calculations, or maybe just an expensive instruction like FCOS, SQRTPD, or IDIV whatever it is, it's slow. It is common to think that slow operations are just that, slow, and nothing can be done to improve performance. But, don't give up too soon. Usually, you still can improve performance significantly by finding a way to avoid the slow operation altogether or by modifying the operation and saving just the good parts.

Operations are slow, for the most part, because they are written to solve a general problem. For example, string functions like scanf work for all types of input. If only a subset of the functionality were required, like the conversion of hexadecimal values, scanf cannot take advantage of that fact and it would still execute the fully general version. In this case, and many others, a special purpose function could easily beat the performance of the generalized function. Especially when building into the code assumptions about the data, such as the length, alignments, and cache state, a specialized function usually is easier to write and its performance is higher.

Slow Instructions

Instructions are slow due to one or more of the following reasons:

  • Long latency. Latency is the time in processor clocks from the time that the instruction first starts executing until the time that it is completed.

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Order Picking Systems
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.