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

Node from stream backrefs optimisation #532

Merged
merged 110 commits into from
Feb 11, 2025

Conversation

matt-o-how
Copy link
Contributor

Use a Vec<NodePtr> stack instead of NodePtr / SExps in node_from_stream_backrefs and add a new traverse_path_with_vec() function to handle backrefs

@matt-o-how matt-o-how requested a review from arvidn January 13, 2025 16:18
Copy link

coveralls-official bot commented Jan 13, 2025

Pull Request Test Coverage Report for Build 13266025427

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 238 of 238 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 94.141%

Totals Coverage Status
Change from base Build 12933937517: 0.3%
Covered Lines: 6298
Relevant Lines: 6690

💛 - Coveralls

Copy link
Contributor

@arvidn arvidn left a comment

Choose a reason for hiding this comment

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

it looks correct, as far as I can tell. I think we need tests for all interesting cases, to make sure it works. I'm also interested in seeing a benchmark. Does this make a difference? I would expect it to at least use less memory, which typically means faster on small machines (like Raspberry PI)

Copy link
Contributor

@arvidn arvidn left a comment

Choose a reason for hiding this comment

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

I think these things are still needed:

  • preserve the existing function, partly to control when we switch over to the new one, and also to be able to test that both behave the same
  • ensure the new function produce the same result as the old one, e.g. with a fuzzer.
  • ensure the new function behave the same with regards to limits to the number of pairs created by Allocator. It can be tested in a fuzzer by building with the counters build feature
  • benchmark to demonstrate that this is an improvement (this should probably be done early, as we might want to scrap this idea if it doesn't carry its weight)
  • survey the mainnet and testnet blockchains to see if back references into the parse-stack eveer exists in the wild
  • unit tests for all edge cases

@matt-o-how matt-o-how force-pushed the node_from_stream_backrefs_optimisation branch from 166b35f to cb47c16 Compare January 17, 2025 10:09
@matt-o-how matt-o-how force-pushed the node_from_stream_backrefs_optimisation branch from cb47c16 to 17f7c09 Compare January 27, 2025 16:53
@arvidn
Copy link
Contributor

arvidn commented Feb 11, 2025

These are the benchmark results I get on raspberry Pi 5:

deserialize/node_from_bytes_backrefs-compressed
                        time:   [352.36 µs 358.58 µs 367.28 µs]
deserialize/node_from_bytes_backrefs_old-compressed
                        time:   [344.03 µs 350.53 µs 358.28 µs]

So, a slight performance degradation. I would have expected it to be a slight improvement on a system with small caches. But presumably the memory savings is worth it. Do we have a measurement on that?

@arvidn arvidn merged commit ee71e95 into main Feb 11, 2025
28 checks passed
@arvidn arvidn deleted the node_from_stream_backrefs_optimisation branch February 11, 2025 15:53
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.

2 participants