-
Notifications
You must be signed in to change notification settings - Fork 13
feat(persistent): More efficient HugrView iterators for PersistentHugr #2595
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
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2595 +/- ##
==========================================
+ Coverage 83.36% 83.39% +0.02%
==========================================
Files 257 259 +2
Lines 50664 50741 +77
Branches 46187 46264 +77
==========================================
+ Hits 42238 42313 +75
- Misses 6059 6061 +2
Partials 2367 2367
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d02aa6c to
b9c152c
Compare
b9c152c to
d9e4c1e
Compare
cb8268a to
357d42a
Compare
357d42a to
b3f3dde
Compare
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.
Nice!
It's a bit annoying that we need to force evaluation of the whole children when popping stuff from the back, but there's no way around it.
| children_cache: HashMap<CommitId, Vec<CommitId>>, | ||
| } | ||
|
|
||
| impl PersistentHugrCache { |
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.
Add some docs!
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.
yup will do!
hugr-persistent/src/trait_impls.rs
Outdated
| Either::Left(IterValidNodes::new(self, children.fuse())) | ||
| } else { | ||
| // children are precisely children of the commit hugr | ||
| Either::Right(children) | ||
| }; | ||
| DoubleEndedIteratorAdapter::from(it) |
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.
We only need to wrap the IterValidNodes case, Either::Right(children) is already a doubleEndedIterator
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.
true, fixing that!
True, but tbh it's barely (ever?) used backwards. |
This PR improves persistent-hugr performance. It does three things
PersistentHugrCacheto cache the list of children of each commit.HugrView::childrenby adding a custom iterator, instead of materialising the entire hugr in memory.fn node_statusandenum NodeStatusfromhugr-persistent/src/wire.rsto hugr-persistent/src/persistent_hugr.rsNote:
Beyond the first two children, the order of
and
may no longer match when node is a Dataflow parent. This is annoying but I could not find an easy way to fix this. AFAIK this should not lead to observable differences according to current specs, but might be an issue at some point. I've created issue #2618 to track this.