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

DL Compress get_keys_values output by hash. #17243

Merged
merged 5 commits into from Jan 12, 2024
Merged

DL Compress get_keys_values output by hash. #17243

merged 5 commits into from Jan 12, 2024

Conversation

fchirica
Copy link
Contributor

@fchirica fchirica commented Jan 8, 2024

Introduces get_keys_values_compressed which maps from hash(key) to hash(leaf). hint_keys_values is modified to store this instead of all (key, values) data to optimize the memory usage.

@fchirica fchirica requested a review from a team as a code owner January 8, 2024 18:37
@fchirica fchirica added DataLayer Changed Required label for PR that categorizes merge commit message as "Changed" for changelog labels Jan 8, 2024
@fchirica
Copy link
Contributor Author

fchirica commented Jan 9, 2024

Removing coverage diff, the two lines in data store correspond to assertions failing and the benchmarks line is just changing type to an already existing not covered structure.

chia/data_layer/data_store.py Outdated Show resolved Hide resolved
Copy link
Contributor

File Coverage Missing Lines
chia/data_layer/data_store.py 94.1% lines 743, 746
chia/data_layer/util/benchmark.py 0.0% lines 26
Total Missing Coverage
47 lines 3 lines 93%

Copy link
Collaborator

@altendky altendky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These thoughts may apply to a lot of existing code as well, I'm not sure, but... This assumes that on average the keys and values are at least the size of the hash. If they are not then this makes the situation actually worse. Using a smaller hash size is limited by the assumptions around not having hash collisions. I'm guessing that these tradeoffs were already considered and we don't expect the 32 byte effective minimum key/value size to be an issue?

chia/data_layer/data_layer_util.py Show resolved Hide resolved
@fchirica fchirica added the ready_to_merge Submitter and reviewers think this is ready label Jan 11, 2024
@cmmarslender cmmarslender merged commit 41c69f5 into main Jan 12, 2024
265 of 266 checks passed
@cmmarslender cmmarslender deleted the fc.compress_kv branch January 12, 2024 15:41
@emlowe
Copy link
Contributor

emlowe commented Jan 12, 2024

These thoughts may apply to a lot of existing code as well, I'm not sure, but... This assumes that on average the keys and values are at least the size of the hash. If they are not then this makes the situation actually worse. Using a smaller hash size is limited by the assumptions around not having hash collisions. I'm guessing that these tradeoffs were already considered and we don't expect the 32 byte effective minimum key/value size to be an issue?

Yea, it's true that in the case of smaller k,v items, this increases the size to 32bytes - but I think that it is worth it to normalize to a hash size (for consistency and code simplicity, etc). Even with a small k,v tree, the increase in size is likely quite small in absolute terms so I don't expect any practical issue with doing this.

Not sure what the memory footprint is for the recursive SQL query here though as that is mostly unchanged, but at least we don't have to keep large k,v items in memory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changed Required label for PR that categorizes merge commit message as "Changed" for changelog DataLayer ready_to_merge Submitter and reviewers think this is ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants