summaryrefslogtreecommitdiff
path: root/Makerules
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-03-25 15:56:04 +0000
committerRobin Watts <robin.watts@artifex.com>2013-03-25 15:56:04 +0000
commitc17efed8d998461533be4dcd5bd22f3b1e90eeff (patch)
treeb8d58e7ca4e770096f4de95e1b714b84baf1d8c1 /Makerules
parente558d59ca8c189c947a3976450bdb3073978de9a (diff)
downloadmupdf-c17efed8d998461533be4dcd5bd22f3b1e90eeff.tar.xz
Avoid store collisions causing unnecessary evictions.
When storing tiling bitmaps from the draw_device to the store, we frequently hit the case where we insert tile records that are already there. (This also happens in other cases, such as an image being decoded simultaneously on 2 different threads, but more rarely). In such cases, the existing code attempts to evict store contents to bring the size down enough to fit the new object in, only to find that it needn't have. This patch attempts to fix that behaviour. The only way we know if an equivalent entry is in place already is to try to place the new one; we therefore do this earlier in the store function. If this encaching succeeds (no equivalent entry already exists) we are safe to evict as required. Should the eviction be incapable of removing enough from the store to make it fit, we now need to remove the entry we just added to the hash table. To avoid doing a full (and potentially expensive linear probe), we amend the hash table functions slightly. Firstly, we add a new function fz_hash_insert_with_pos that does the insert, but returns the position within the hashtable that the entry was inserted. Secondly, we then add a new fz_hash_remove_fast function that takes this position as an entry. The 'fast' removal function checks to see whether the entry is still correct (it always should be unless we have been very unlucky with a table rebuild, or another hashtable operation happening at the same time) and can quickly remove the entry. If lightning has struck, it works the old (slower) way.
Diffstat (limited to 'Makerules')
0 files changed, 0 insertions, 0 deletions