scan --staged exports and re-maps the whole index on every commit
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 58/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- git, go
- Lĩnh vực
- devtools, performance
Hướng nghiên cứu
Start with internal/engine/diffscan.go and internal/engine/run.go to trace the staged scan, then inspect ExportIndex and mkdirAllReadable in internal/gitx/gitx.go and cache behavior in internal/mapper/mapper.go. Run the staged scan tests and add coverage for a clean work tree and an unstaged edit on top of a staged one. Done means the clean case skips export, the staged scan reuses HEAD's cached map, and each export directory is created once.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
The pre-commit path (scan --staged) writes every tracked file to an export directory, maps all of it from scratch and deletes it, so the hook's time grows with the size of the repository, not with the size of the commit.
Where
internal/gitx/gitx.go:906-924,:976-1006(ExportIndex,writeBlobs)internal/gitx/gitx.go:848-861(mkdirAllReadable: oneMkdirper path segment per file)internal/engine/diffscan.go:248(exportStaged)internal/engine/run.go:186-208,:468(mapOpts.Changedset only for--changed;RememberSecretsover the whole export)internal/mapper/mapper.go:115-141(no HEAD in the export, so no cache applies).pre-commit-hooks.yaml:7(hooks runscan --staged --offlinewithalways_run: true)
Details
ExportIndex keeps every stage-0 regular entry of git ls-files --stage and writes each blob. The changed set is never passed in. The export is a fresh git init with no HEAD, so gitx.HeadSHA fails in mapper.Build and neither the commit cache nor the HEAD-plus-changed cache applies: the whole export is listed, binary-sniffed and mapped, then RememberSecrets parses every Dockerfile, Terraform and YAML file in it. Only the seeders are limited to the staged files.
Impact
Derived from the code, not measured. For a repository of 20,000 tracked files and 300 MB, each commit costs 20,000 file creates, about 100,000 extra Mkdir calls, 300 MB written and read back, and 20,000 deletes, for a one-line change. On Windows, where small-file creation under real-time antivirus is in the millisecond range per file, the hook goes from sub-second to tens of seconds. A --changed scan of the same tree reuses the cached map of HEAD and reads only the changed files.
Suggested fix
Make the work proportional to the commit, while keeping "what was scanned is what the commit will contain". (1) Fast path: when no tracked file differs between the work tree and the index (the usual case), skip the export and scan the work tree with the changed set, as --changed does. (2) Otherwise pass the real repository's HEAD and the changed set to the mapper so it can load the cached map of HEAD and read only the staged files, and export only what differs. Independently, have mkdirAllReadable remember directories it already created during one export.
Acceptance criteria
- A staged scan with a clean work tree does not write an export
- A staged scan reuses the cached map of HEAD
-
mkdirAllReadablecreates each directory once per export - The staged-content guarantee of #149 still holds (test with an unstaged edit on top of a staged one)
Related: #149, #121
Getting started
- Relevant files: .pre-commit-hooks.yaml, internal/engine/diffscan.go, internal/engine/run.go, internal/gitx/gitx.go, internal/mapper/mapper.go
- How to run tests:
make test-short(Unix) or.\make.ps1 test-short(Windows PowerShell);make lintbefore you call it done - Related docs: CONTRIBUTING.md, docs/ARCHITECTURE.md
Filed by repo-audit/full-audit at 50e92ec. Severity: medium. Effort: M. audit-key: performance|internal/gitx/gitx.go|ExportIndex
- Ngôn ngữ chính
- Go
- Star
- 0
- Fork
- 1
- Merge trung bình
- 8 giờ 14 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TMHSDigital/Spackle
-
ci good first issue severity: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
TMHSDigital/Spackle#206 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ci severity: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
TMHSDigital/Spackle#205 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue severity: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
TMHSDigital/Spackle#199 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue severity: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 87/100
TMHSDigital/Spackle#195 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation good first issue severity: medium
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
TMHSDigital/Spackle#188 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của TMHSDigital/Spackle
Issue tương tự
-
deskclose human-decided leaves the legacy decision-needed label and applies no human-decidedĐang mởbug effort:s impact:med raised-by:worker risk:low to:worker
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
medici-finance/assay#8120 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
factory:subtask
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
agent-substrate/substrate#4308 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
celestiaorg/celestia-app#8877 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
sweep
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
bketelsen/truenas-mcp#112 ·
Maintainer thường phản hồi trong vòng 1 ngày