Repository navigation
Always free Tsan fibers - #595
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 (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesTask lifecycle
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Reclaim the stack and the TSan fiber together in AnyTask.releaseCoro, called from the executor's finish cleanup instead of waiting for the last task reference to drop. destroy() still calls it for tasks that were created but never ran.
|
Oh, thank you. I messed up, the goal was to have the tsan fiber destroy done in two places, but I apparently forgot the main one. I've pushed a commit to your branch with a small refactoring, to destroy the tsan fiber immediately after the task exits, not after it's "reaped". |
Partially solves #585
It does not fully solve the leak, but the memory usage growth is now much milder
(125M in 6 seconds instead of original 5G)
I couldn't find where the remaining leak is coming from, but I couldn't figure out if it is due to zio's tsan handling (because when tsan handling is disabled, tsan just crashes the example program), or if it just a TSan thing. Fibers now seem to be freed correctly and zio does nothing else with tsan.
Also this does not at all touch the issue mentioned in comment where TSan caused segfault after destroying seemingly already destroyed fiber, and that issue still persists.
Also as a side effect of this change, weird pause during program exit has disappeared in my program when run with thread sanitizer.