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

Fix cleanChild() algorithm #56

Closed
rvagg opened this issue Aug 5, 2020 · 0 comments · Fixed by #57
Closed

Fix cleanChild() algorithm #56

rvagg opened this issue Aug 5, 2020 · 0 comments · Fixed by #57
Labels
need/triage Needs initial labeling and prioritization

Comments

@rvagg
Copy link
Member

rvagg commented Aug 5, 2020

Pulling this out of a TODO attached to cleanChild() in #52 because I think it might be the most important thing to address with the current impl:

// TODO(rvagg): I don't think the logic here is correct. A compaction should
// occur strictly when: there are no links to child nodes remaining (assuming
// we've cleaned them first and they haven't caused a cascading collapse to
// here) and the number of direct elements (actual k/v pairs) in this node is
// equal o bucketSize+1. Anything less than bucketSize+1 is invalid for a node
// other than the root node (which probably won't have cleanChild() called on
// it). e.g.
// https://github.com/rvagg/iamap/blob/fad95295b013c8b4f0faac6dd5d9be175f6e606c/iamap.js#L333
// If we perform this depth-first, then it's possible to see the collapse
// cascade upward such that we end up with some parent node with a bucket with
// only bucketSize elements. The canonical form of the HAMT requires that
// any node that could be collapsed into a parent bucket is collapsed and.

This is more than just a perf improvement and needs to be addressed - either to prove that my concerns are wrong, or get the algorithm correct so it's not pushing beyond CHAMP invariants.

@rvagg rvagg added the need/triage Needs initial labeling and prioritization label Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant