-
Notifications
You must be signed in to change notification settings - Fork 704
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
Remove cached node bytes from merkle nodes #2393
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a benchmark that measures the effect of this change?
Co-authored-by: Dan Laine <[email protected]> Signed-off-by: David Boehm <[email protected]>
Not explicitly. This is mostly to reduce the size of cache entries since they currently store the node's bytes twice, once as the raw bytes and once in the various fields on the node struct. Removing this extra copy with roughly halve the memory footprint per node, so we should be able to store almost twice the nodes in the cache. |
@@ -66,17 +64,7 @@ func (n *node) hasValue() bool { | |||
|
|||
// Returns the byte representation of this node. | |||
func (n *node) bytes() []byte { | |||
if n.nodeBytes == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this cached value means we'll have to reserialize the node before writing it. Are we concerned about the additional time that'll take? Seems to be a tradeoff between memory usage and CPU usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anything we are writing is something we edited so this would have always been nil
We mostly load nodes just before we edit them, so holding on to the bytes just wastes memory.