diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2011-05-05 12:11:21 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2011-05-05 12:11:21 +0000 |
commit | 3507176bda3b5c66ab178e2eab9e1daf6502a7c3 (patch) | |
tree | 7bd9b1013d49527a2e3ab7c595b589020acccdcf /sys | |
parent | a3fd6084d44ed453397a1d4ee24f6c1150d1ffd0 (diff) |
Up until now, malloc scanned the bits of the chunk bitmap from
position zero, skipping a random number of free slots and then
picking the next free one. This slowed things down, especially if
the number of full slots increases.
This changes the scannning to start at a random position in the
bitmap and then taking the first available free slot, wrapping if
the end of the bitmap is reached. Of course we'll still scan more
if the bitmap becomes more full, but the extra iterations skipping
free slots and then some full slots are avoided.
The random number is derived from a global, which is incremented
by a few random bits every time a chunk is needed (with a small optimization
if only one free slot is left).
Thanks to the testers!
Diffstat (limited to 'sys')
0 files changed, 0 insertions, 0 deletions