* Added a new function hash_insert_grow() that grows the hash table when needed.

* Removed the public hash_grow() function again (at least for now, it's only
  private).
* Removed the newSize argument from hash_grow(); it will compute the new size
  automatically.
* The block cache is now using hash_insert_grow() instead of hash_insert()
  which should make hash lookups much faster with some 10 thousand blocks,
  also increased the initial table size from 32 to 1024...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23692 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-01-21 19:57:40 +00:00
parent 9f1506cb81
commit 4a67038e56
3 changed files with 89 additions and 71 deletions
+4 -4
View File
@@ -327,7 +327,7 @@ block_cache::block_cache(int _fd, off_t numBlocks, size_t blockSize,
if (buffer_cache == NULL)
return;
hash = hash_init(32, 0, &cached_block::Compare, &cached_block::Hash);
hash = hash_init(1024, 0, &cached_block::Compare, &cached_block::Hash);
if (hash == NULL)
return;
@@ -650,7 +650,7 @@ get_cached_block(block_cache *cache, off_t blockNumber, bool *_allocated,
if (block == NULL)
return NULL;
hash_insert(cache->hash, block);
hash_insert_grow(cache->hash, block);
*_allocated = true;
}
@@ -1118,7 +1118,7 @@ cache_start_transaction(void *_cache)
TRACE(("cache_start_transaction(): id %ld started\n", transaction->id));
T(Action("start", cache, transaction));
hash_insert(cache->transaction_hash, transaction);
hash_insert_grow(cache->transaction_hash, transaction);
return transaction->id;
}
@@ -1347,7 +1347,7 @@ cache_detach_sub_transaction(void *_cache, int32 id,
transaction->num_blocks = transaction->main_num_blocks;
transaction->sub_num_blocks = 0;
hash_insert(cache->transaction_hash, newTransaction);
hash_insert_grow(cache->transaction_hash, newTransaction);
cache->last_transaction = newTransaction;
return newTransaction->id;