Skip to content

Make debugger significantly faster (backport #12645)#12746

Merged
mergify[bot] merged 4 commits into2.25-maintenancefrom
mergify/bp/2.25-maintenance/pr-12645
Mar 24, 2025
Merged

Make debugger significantly faster (backport #12645)#12746
mergify[bot] merged 4 commits into2.25-maintenancefrom
mergify/bp/2.25-maintenance/pr-12645

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Mar 24, 2025

Motivation

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

Context

cc @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).

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)
@mergify mergify bot requested a review from edolstra as a code owner March 24, 2025 16:05
@mergify mergify bot added automatic backport This PR is a backport produced by automation (does not trigger backporting) merge-queue labels Mar 24, 2025
@github-actions github-actions bot added the repl The Read Eval Print Loop, "nix repl" command and debugger label Mar 24, 2025
@mergify mergify bot merged commit 1d16259 into 2.25-maintenance Mar 24, 2025
27 checks passed
@mergify mergify bot deleted the mergify/bp/2.25-maintenance/pr-12645 branch March 24, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automatic backport This PR is a backport produced by automation (does not trigger backporting) merge-queue repl The Read Eval Print Loop, "nix repl" command and debugger

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant