perf(trace): post-commit starts three git processes for each committed file

Ouverte
#3,756 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
62/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
git, go
Domaine
cli, performance

Piste de recherche

Start with settleCommittedLines in app/cli/pkg/action/trace_hook_handler.go and FileAt in app/cli/internal/trace/git/lines.go; check how both ExecClient and GoGitClient read committed files. Then inspect recordRootChanges in app/cli/pkg/action/trace_agent_hook.go and the relevant existing tests. Done when both callers can read multiple paths without resolving the same commit separately for every file, and paths missing from the commit still produce no content.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

chainloop component/CLI performance trace-provider
Problem

The post-commit hook of Chainloop Trace starts 3 git processes for each committed file that has pending AI lines. A large commit makes the hook slow.

settleCommittedLines (app/cli/pkg/action/trace_hook_handler.go) calls client.FileAt(repoRoot, sha, path) one time for each pending path in each session. ExecClient.FileAt (app/cli/internal/trace/git/lines.go) runs these commands for each call:

  1. git rev-parse --verify --quiet <sha>^{commit}
  2. git cat-file -e <sha>:<path>
  3. git cat-file blob <sha>:<path>

The commit SHA is the same for all the files. Thus step 1 runs again for each file without a reason.

Measurement

Local clone of this repository (3.3k files). One commit changes 301 files, and all the changes are AI lines that are pending.

Item Value
Git processes that post-commit starts More than 900
Time of post-commit Approximately 5.2 s

This is on main. It is not caused by #3631.

Suggested fix

Read all the files with one git cat-file --batch process. Send one <sha>:<path> line for each path on stdin. For a path that is not in the commit, Git prints <sha>:<path> missing. Use this result as "no content", as FileAt does now. Resolve the commit one time before the loop.

For example, add a Client method that takes a revision and a list of paths and returns the content by path. The GoGitClient version can read the commit tree one time.

recordRootChanges (app/cli/pkg/action/trace_agent_hook.go) calls FileAt for each changed path in the same way, during PostToolUse for Bash calls. The same method can fix that caller too.

Langage dominant
Go
Étoiles
582
Forks
61
Merge moyen
12 h 47 min
PR mergées (30 j)
137

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de chainloop-dev/chainloop

Toutes les issues de chainloop-dev/chainloop

Issues similaires

Plus d'issues Go

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.