Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Profile latency and allocations with hotpath#956

Merged
j178 merged 4 commits into
j178:masterfrom
lmmx:ci-hotpath
Oct 28, 2025
Merged

Profile latency and allocations with hotpath#956
j178 merged 4 commits into
j178:masterfrom
lmmx:ci-hotpath

Conversation

@lmmx

@lmmx lmmx commented Oct 23, 2025

Copy link
Copy Markdown
Collaborator
  • perf(hotpath): profile prek run on its own repo

Hotpath instrumentation

I've added #[cfg_attr(feature = "hotpath", hotpath::measure)] to the main hot paths I think we care about:

  • run() - the entry point for prek run
  • collect_files() - file discovery and filtering
  • install_hooks() - hook environment setup
  • run_hooks() - overall hook execution
  • run_hook() - individual hook runs
  • clone_repo() - repo cloning

The guard is initialised in main() so profiling output prints when the program exits.

Status: ready for review

  • The CI is failing because the PR is not merged and the new check will only run from the master branch

@lmmx lmmx changed the title ci hotpath perf(ci): profile latency and allocations with hotpath Oct 23, 2025
@lmmx lmmx marked this pull request as draft October 23, 2025 09:15
@codecov

codecov Bot commented Oct 23, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.94%. Comparing base (b524f38) to head (4ed1b94).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #956   +/-   ##
=======================================
  Coverage   89.94%   89.94%           
=======================================
  Files          66       66           
  Lines       12227    12227           
=======================================
  Hits        10997    10997           
  Misses       1230     1230           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Oct 23, 2025

Copy link
Copy Markdown
Contributor

📦 Cargo Bloat Comparison

Binary size change: +0.00% (16.1 MiB → 16.1 MiB)

Expand for cargo-bloat output

PR Branch Results

 File  .text     Size          Crate Name
 0.6%   1.4% 101.1KiB          prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.5%   1.1%  85.8KiB           prek prek::builtin::pre_commit_hooks::Implemented::run::{{closure}}
 0.5%   1.0%  76.8KiB           prek prek::languages::<impl prek::config::Language>::run::{{closure}}
 0.4%   0.9%  70.0KiB           prek prek::run::{{closure}}
 0.4%   0.9%  63.8KiB           prek prek::archive::unpack::{{closure}}
 0.2%   0.5%  40.9KiB regex_automata regex_automata::meta::strategy::new
 0.2%   0.5%  40.1KiB          prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.2%   0.5%  38.5KiB           prek prek::identify::by_extension::{{closure}}
 0.2%   0.5%  35.0KiB           prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.4%  32.9KiB           prek prek::workspace::Workspace::discover
 0.2%   0.4%  32.8KiB           prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4%  32.7KiB           prek prek::languages::node::installer::NodeInstaller::install::{{closure}}
 0.2%   0.4%  31.8KiB             h2 h2::proto::connection::DynConnection<B>::recv_frame
 0.2%   0.4%  31.7KiB             h2 h2::proto::connection::Connection<T,P,B>::poll
 0.2%   0.4%  26.2KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.2%   0.3%  25.8KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::connect_to::{{closure}}::{{closure}}::{{closure}}
 0.2%   0.3%  25.2KiB        globset globset::GlobSetBuilder::build
 0.2%   0.3%  24.9KiB           prek prek::main
 0.1%   0.3%  24.6KiB           prek prek::languages::golang::installer::GoInstaller::install::{{closure}}
 0.1%   0.3%  23.7KiB          hyper hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
39.7%  87.4%   6.4MiB                And 10107 smaller methods. Use -n N to show more.
45.4% 100.0%   7.3MiB                .text section size, the file size is 16.1MiB

Base Branch Results

 File  .text     Size          Crate Name
 0.6%   1.4% 101.1KiB          prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.5%   1.1%  85.8KiB           prek prek::builtin::pre_commit_hooks::Implemented::run::{{closure}}
 0.5%   1.0%  76.8KiB           prek prek::languages::<impl prek::config::Language>::run::{{closure}}
 0.4%   0.9%  70.0KiB           prek prek::run::{{closure}}
 0.4%   0.9%  63.8KiB           prek prek::archive::unpack::{{closure}}
 0.2%   0.5%  40.9KiB regex_automata regex_automata::meta::strategy::new
 0.2%   0.5%  40.1KiB          prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.2%   0.5%  38.5KiB           prek prek::identify::by_extension::{{closure}}
 0.2%   0.5%  35.0KiB           prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.4%  32.9KiB           prek prek::workspace::Workspace::discover
 0.2%   0.4%  32.8KiB           prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4%  32.7KiB           prek prek::languages::node::installer::NodeInstaller::install::{{closure}}
 0.2%   0.4%  31.8KiB             h2 h2::proto::connection::DynConnection<B>::recv_frame
 0.2%   0.4%  31.7KiB             h2 h2::proto::connection::Connection<T,P,B>::poll
 0.2%   0.4%  26.2KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.2%   0.3%  25.8KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::connect_to::{{closure}}::{{closure}}::{{closure}}
 0.2%   0.3%  25.2KiB        globset globset::GlobSetBuilder::build
 0.2%   0.3%  24.9KiB           prek prek::main
 0.1%   0.3%  24.6KiB           prek prek::languages::golang::installer::GoInstaller::install::{{closure}}
 0.1%   0.3%  23.7KiB          hyper hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
39.7%  87.4%   6.4MiB                And 10107 smaller methods. Use -n N to show more.
45.4% 100.0%   7.3MiB                .text section size, the file size is 16.1MiB

@lmmx lmmx force-pushed the ci-hotpath branch 3 times, most recently from ccbde77 to e660cfe Compare October 23, 2025 11:06
@lmmx

lmmx commented Oct 23, 2025

Copy link
Copy Markdown
Collaborator Author

Hmmm I'm getting an error here

Run # Build and profile base branch
Previous HEAD position was ca9423d Merge b3cee9ffa89779b707b8db6f7842a8cd4c180642 into 697b101b6d20a3d4b2d2dc6258d486c8402a842c
HEAD is now at 697b101 Improve styling for stashing error message (#953)
error: the package 'prek' does not contain this feature: hotpath
Error: Process completed with exit code 101.

but I added that feature to Cargo TOML

  • It is on 697b101 which is the master branch HEAD commit without the feature, hence the error (this just means it won’t run a modified workflow introduced by a commit

In other words it is failing because it is not merged (so would need to be merged to see it in action)!

When it succeeds (blocked by this step) it should give a comment like the cargo-bloat one (uses the same mechanism)

@lmmx lmmx marked this pull request as ready for review October 23, 2025 11:22
@j178

j178 commented Oct 24, 2025

Copy link
Copy Markdown
Owner

Thanks! But I'll put this on the back burner for now and come back to it after I wrap up some other higher priority stuff.

@lmmx

lmmx commented Oct 24, 2025

Copy link
Copy Markdown
Collaborator Author

Yes no urgency ☺️ I just saw it cross my timeline and thought it could be good for perf chasing, but already done lots on this lately

@j178 j178 changed the title perf(ci): profile latency and allocations with hotpath Profile latency and allocations with hotpath Oct 28, 2025
@j178 j178 added the performance Performance improvements label Oct 28, 2025
@j178

j178 commented Oct 28, 2025

Copy link
Copy Markdown
Owner

Thank you!

@j178 j178 merged commit 65a2fe2 into j178:master Oct 28, 2025
21 of 22 checks passed
@lmmx lmmx deleted the ci-hotpath branch October 28, 2025 14:54
@lmmx

lmmx commented Oct 29, 2025

Copy link
Copy Markdown
Collaborator Author

I don't think it's working correctly, will have a look into it later

feliblo pushed a commit to feliblo/prek that referenced this pull request Oct 29, 2025
* perf(hotpath): profile prek run on its own repo

* Combine pr comments

* Fix path

---------

Co-authored-by: Jo <[email protected]>
feliblo pushed a commit to feliblo/prek that referenced this pull request Oct 29, 2025
* perf(hotpath): profile prek run on its own repo

* Combine pr comments

* Fix path

---------

Co-authored-by: Jo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants