[engine] Reuse stdout buffer for git operations and exec

Since parallel checks are always limited to NumCPU()+2, this limits the
number of stdout buffers created.

This reduce memory usage and fragmentation for exec(). Create three
16kib buffers to reduce initial fragmentation.

This enables running git commands in parallel. For now, only git diff
runs in parallel.

Improvements all around for memory allocation, with significant delta:

name                   old alloc/op   new alloc/op   delta
CtxOsExec                 137kB ± 0%      70kB ± 0%  -49.01%  (p=0.004 n=5+6)
CtxOsExec100             9.07MB ± 0%    2.55MB ± 5%  -71.85%  (p=0.004 n=5+6

Change-Id: If9c92826db94d0bb2193827dfa8fb7d3f7830060
Reviewed-on: https://fuchsia-review.googlesource.com/c/shac-project/shac/+/859576
Reviewed-by: Oliver Newman <olivernewman@google.com>
Commit-Queue: Marc-Antoine Ruel <maruel@google.com>
3 files changed
tree: 25c98fd7667238936fe9572e4fc387382e4e2a4e
  1. .github/
  2. doc/
  3. images/
  4. internal/
  5. scripts/
  6. .gitignore
  7. AUTHORS
  8. check_doc.star
  9. codecov.yml
  10. CONTRIBUTING.md
  11. go.mod
  12. go.star
  13. go.sum
  14. LICENSE
  15. licenses.star
  16. main.go
  17. OWNERS
  18. PATENTS
  19. README.md
  20. shac.star
  21. shac.textproto
README.md

shac

Shac (Scalable Hermetic Analysis and Checks) is a unified and ergonomic tool and framework for writing and running static analysis checks.

Shac checks are written in Starlark.

usage demonstration

Usage

go install go.fuchsia.dev/shac-project/shac@latest
shac check
shac doc shac.star | less

Documentation

Contributing

⚠ The source of truth is at https://fuchsia.googlesource.com/shac-project/shac.git and uses Gerrit for code review.

See CONTRIBUTING.md to submit changes.