Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blockchain: Use hash values in structs. #992

Merged
merged 1 commit into from
Jan 30, 2018

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Jan 29, 2018

This requires #990

This modifies the BestState struct in the blockchain package to store hashes directly instead of pointers to them and updates callers to deal with the API change in the exported BestState struct.

In general, the preferred approach for hashes moving forward is to store hash values in complex data structures, particularly those that will be used for cache entries, and accept pointers to hashes in arguments to functions.

Some of the reasoning behind making this change is:

  • It is generally preferred to avoid storing pointers to data in cache objects since doing so can easily lead to storing interior pointers into other structs that then can't be GC'd
  • Keeping the hash values directly in the structs provides better cache locality

@davecgh davecgh force-pushed the blockchain_concrete_hash_in_structs branch 2 times, most recently from 7215de9 to bcea2b7 Compare January 29, 2018 04:00
@davecgh davecgh force-pushed the blockchain_concrete_hash_in_structs branch from bcea2b7 to 73a5e0f Compare January 29, 2018 18:05
This modifies the BestState struct in the blockchain package to store
hashes directly instead of pointers to them and updates callers to deal
with the API change in the exported BestState struct.

In general, the preferred approach for hashes moving forward is to store
hash values in complex data structures, particularly those that will be
used for cache entries, and accept pointers to hashes in arguments to
functions.

Some of the reasoning behind making this change is:

- It is generally preferred to avoid storing pointers to data in cache
  objects since doing so can easily lead to storing interior pointers into
  other structs that then can't be GC'd
- Keeping the hash values directly in the structs provides better
  cache locality
@davecgh davecgh force-pushed the blockchain_concrete_hash_in_structs branch from 73a5e0f to 20a8ccc Compare January 30, 2018 19:53
@davecgh davecgh merged commit 20a8ccc into decred:master Jan 30, 2018
@davecgh davecgh deleted the blockchain_concrete_hash_in_structs branch January 30, 2018 20:14
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.

3 participants