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

Refactor Get() to work with new faster cache #447

Merged
merged 9 commits into from
Dec 6, 2021

Conversation

jtieri
Copy link
Member

@jtieri jtieri commented Nov 30, 2021

Created a new cache in nodedb.go that would be maintained for our newer FastNode structs and implemented the pieces necessary for changing Get() as per this

immutable_tree.go Outdated Show resolved Hide resolved
fast_node.go Outdated Show resolved Hide resolved
fast_node.go Outdated Show resolved Hide resolved
nodedb.go Show resolved Hide resolved
nodedb.go Show resolved Hide resolved
@jtieri jtieri marked this pull request as ready for review December 1, 2021 22:38
@jackzampolin jackzampolin changed the title WIP: refactor Get() to work with new faster cache Refactor Get() to work with new faster cache Dec 2, 2021
@ValarDragon ValarDragon merged commit 0944259 into dev/iavl_data_locality Dec 6, 2021
@ValarDragon ValarDragon deleted the justin/fast-node-get branch December 6, 2021 02:04

return t.root.get(t, key)
fastNode, err := t.ndb.GetFastNode(key)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we log error here? When this operation will fail? Would be good to add a comment. @ValarDragon

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea is that if this GetFastNode() call fails for any reason, we assume there is no FastNode equivalent for this key in the nodedb and fall back to the original, yet slower, IAVL logic in place.

I'll add debug logging here and add a comment to make this more clear.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the FastNode is confusing. Maybe we should rename to CachedNode?


if len(key) == 0 {
panic("nodeDB.GetFastNode() requires key")
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

please do not panic!

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch Robert, I meant to replace all the panics used with the traditional node logic with errors so that failure to fetch a fast node simply falls back to the original logic in IAVL.

I'll get this taken care of in the next PR

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