andrewrk / poop

Performance Optimizer Observation Platform
MIT License
788 stars 50 forks source link

show command stderr of failure #29

Closed dweiller closed 1 year ago

dweiller commented 1 year ago

Closes #9. Here is the output for a command failing.

I  ~/S/poop (child-stderr +) [1] > zig-out/bin/poop ls 'ls a' ls  -d 50
Benchmark 1 (24 runs): ls
  measurement      mean ± σ               minmax                   outliers         delta
  wall_time        1.432ms ± 484.231us    773.111us1.972ms           0 ( 0%)        0%
  peak_rss         2M ± 70K               2M2M                       0 ( 0%)        0%
  cpu_cycles       387633 ± 64478         354835608024               3 (13%)        0%
  instructions     398961 ± 75            398903399132               0 ( 0%)        0%
  cache_references 28741 ± 509            2759230467                 2 ( 8%)        0%
  cache_misses     9038 ± 255             86939953                   1 ( 4%)        0%
  branch_misses    4892 ± 124             47125187                   0 ( 0%)        0%

error: Benchmark 2 command 'ls a' failed with exit code 2:
─────────────────── stderr ───────────────────
ls: cannot access 'a': No such file or directory
──────────────────────────────────────────────

Any benchmarks after the failed one are skipped.

I don't think it makes that much sense for poop to capture arbitrarily large amounts of stderr, so I think it makes sense to just truncate after a certain amount is captured. Due to the way std.io.Poller reads, it only really makes sense to use a power of two sized buffer - I chose 4096 for no particular reason. The waystd.io.Poller reads means that even if there is more than 4096 bytes of stderr, any where between 4096-512+1=3585 and 4096 bytes might be read as the poller always tries to read at least 512 bytes.

If the stderr is truncated the stderr will look like this:

────────────── stderr truncated ──────────────
ls: cannot access 'a': N
──────────────────────────────────────────────

But with presumably much more output

andrewrk commented 1 year ago

edit: never mind me, I forgot to pull!

andrewrk commented 1 year ago

Reverted in 14e2f304b23128025e6440f9034983e9f9e6bcf8. Your code has a deadlock in it, try testing with a program that outputs a lot of stderr.