-
Notifications
You must be signed in to change notification settings - Fork 400
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
perf: fast drop LinkStageOutput #842
Conversation
✅ Deploy Preview for rolldown-rs canceled.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #842 +/- ##
==========================================
+ Coverage 80.50% 80.58% +0.07%
==========================================
Files 133 135 +2
Lines 6679 6705 +26
==========================================
+ Hits 5377 5403 +26
Misses 1302 1302 ☔ View full report in Codecov by Sentry. |
CodSpeed Performance ReportMerging #842 will not alter performanceComparing Summary
|
Dropping data to another thread may show advantage on multiple time build but bad for one-time usage such as cli. Saw you making this a draft, not worth for me to continue writing this. |
I'm finding why the ci benchmark is not changed. The js benchmark makes it difficult to see changes at local, but the local rust benchmark will see the result. The pr branch is 180 ms compared to main branch 200 ms for threejs10x.
It is a Rust problem because we never drop memory manually, it depends on Rust compiler. The problem is
The performance is due to has something to do before quit the main thread(drop data), move the action of drop data to other thread will run it and other something in parallel. Here has some detail for it. |
The technique is legit. But maybe don't call it |
To show evidence, you should use Mac Xcode Instruments and see if your CPUs are occupied with drops in the end. |
drop_in_another_thread(std::mem::take(self)); | ||
} | ||
} | ||
|
||
impl Drop for Symbols { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
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.
However, I still think should do this explicitly rather do it in drop
method.
With that being said, we probably could add a flag to show we are running in |
Using I also oppose manually spawning memory to another thread for release internally; on some platforms, like wasm32, this approach would be counterproductive. |
|
||
impl Drop for Symbols { | ||
fn drop(&mut self) { | ||
drop_in_another_thread(std::mem::take(self)); |
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.
I was so against implicity that I didn't notce this in the first place. Does this cause infinity loop? Every drop
on Self
will create a new Self
and when the new Self
is dropped another Self
will be created again.
We end up create infinity threads on infinity Self
.
Overall, I think it's valueable. rspack use this optimization and has some improment. However as @Brooooooklyn said, it's not a best way in any situation, so what we need here is only apply this optimization in some conditions. |
Description