Lists Home |
Date Index |
Michael Champion wrote:
> It is common sense that you can't optimize
> both speed and space simultaneously.
Common sense is great except for when it is wrong (or
partially wrong). This particular bit of common sense is *often*
correct, but not always...
In communications protocols, reducing the "size" of an object
will increase the speed with which it is communicated... (Speed of
light is finite...) The same effect applies to memory and disk
accesses. Speed in these contexts is at least partially related to
Use of binary integers rather than their string
representations can often reduce the size of objects while also
increasing processing speed because the need to do conversions may be
A process that deletes instances of default values in
representations of an object defined by a schema will often reduce the
size of the instance. Depending on processing details, such deletions
can result in speed improvements in addition to those that are the
direct result of size reduction. (i.e. If you don't provide the
default, you don't have to process it when creating or reading the
Replacing "begin" and "end" tags in a data stream with a
"length" count can result in size reductions (if the begin/end tags
are larger than the count value) while also improving speed by
eliminating the need to scan for end tags.
Replacing "tags" with references to a "dictionary" can
drastically reduce the size of an object (see Xbis, etc.) while also
making processing more efficient since you can do integer lookups into
your symbol table rather than mucking about with strings.
I could go on...
Nonetheless, the general drift of the "common sense" is
correct. It is usually not a good idea to attempt to optimize two
things at the same time. It is also often impossible to optimize two
things simultaneously. Further, folk who are trying to optimize more
than one thing at a time are often simply showing that they haven't
done enough analysis to understand which of the multiple optimization
axis is actually most important to them.