Title: Idea: Improve hook speed by skipping before/after diff via readonly flag · Issue #1564 · pre-commit/pre-commit · GitHub
Open Graph Title: Idea: Improve hook speed by skipping before/after diff via readonly flag · Issue #1564 · pre-commit/pre-commit
X Title: Idea: Improve hook speed by skipping before/after diff via readonly flag · Issue #1564 · pre-commit/pre-commit
Description: pre-commit/pre_commit/commands/run.py Lines 175 to 185 in 4f5cb99 diff_cmd = ('git', 'diff', '--no-ext-diff') diff_before = cmd_output_b(*diff_cmd, retcode=None) if not hook.pass_filenames: filenames = () time_before = time.time() langua...
Open Graph Description: pre-commit/pre_commit/commands/run.py Lines 175 to 185 in 4f5cb99 diff_cmd = ('git', 'diff', '--no-ext-diff') diff_before = cmd_output_b(*diff_cmd, retcode=None) if not hook.pass_filenames: filenam...
X Description: pre-commit/pre_commit/commands/run.py Lines 175 to 185 in 4f5cb99 diff_cmd = ('git', 'diff', '--no-ext-diff') diff_before = cmd_output_b(*diff_cmd, retcode=None) if not hook...
Opengraph URL: https://github.com/pre-commit/pre-commit/issues/1564
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Idea: Improve hook speed by skipping before/after diff via readonly flag ","articleBody":"https://github.com/pre-commit/pre-commit/blob/4f5cb99ff5c9e13edcd97461c09dcaf271197e5c/pre_commit/commands/run.py#L175-L185\r\n\r\nHi all,\r\n\r\nI am looking at implemented pre-commit to replace a harder-to-maintain custom bash script our company current uses. In my initial tests, pre-commit works great, except for the fact that it is slow. The majority of our hooks are readonly in nature, and run quite fast. However, on our repository, pre-commit is spending close to 1 second per hook performing a before/after diff.\r\n\r\nI added some instrumentation, and in our test case with 10 executed hooks, the execution time of pre-commit is >7 seconds with the before/after diffs, and ~1 second with those diffs disabled. I will note this is an extremely large repository, with many thousands of files. Generally, git actions are somewhat slow on it.\r\n\r\nIn exploring issues related to perf, I had found https://github.com/pre-commit/pre-commit/issues/510, which seems to tackle a different problem - individual hooks that take a while, rather than the overhead of pre-commit itself. However, there was one comment that got me thinking, regarding a `readonly` attribute one could apply to a hook. I know - this metadata would only be as truthy as the author who wrote the hook, but if a hook was marked as readonly, `pre-commit` could theoretically skip the before/after hook diffs.\r\n\r\nAny thoughts? Happy to contribute the PR if maintainers see this as valuable.","author":{"url":"https://github.com/jhenkens","@type":"Person","name":"jhenkens"},"datePublished":"2020-08-20T14:49:14Z","url":"https://github.com/pre-commit/pre-commit/issues/1564"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:05c3a2ee-e371-89b4-537a-74393201469d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9980:1A09C8:142ED0B:1AB07EB:6B06625B |
| html-safe-nonce | b9af1e15dd3456471cc91a74b5f6f68a069c5d58058c1d21b4ba78228130253f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTgwOjFBMDlDODoxNDJFRDBCOjFBQjA3RUI6NkIwNjYyNUIiLCJ2aXNpdG9yX2lkIjoiMTM2NjI4MzIzMTQwMTMzNDY3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3488fe35936758c86323ecf26b31f2391ac44df3be1cb0efb98c7d56004ae0c5 |
| hovercard-subject-tag | issue:682778735 |
| github-keyboard-shortcuts | repository,issues,commits,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pre-commit/pre-commit/1564/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c73be4f8ad858c94200d185c30441f26ef52fd4a411f30d956812a5a9e2adf70/pre-commit/pre-commit/issues/1564 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c73be4f8ad858c94200d185c30441f26ef52fd4a411f30d956812a5a9e2adf70/pre-commit/pre-commit/issues/1564 |
| og:image:alt | pre-commit/pre_commit/commands/run.py Lines 175 to 185 in 4f5cb99 diff_cmd = ('git', 'diff', '--no-ext-diff') diff_before = cmd_output_b(*diff_cmd, retcode=None) if not hook.pass_filenames: filenam... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jhenkens |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6324e6ac990fb6befbec840cc0e102a1071c339bfe8f9826bb12de2e3ba1d297 |
| turbo-cache-control | no-preview |
| go-import | github.com/pre-commit/pre-commit git https://github.com/pre-commit/pre-commit.git |
| octolytics-dimension-user_id | 6943086 |
| octolytics-dimension-user_login | pre-commit |
| octolytics-dimension-repository_id | 17689377 |
| octolytics-dimension-repository_nwo | pre-commit/pre-commit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 17689377 |
| octolytics-dimension-repository_network_root_nwo | pre-commit/pre-commit |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7f0aa75f4141d440c6110dc31af7ea7797abb6c4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width