Idea: Improve hook speed by skipping before/after diff via readonly flag
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- git, python
- 领域
- performance, tooling
调研方向
Start with pre_commit/commands/run.py at lines 175-185 and review issue #510 for related performance context. Determine how a readonly hook attribute would affect before/after diff handling, then verify that readonly hooks avoid the diff overhead without changing behavior for hooks that may modify files.
由索引模型根据 Issue 内容生成。
描述
Hi all,
I 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.
I 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.
In 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.
Any thoughts? Happy to contribute the PR if maintainers see this as valuable.
- 主要语言
- Python
- 星标
- 15.6k
- 派生
- 1k
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pre-commit/pre-commit 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
pre-commit/pre-commit#3664 · 3 条评论 ·
-
bug windows
难度 2/5 1-3 小时 新手友好度 78/100
pre-commit/pre-commit#2530 · 6 条评论 ·
-
难度 3/5 1-2 天 新手友好度 42/100
pre-commit/pre-commit#3501 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 58/100
pre-commit/pre-commit#3410 · 4 条评论 · 3 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 35/100
pre-commit/pre-commit#3278 · 6 条评论 ·
查看 pre-commit/pre-commit 的全部 Issue
相似的 Issue
-
sponsored
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 86/100
Diaoul/subliminal#1382 ·
-
难度 1/5 1 小时以内 新手友好度 92/100
-
triage/confirmed
难度 2/5 1-3 小时 新手友好度 88/100
agentscope-ai/agentscope#2775 ·
-
难度 2/5 1-3 小时 新手友好度 84/100