refactor(bootstrapper): replace recursion with trampoline for iterative execution#1109
refactor(bootstrapper): replace recursion with trampoline for iterative execution#1109rd4398 wants to merge 1 commit intopython-wheel-build:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe bootstrap flow was converted from direct recursive calls to a generator-based, trampoline-driven model. Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
dhellmann
left a comment
There was a problem hiding this comment.
I have to admit, this is a small clean change but I really had to study the trampoline code to make sense of how it works. I'm not sure how I feel about hiding the cleverness in another library vs. having a non-recursive depth-first traversal algorithm here in fromager.
|
|
||
| def _bootstrap_gen( | ||
| self, req: Requirement, req_type: RequirementType | ||
| ) -> typing.Generator[typing.Any, typing.Any, None]: |
There was a problem hiding this comment.
Maybe we could be more specific with types here, instead of using typing.Any?
There was a problem hiding this comment.
I think we cannot be more specific because of the way the way trampoline works
- YieldType — we yield child generators, but each yield site yields a different generator type, so a single precise type isn't possible within one method
- SendType — the value received from yield depends on which child generator was yielded (e.g., SourceBuildResult from _build_from_source, None from _bootstrap_gen)
There was a problem hiding this comment.
We can still declare our type accurately, even if trampoline doesn't care, can't we?
Yeah, I agree. I wonder whether we want to move back to implementing our plan for iterative bootstrap even though it is a significantly big change. @LalatenduMohanty what do you think? cc @tiran |
I'd be interested in seeing the change to compare them for readability. |
Ack, will submit the PR today with that implementation. |
…ve execution Convert recursive bootstrap methods to generators using the trampoline library, eliminating Python's recursion depth limit for deep/wide dependency graphs. Co-Authored-By: Claude <claude@anthropic.com> Signed-off-by: Rohan Devasthale <rdevasth@redhat.com>
c2f6fb6 to
1f7ac06
Compare
Done. @dhellmann @LalatenduMohanty #1116 is the alternative implementation. Please take a look when you have time |
This commit converts recursive bootstrap methods to generators using the trampoline library, eliminating Python's recursion depth limit for deep/wide dependency graphs.
trampoline source: https://gitlab.com/ferreum/trampoline
Closes: #1068