loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add elapsed time on debug for slow git commands (#25642)

To record which command is slow, this PR adds a debug log for slow git
operations.

---------

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: delvh <dev.lh@web.de>

authored by

Lunny Xiao
Lauris BH
delvh
and committed by
GitHub
f35ea2b0 934124c6

+9 -1
+9 -1
modules/git/command.go
··· 301 301 } 302 302 defer finished() 303 303 304 + startTime := time.Now() 305 + 304 306 cmd := exec.CommandContext(ctx, c.prog, c.args...) 305 307 if opts.Env == nil { 306 308 cmd.Env = os.Environ() ··· 327 329 } 328 330 } 329 331 330 - if err := cmd.Wait(); err != nil && ctx.Err() != context.DeadlineExceeded { 332 + err := cmd.Wait() 333 + elapsed := time.Since(startTime) 334 + if elapsed > time.Second { 335 + log.Debug("slow git.Command.Run: %s (%s)", c, elapsed) 336 + } 337 + 338 + if err != nil && ctx.Err() != context.DeadlineExceeded { 331 339 return err 332 340 } 333 341