Skip to content

Use brew --prefix to get brew package config path for install script#4505

Merged
lovell merged 1 commit intolovell:0.35from
dsherret:perf_install_postinstall_perf_brew_prefix
Mar 12, 2026
Merged

Use brew --prefix to get brew package config path for install script#4505
lovell merged 1 commit intolovell:0.35from
dsherret:perf_install_postinstall_perf_brew_prefix

Conversation

@dsherret
Copy link

We noticed the Bun package manager is excluding the install script for your package because it is slow.

https://github.com/oven-sh/bun/blob/a305e99af5d9dbe74ffabfa5a3c0cfdf815ac71a/src/install/postinstall_optimizer.zig#L14-L19

In Deno we were looking into making a similar optimization, but we don't believe it would be good to override your preferences just so we can do better on an install benchmark.

I was looking at the code and I believe that it should actually get the value from brew --prefix then ./lib/pkgconfig. I'm not sure though. It is much faster to do this on my machine.

% hyperfine --warmup 5 "brew --prefix" "brew environment --plain"
Benchmark 1: brew --prefix
  Time (mean ± σ):      22.9 ms ±   1.6 ms    [User: 8.3 ms, System: 8.8 ms]
  Range (min … max):    18.8 ms …  29.1 ms    120 runs
 
Benchmark 2: brew environment --plain
  Time (mean ± σ):     789.2 ms ±  65.3 ms    [User: 209.1 ms, System: 139.0 ms]
  Range (min … max):   714.9 ms … 884.1 ms    10 runs
 
Summary
  brew --prefix ran
   34.41 ± 3.68 times faster than brew environment --plain

@dsherret dsherret changed the title perf(install): use brew --prefix to get brew package config path Use brew --prefix to get brew package config path for install script Mar 12, 2026
@lovell lovell changed the base branch from main to 0.35 March 12, 2026 08:45
@lovell
Copy link
Owner

lovell commented Mar 12, 2026

Hi David, thank you for taking the time to investigate the problem and provide a solution, this will definitely improve things for those using Homebrew and building from source .

Luckily this class of problem should disappear in the next release as build from source becomes opt-in, please see #4490 (comment) for more details.

@lovell lovell merged commit 3d1ef62 into lovell:0.35 Mar 12, 2026
31 checks passed
@dsherret dsherret deleted the perf_install_postinstall_perf_brew_prefix branch March 12, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants