Skip to content

critical-path: format/group/color output - #1652

Open
9999years wants to merge 1 commit into
meta:mainfrom
mercury:critical-path-format
Open

9999years wants to merge 1 commit into
meta:mainfrom
mercury:critical-path-format

Conversation

@9999years

Copy link
Copy Markdown
Contributor

The buck2 log critical-path and buck2 log slowest-path commands print human-readable output that's quite difficult to read:

  • Many output lines represent sub-millisecond durations.
    • Output is uncolored, so it's hard to tell which lines are relevant at a glance.
  • There are lots of lines for waiting unknown, which are generally not very useful.
    • waiting unknown lines cause a single 'human-legible' line to be split into dozens of entries.
  • All times are printed in microseconds, so I hope you can divide by a million in your head :)
  • Columns are not named very clearly; the waiting column indicates time that overlapped other work (and did not extend the build).

Here we fix those issues:

  • Lines are colored by duration:
    • <100ms is gray
    • <1s is normal
    • <5s is yellow
    • <10s is red
    • >10s is bright/bold red
  • Consecutive lines (including 'waiting unknown' lines) are deduplicated and summed together.
  • A new --threshold option can be used to hide small entries, e.g. --threshold=10ms.
    • If the --threshold option is used, the output will end with a line explaining how much was hidden: "hid 778 low-impact entries under 10.0ms, totaling 1.10s".
  • The output begins with a legend explaining what the column names mean.

With these changes, the critical-path output for a large build can be condensed from 828 lines to to a very human-readable 51 lines (including legend and blank lines).

Here is an example from an open-source build. Before (only a small portion of the output is shown, full output is 222 lines):

image

After (53 lines):

image

The `buck2 log critical-path` and `buck2 log slowest-path` commands
print human-readable output that's quite difficult to read:

- Many output lines represent sub-millisecond durations.
    - Output is uncolored, so it's hard to tell which lines are relevant
      at a glance.
- There are lots of lines for `waiting unknown`, which are generally not
  very useful.
  - `waiting unknown` lines cause a single 'human-legible' line to be
    split into dozens of entries.
- All times are printed in microseconds, so I hope you can divide by a
  million in your head :)
- Columns are not named very clearly; the `waiting` column indicates
  time that overlapped other work (and did not extend the build).

Here we fix those issues:
- Lines are colored by duration:
    - <100ms is gray
    - <1s is normal
    - <5s is yellow
    - <10s is red
    - >10s is bright/bold red
- Consecutive lines (including 'waiting unknown' lines) are deduplicated
  and summed together.
- A new `--threshold` option can be used to hide small entries, e.g.
  `--threshold=10ms`.
  - If the `--threshold` option is used, the output will end with a line
    explaining how much was hidden: "hid 778 low-impact entries under
    10.0ms, totaling 1.10s".
- The output begins with a legend explaining what the column names mean.

With these changes, an 828-line `buck2 log critical-path` output can be
condensed to a very human-readable 51 lines (including legend and blank
lines).
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 25, 2026
@meta-codesync

meta-codesync Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D134544285. (Because this pull request was imported automatically, there will not be any future comments.)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant