-
Notifications
You must be signed in to change notification settings - Fork 69
Refactor chain to use a vec #1681
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
base: master
Are you sure you want to change the base?
Refactor chain to use a vec #1681
Conversation
a9dec5c to
18360e7
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.
Pull request overview
This PR refactors the Chain filter operation from a binary tree structure Chain(Filter, Filter) to a vector-based structure Chain(Vec<Filter>). The motivation is to improve performance during filter optimization, specifically making operations like finding the last element in a chain much faster.
Key Changes:
- Changed
Op::Chainfrom storing twoFilterarguments to storing aVec<Filter> - Updated all filter optimization algorithms (simplify, flatten, step, invert) to work with vector-based chains
- Modified parsing to accumulate chain elements into a vector
- Updated serialization/deserialization to handle variable-length chains
- Adjusted all filter application logic to iterate through chain vectors
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| josh-core/src/filter/op.rs | Changed Chain enum variant from two Filter parameters to Vec |
| josh-core/src/flang/parse.rs | Updated parsing to build chains as vectors, handling accumulation of multiple filters |
| josh-core/src/filter/persist.rs | Modified serialization to store variable-length chains; deserialization now reads arbitrary number of chain elements |
| josh-core/src/filter/opt.rs | Completely rewrote chain optimization logic to handle vectors: flattening nested chains, combining adjacent operations, and handling empty/single-element cases |
| josh-core/src/filter/mod.rs | Updated all chain-related operations (apply, unapply, lazy_refs, resolve_refs, path calculations) to iterate through vectors |
| josh-core/src/flang/mod.rs | Modified pretty-printing and spec generation to handle vector-based chains with special cases for empty and two-element chains |
| josh-core/src/build.rs | Updated chain builder function to wrap arguments in a vector |
| tests//.t | Test expectations updated to reflect new chain representation with flat numbering (chain/0, chain/1, chain/2) instead of nested (chain/0/chain/0/chain/0) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0fd49f5 to
e9ef0bc
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.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e9ef0bc to
da4cef4
Compare
It was discovered during profiling that filter optimisation spends lots of time rearranging chains. Using a vec will make operations like finding the last element in a chain much faster.
da4cef4 to
faf1032
Compare
It was discovered during profiling that filter optimisation spends lots of time rearranging chains.
Using a vec will make operations like finding the last element in a chain much faster.