Skip to content

perf(pkg): memoize Lock_dir.get_with_path - #12758

Merged
Alizter merged 1 commit into
ocaml:mainfrom
Alizter:push-mylrktlnpwos
Nov 21, 2025
Merged

Alizter merged 1 commit into
ocaml:mainfrom
Alizter:push-mylrktlnpwos

Conversation

@Alizter

@Alizter Alizter commented Nov 20, 2025 •

Copy link
Copy Markdown
Collaborator

Avoids countless re-reads of our build-side lock directory.

Before:

[ocaml-cohttp]$ hyperfine "dune build"
Benchmark 1: dune build
  Time (mean ± σ):      4.842 s ±  0.060 s    [User: 4.444 s, System: 0.365 s]
  Range (min … max):    4.725 s …  4.908 s    10 runs

After:

[ocaml-cohttp]$ hyperfine "dune build"
Benchmark 1: dune build
  Time (mean ± σ):      3.488 s ±  0.044 s    [User: 3.186 s, System: 0.283 s]
  Range (min … max):    3.399 s …  3.550 s    10 runs

Comment thread src/dune_rules/lock_dir.ml Resolved
@Alizter Alizter added the package management Dune's package management — `(pkg)` stanza, lockdirs, `dune pkg` commands label Nov 20, 2025
@rgrinberg

Copy link
Copy Markdown
Member

Looks good. I adjusted the PR so that we don't parse the same lock dir when it's used in different contexts.

@Alizter
Alizter marked this pull request as ready for review November 21, 2025 09:12
Before:
```
[ocaml-cohttp]$ hyperfine "dune build"
Benchmark 1: dune build
  Time (mean ± σ):      4.842 s ±  0.060 s    [User: 4.444 s, System: 0.365 s]
  Range (min … max):    4.725 s …  4.908 s    10 runs
```
 
After:
```
[ocaml-cohttp]$ hyperfine "dune build"
Benchmark 1: dune build
  Time (mean ± σ):      3.488 s ±  0.044 s    [User: 3.186 s, System: 0.283 s]
  Range (min … max):    3.399 s …  3.550 s    10 runs
```

Signed-off-by: Ali Caglayan <[email protected]>
@Alizter Alizter added this to the [pkg]: Minimal Stable Product milestone Nov 21, 2025
@Alizter
Alizter enabled auto-merge November 21, 2025 09:13
@Alizter
Alizter merged commit b08266c into ocaml:main Nov 21, 2025
@Alizter
Alizter deleted the push-mylrktlnpwos branch November 21, 2025 09:30
Alizter added a commit that referenced this pull request Apr 6, 2026
Add a test showing that the lock dir is currently loaded once per
context when contexts share the same lock dir path.

This invariant was introduced in #12758 but not tested.

Depends on #14064.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package management Dune's package management — `(pkg)` stanza, lockdirs, `dune pkg` commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants