Skip to content

Conversation

@daviesrob
Copy link
Member

Keys for cram_block_compression_hdr::TD_hash and cram_slice::pair hash tables are kept in string pools. Adding keys to the pool before putting them in the hash table could lead to redundant copies being left behind in the pool because the newly-added key was not used. To prevent this, only add keys to the string pool when the hash table entry is new, and update the hash table entry so it uses the pooled key. We can get away with this as in both cases the key is available as a NUL-terminated string that can be used for the initial hash look-up.

This will very slightly reduce the memory used when writing CRAM files, and remove some unnecessary memory copies.

Keys for cram_block_compression_hdr::TD_hash and cram_slice::pair
hash tables are kept in string pools.  Adding keys to the pool
before putting them in the hash table could lead to redundant
copies being left behind in the pool because the newly-added key
was not used.  To prevent this, only add keys to the string pool
when the hash table entry is new, and update the hash table entry
so it uses the pooled key.  We can get away with this as in both
cases the key is available as a NUL-terminated string that can
be used for the initial hash look-up.

This should slightly reduce the memory used when writing CRAM
files, and remove some unnecessary memory copies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant