-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Add FreezeLock
type and use it to store Definitions
#115401
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Have you benchmarked using the std RwLock unconditionally for Definitions? |
|
I thought this PR used |
The new datastructure is fancy enough that I think it should have a test suite with various possible executions, and it should pass But before we go there, it may be good to actually show that this is going to be faster than a lock or rwlock with some benchmarks. If this is meant to get the perf of the non-parallel compiler, it may be good to try out switching to std::sync::RwLock on the non-parallel compiler and running it through the perf suite. |
I'm still a bit confused about your The main benefit here and in #115418 is the nicer semantics over There does seem to be a bit of lock contention on |
That makes a lot of sense. Please include this information in the main post, or even better the documentation on Freeze, comparing it with the RwLock usage. Let's see what perf says about it in the single threaded case @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 4b90650cfed7714649dd4fce2026911d73dddc56 with merge fbe9d41f54b8ad93a882dc9bb0d841c032925d5c... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Freeze
type and use it to store Definitions
FreezeLock
type and use it to store Definitions
☔ The latest upstream changes (presumably #115422) made this pull request unmergeable. Please resolve the merge conflicts. |
Out of curiosity, since I'm struggling to understand memory ordering: in the case where Thank you very much for your time! |
I tried this out in #115557. Looks like incremental encoding invokes these functions a lot after the data structure gets frozen. |
I still believe this, but it's simple enough, so 🤷 r=me after a rebase |
I rebased it and changed the guards to pass a reference to the lock to deal with the issue of passing guards as function parameters. |
@vacuus The store happens before the load, otherwise that sounds right. |
This comment has been minimized.
This comment has been minimized.
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (a0c28cd): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 627.8s -> 627.776s (-0.00%) |
There's some incremental regressions, so I tested the parallel compiler in that scenario:
It seems like this more of a serial / parallel compiler tradeoff, performance wise. |
Use `Freeze` for `SourceFile` This uses the `Freeze` type in `SourceFile` to let accessing `external_src` and `lines` be lock-free. Behavior of `add_external_src` is changed to set `ExternalSourceKind::AbsentErr` on a hash mismatch which matches the documentation. `ExternalSourceKind::Unneeded` was removed as it's unused. Based on rust-lang#115401.
Use `Freeze` for `SourceFile` This uses the `Freeze` type in `SourceFile` to let accessing `external_src` and `lines` be lock-free. Behavior of `add_external_src` is changed to set `ExternalSourceKind::AbsentErr` on a hash mismatch which matches the documentation. `ExternalSourceKind::Unneeded` was removed as it's unused. Based on rust-lang#115401.
Use `Freeze` for `SourceFile` This uses the `Freeze` type in `SourceFile` to let accessing `external_src` and `lines` be lock-free. Behavior of `add_external_src` is changed to set `ExternalSourceKind::AbsentErr` on a hash mismatch which matches the documentation. `ExternalSourceKind::Unneeded` was removed as it's unused. Based on rust-lang/rust#115401.
@rustbot label: +perf-regression-triaged |
Use `Freeze` for `SourceFile` This uses the `Freeze` type in `SourceFile` to let accessing `external_src` and `lines` be lock-free. Behavior of `add_external_src` is changed to set `ExternalSourceKind::AbsentErr` on a hash mismatch which matches the documentation. `ExternalSourceKind::Unneeded` was removed as it's unused. Based on rust-lang/rust#115401.
This adds a
FreezeLock
type which allows mutation using a lock until the value is frozen where it can be accessed lock-free. It's used to storeDefinitions
inUntracked
instead of aRwLock
. Unlike the current scheme of leaking read guards this doesn't deadlock if definitions is written to after no mutation are expected.