Commits

Nadav Rotem committed cdbf839f6ce
[Runtime Mem] Convert the metadata map from open to closed hash map. This change cuts the number of mallocs() in the metadata caches in half. The current metadata cache data structure uses a linked list for each entry in the tree to handle collissions. This means that we need at least two memory allocations for each entry, one for the tree node and one for the linked list node. This commit changes the map used by the metadata caches from an open hash map (that embeds a linked list at each entry) into an closed map that uses a different hash value for each entry. With this change we no longer accept collissions and it is now the responsibility of the user to prevent collissions. The new get/trySet API makes this responsibility explicit. The new design also goes well with the current design where hashing is done externally and the fact that we don't save the full key, just the hash and the value to save memory. This change reduces the number of allocated objects per entry in half. Instead of allocating two 32-byte objects (one for the tree node and one for the linked list) we just allocate a single entry that contains the hash and the value. Unfortunately, values that are made of two 64-bit pointers (like protocol conformance entries) are now too big for the 32-byte tree entry and are rounded up to 48 bytes. In practice this is not a big deal because malloc has 48-byte pool entries.