Expand description
The record of where one wrapped git worktree add spent its time, step by step,
appended beside the commit timing record.
What:
The record of where one wrapped git worktree add spent its time, step by step, appended to a size-capped file in the
common Git directory beside the commit timing record.
Why:
An add that took thirteen seconds could not be split afterwards without a strace that distorted it. Each step is a
stretch of the command (a walk of the source, a Git run, the snapshot call, a durable write), timed on the monotonic
clock; a step inside another is taken out of the outer one, so the steps are disjoint and what none covers is reported
as otherMs. The record goes to the file only, in one append when the command ends, with no flush to disk, and it
never changes what the add does.
In TS you’d write (pseudocode):
begin(commonDir);
const value = step('walkSource', () => walk());
finish(exitCode); // appends JSON.stringify(record) + '\n' to join(commonDir, 'cli-git-worktree-add-timing.jsonl')Structs§
- Recorder
- What: The steps of one add, filled as the add runs and written when it ends. Why: The accounting is separate from the clock so that the controls can drive it with chosen times.
Constants§
- ADD_
TIMING_ FILE - The file inside the common Git directory that collects the add timing records of every worktree of the repository.
- ADD_
TIMING_ SCHEMA_ VERSION - The version of the record’s fields; it changes only when a field’s meaning changes, never when a field is added.
Functions§
- begin
- Begin recording the add of the repository whose common Git directory is
common_dir, replacing any earlier recording of this thread. - finish
- What:
End the recording and append its record to the repository’s add timing file, best effort.
Why:
The command’s result never depends on the record: a file that cannot be written is only a debug line. The directory is
never created and nothing is flushed to disk, so the record costs one
write. - git_
step_ label - What:
The step name of one Git run:
gitand the subcommand, found past the global options that take a value (-C,-c,--git-dir,--work-tree) and the flags that do not. Why: The record says how many Git processes an add started and how long each kind took, which names the avoidable ones. - note
- Note a fact about the add being recorded; nothing outside a recording.
- step
- Run
bodyas the stepname; with no recording begun,bodyruns alone. - work
- What:
Run
bodyas work namednameon any thread, adding its time to the name’s sum; with no recording begun,bodyruns alone. Why: The repair of package managers runs its tools on worker threads, which the thread’s own steps cannot see; the sum over threads says how much work a step held, and the step that waited for it says how long the add waited.