Make debugger significantly faster (backport #12645)#12746
Merged
mergify[bot] merged 4 commits into2.25-maintenancefrom Mar 24, 2025
Merged
Make debugger significantly faster (backport #12645)#12746mergify[bot] merged 4 commits into2.25-maintenancefrom
mergify[bot] merged 4 commits into2.25-maintenancefrom
Conversation
All of this code doesn't actually depend on anything from libexpr. Because Pos is so tigtly coupled with Error, it makes sense to have in the same library. (cherry picked from commit a53b184)
This should provide context for follow-up commits in the patch series. (cherry picked from commit bf12aed)
Previous implementation didn't actually check if
std::get_if returned a nullptr:
std::optional<SourcePath> getSourcePath() const {
return *std::get_if<SourcePath>(&origin);
}
(cherry picked from commit 50123f2)
The underlying issue is that debugger code path was calling PosTable::operator[] in each eval method. This has become incredibly expensive since 5d9fdab. While we are it it, I've reworked the code to not use std::shared_ptr where it really isn't necessary. As I've documented in previous commits, this is actually more a workaround for recursive header dependencies now and is only necessary in `error.hh` code. Some ad-hoc benchmarking: After this commit: ``` Benchmark 1: nix eval nixpkgs#hello --impure --ignore-try --no-eval-cache --debugger Time (mean ± σ): 784.2 ms ± 7.1 ms [User: 561.4 ms, System: 147.7 ms] Range (min … max): 773.5 ms … 792.6 ms 10 runs ``` On master 3604c7c: ``` Benchmark 1: nix eval nixpkgs#hello --impure --ignore-try --no-eval-cache --debugger Time (mean ± σ): 22.914 s ± 0.178 s [User: 18.524 s, System: 4.151 s] Range (min … max): 22.738 s … 23.290 s 10 runs ``` (cherry picked from commit adbd083)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The underlying issue is that debugger code path was
calling
PosTable::operator[]in eachevalmethod.This has become incredibly expensive since 5d9fdab.
While we are it it, I've reworked the code to
not use std::shared_ptr where it really isn't necessary.
As I've documented in previous commits, this is actually
more a workaround for recursive header dependencies now
and is only necessary in
error.hhcode.Some ad-hoc benchmarking:
After this commit:
On master 3604c7c:
Context
nix build --debugger#10796cc @roberth for 50123f2
cc @tomberek, #12544 (comment)
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.
This is an automatic backport of pull request #12645 done by [Mergify](https://mergify.com).