Summary
When working with treefmt, prek costs more than 10 seconds. A minimum reproducible example:
mkdir prek-test
cd prek-test
git init
create a treefmt.toml
# treefmt.toml
[formatter.shfmt]
command = "shfmt"
options = ["-w"]
includes = ["*.sh"]
and a yaml config for prek
repos:
- repo: local
hooks:
- id: treefmt
name: treefmt
entry: treefmt
language: system
always_run: true
and create a simple shell file
echo "echo hello" > test.sh
git add .
will have the following result:
time prek run --all-files
treefmt..................................................................Passed
prek run --all-files 0.02s user 0.07s system 0% cpu 10.046 total
# compared with pre-commit
time pre-commit run --all-files
treefmt..................................................................Passed
pre-commit run --all-files 0.15s user 0.05s system 101% cpu 0.196 total
Platform
Ubuntu 24.04
Version
0.2.20
.pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: treefmt
name: treefmt
entry: treefmt
language: system
always_run: true
Log file
prek -vvv
2026-01-15T09:04:53.396402Z DEBUG prek: 0.2.20
2026-01-15T09:04:53.396434Z DEBUG Args: ["prek", "-vvv"]
2026-01-15T09:04:53.400073Z TRACE get_root: close time.busy=3.60ms time.idle=2.47µs
2026-01-15T09:04:53.400102Z DEBUG Git root: /home/cc/prek-test
2026-01-15T09:04:53.400114Z TRACE Executing `/home/cc/.nix-profile/bin/git ls-files --unmerged`
2026-01-15T09:04:53.401895Z DEBUG Found workspace root at `/home/cc/prek-test`
2026-01-15T09:04:53.401913Z TRACE Include selectors: ``
2026-01-15T09:04:53.401926Z TRACE Skip selectors: ``
2026-01-15T09:04:53.401972Z DEBUG discover{root="/home/cc/prek-test" config=None refresh=false}: Loaded workspace from cache
2026-01-15T09:04:53.401997Z DEBUG discover{root="/home/cc/prek-test" config=None refresh=false}: Loading project configuration path=.pre-commit-config.yaml
2026-01-15T09:04:53.402092Z TRACE discover{root="/home/cc/prek-test" config=None refresh=false}:read_config{path="/home/cc/prek-test/.pre-commit-config.yaml"}: close time.busy=73.8µs time.idle=730ns
2026-01-15T09:04:53.402126Z TRACE discover{root="/home/cc/prek-test" config=None refresh=false}: close time.busy=187µs time.idle=1.02µs
2026-01-15T09:04:53.402148Z TRACE Executing `/home/cc/.nix-profile/bin/git diff --exit-code --name-only -z /home/cc/prek-test/.pre-commit-config.yaml`
2026-01-15T09:04:53.405269Z TRACE Checking lock resource="store" path=/home/cc/.cache/prek/.lock
2026-01-15T09:04:53.405335Z DEBUG Acquired lock resource="store"
2026-01-15T09:04:53.405404Z DEBUG Hooks going to run: ["treefmt"]
2026-01-15T09:04:53.405570Z DEBUG Hook `treefmt` does not need installation
2026-01-15T09:04:53.405592Z TRACE Released lock path=/home/cc/.cache/prek/.lock
2026-01-15T09:04:53.405606Z TRACE Executing `/home/cc/.nix-profile/bin/git diff --diff-filter=A --name-only -z -- /home/cc/prek-test`
2026-01-15T09:04:53.408987Z TRACE Executing `/home/cc/.nix-profile/bin/git write-tree`
2026-01-15T09:04:53.410588Z TRACE Executing `/home/cc/.nix-profile/bin/git diff-index --binary --exit-code 913d6a339cf46bcaae38d7507d2eef56f0e0f0f0 -- /home/cc/prek-test`
2026-01-15T09:04:53.413735Z DEBUG Unstaged changes detected
Unstaged changes detected, stashing unstaged changes to `/home/cc/.cache/prek/patches/1768467893413-753534.patch`
2026-01-15T09:04:53.413808Z DEBUG Cleaning working tree
2026-01-15T09:04:53.417452Z TRACE collect_files: Executing `/home/cc/.nix-profile/bin/git rev-parse --git-dir`
2026-01-15T09:04:53.418869Z TRACE collect_files: Executing `cd /home/cc/prek-test && /home/cc/.nix-profile/bin/git diff --cached --name-only --diff-filter=ACMRTUXB -z`
2026-01-15T09:04:53.420741Z DEBUG collect_files: Staged files: 3
2026-01-15T09:04:53.420758Z TRACE collect_files: close time.busy=407µs time.idle=2.91ms
2026-01-15T09:04:53.420780Z TRACE for_project{project=.}: close time.busy=1.28µs time.idle=679ns
2026-01-15T09:04:53.420801Z TRACE get_diff{path="/home/cc/prek-test"}: Executing `/home/cc/.nix-profile/bin/git diff -- /home/cc/prek-test`
2026-01-15T09:04:53.422415Z TRACE get_diff{path="/home/cc/prek-test"}: close time.busy=170µs time.idle=1.45ms
2026-01-15T09:04:53.422435Z TRACE Files for project `.` after filtered: 3
2026-01-15T09:04:53.428374Z TRACE for_hook{hook="treefmt"}: close time.busy=5.93ms time.idle=979ns
2026-01-15T09:04:53.428425Z TRACE Files for hook `treefmt` after filtered: 3
treefmt..................................................................2026-01-15T09:04:53.428462Z TRACE run{hook_id=treefmt language=system}: Resolved command: treefmt
2026-01-15T09:04:53.428516Z TRACE run{hook_id=treefmt language=system}: Running treefmt total_files=3 concurrency=96
2026-01-15T09:04:53.428635Z TRACE run{hook_id=treefmt language=system}: Executing `cd /home/cc/prek-test && treefmt test.sh pre-commit-config.yaml treefmt.toml`
2026-01-15T09:05:03.454542Z TRACE run{hook_id=treefmt language=system}: close time.busy=3.46ms time.idle=10.0s
2026-01-15T09:05:03.454632Z TRACE get_diff{path="/home/cc/prek-test"}: Executing `/home/cc/.nix-profile/bin/git diff -- /home/cc/prek-test`
2026-01-15T09:05:03.456809Z TRACE get_diff{path="/home/cc/prek-test"}: close time.busy=427µs time.idle=1.76ms
Passed
- hook id: treefmt
- duration: 10.03s
traversed 3 files
emitted 1 files for processing
formatted 0 files (0 changed) in 10.018s
Summary
When working with
treefmt,prekcosts more than 10 seconds. A minimum reproducible example:mkdir prek-test cd prek-test git initcreate a
treefmt.tomland a yaml config for
prekand create a simple shell file
will have the following result:
Platform
Ubuntu 24.04
Version
0.2.20
.pre-commit-config.yaml
Log file