Skip to content

Report final benchmark results as ns/op#216

Open
Sohamkayal4103 wants to merge 1 commit into
masc-ucsc:mainfrom
Sohamkayal4103:bench_final
Open

Report final benchmark results as ns/op#216
Sohamkayal4103 wants to merge 1 commit into
masc-ucsc:mainfrom
Sohamkayal4103:bench_final

Conversation

@Sohamkayal4103
Copy link
Copy Markdown
Contributor

@Sohamkayal4103 Sohamkayal4103 commented May 17, 2026

Summary

This PR updates the final benchmark reporting to use ns/op instead of total wall-clock time.

Changes

  • Convert comparison CSV values from total time to wall_ns / items
  • Report the median ns/op across repeated runs
  • Update plot y-axis labels to show ns/op
  • Update benchmark README documentation to describe the new unit

Why

ns/op is easier to compare across different graph sizes because it normalizes total runtime by the number of operations performed.

Notes

Raw benchmark CSVs still keep wall_ns and items. The normalized ns/op values are generated in the comparison CSV and plots.

Summary by CodeRabbit

  • Documentation

    • Updated benchmark suite documentation clarifying directory layout, output definitions, and LiveHD setup requirements.
    • Added guidance for configuring LiveHD root path and conditional integration.
  • Improvements

    • Benchmark timing metrics now calculated and displayed in nanoseconds per operation.
    • Plot generation dynamically reads and displays time unit labels from benchmark data.

Review Change Stack

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

Warning

Rate limit exceeded

@Sohamkayal4103 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes and 23 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eef8398c-d03c-4ccb-9663-0e392bda04fa

📥 Commits

Reviewing files that changed from the base of the PR and between fe13a7f and 7253f80.

📒 Files selected for processing (5)
  • hhds/benchmarks_final/README.md
  • hhds/benchmarks_final/livehd/README.md
  • hhds/benchmarks_final/scripts/make_comparison.py
  • hhds/benchmarks_final/scripts/plot_results.py
  • hhds/benchmarks_final/scripts/run_all.sh
📝 Walkthrough

Walkthrough

This PR updates the benchmark suite to compute and report timing in nanoseconds per operation instead of milliseconds, adds optional LiveHD benchmark support via environment variables, and adjusts documentation and downstream tools to reflect these changes.

Changes

Benchmark timing units and LiveHD integration

Layer / File(s) Summary
Nanoseconds-per-operation timing computation
hhds/benchmarks_final/scripts/make_comparison.py
Introduces ns_per_op(row) to compute per-operation latency from wall nanoseconds and item count, adds fmt_ns_per_op(values) formatter replacing prior millisecond logic, and updates CSV generation to set time_unit to "ns/op" and populate per-library columns with the new metric.
LiveHD conditional build and execution
hhds/benchmarks_final/scripts/run_all.sh
Adds LIVEHD_ROOT and LIVEHD_BIN environment variables with defaults, conditionally builds the LiveHD benchmark binary when source exists, and wraps LiveHD execution to run the full parameterized suite when available or emit header-only CSV otherwise; intentionally omits backward traversal rows for LiveHD.
Plot label using dynamic time unit
hhds/benchmarks_final/scripts/plot_results.py
Changes y-axis label from hardcoded "median wall time (ms)" to dynamic "median time (...)" where the unit is read from CSV time_unit field with "ns/op" fallback.
Benchmark suite documentation
hhds/benchmarks_final/README.md, hhds/benchmarks_final/livehd/README.md
Main README clarifies livehd/ as a conditional result slot and redefines comparison.csv semantics as median nanoseconds per operation (computed as wall_ns / items); adds "LiveHD notes" section for LIVEHD_ROOT configuration and backward-traversal limitations. LiveHD README replaces prior "no buildable source" guidance with setup instructions including binary name, root path override, CSV schema requirements, and reasons for N/A backward results.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • masc-ucsc/hhds#215: Introduces the benchmark suite structure; this PR directly extends scripts from that change (especially make_comparison.py and plot_results.py) and refines LiveHD integration logic in run_all.sh.

Poem

🐰 Benchmarks now tick in nanoseconds bright,
Per operation flows with clarity and light,
LiveHD joins when roots align with care,
Environment variables float in the air,
Plots and comparisons dance together in grace!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Report final benchmark results as ns/op' clearly and concisely summarizes the main change across the pull request, which converts benchmark reporting from total wall-clock time to normalized nanoseconds per operation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@hhds/benchmarks_final/livehd/README.md`:
- Around line 11-21: Replace the hardcoded developer path shown in README.md
("/Users/hamidsadjadpour/Desktop/masc_ucsc/livehd") with a generic example or a
description of the actual default behavior: state that LIVEHD_ROOT defaults to
the parent directory of the HHDS repo plus "/livehd" (and that you can override
it with the LIVEHD_ROOT environment variable when running run_all.sh); reference
the run_all.sh behavior (the default computed on line 10) so readers know where
the default comes from.

In `@hhds/benchmarks_final/scripts/run_all.sh`:
- Around line 37-42: The LiveHD build step currently can abort the whole script
due to set -e, so modify the block that references LIVEHD_ROOT and runs bazel
build //lgraph:livehd_final_bench to handle failures explicitly: run the build
in a subshell or capture its exit code, set LIVEHD_AVAILABLE=1 only if the build
exits with code 0, and on non-zero exit print a warning (using echo or logger)
but continue without exiting so subsequent benchmarks (HHDS/Boost) still run;
update the block that sets LIVEHD_AVAILABLE and uses LIVEHD_ROOT accordingly to
reflect this guarded build behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 89ecde6f-570b-4b7b-8c55-8d509f6db5e3

📥 Commits

Reviewing files that changed from the base of the PR and between 66198bc and fe13a7f.

📒 Files selected for processing (5)
  • hhds/benchmarks_final/README.md
  • hhds/benchmarks_final/livehd/README.md
  • hhds/benchmarks_final/scripts/make_comparison.py
  • hhds/benchmarks_final/scripts/plot_results.py
  • hhds/benchmarks_final/scripts/run_all.sh

Comment on lines +11 to +21
Default expected path:

```text
/Users/hamidsadjadpour/Desktop/masc_ucsc/livehd
```

Override it with:

```bash
LIVEHD_ROOT=/path/to/livehd bash hhds/benchmarks_final/scripts/run_all.sh
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Replace hardcoded developer path with a generic example.

Line 14 shows an absolute path (/Users/hamidsadjadpour/Desktop/masc_ucsc/livehd) that appears to be from a specific developer's machine. This should be replaced with a generic example or removed in favor of describing the actual default behavior.

The default in run_all.sh line 10 is computed dynamically as the parent directory of the HHDS repo plus /livehd, not a hardcoded path.

📝 Suggested fix
 Default expected path:
 
 ```text
-/Users/hamidsadjadpour/Desktop/masc_ucsc/livehd
+<parent-directory-of-hhds-repo>/livehd

Or describe the default behavior:

```diff
-Default expected path:
+Default behavior:
 
 ```text
-/Users/hamidsadjadpour/Desktop/masc_ucsc/livehd
+LIVEHD_ROOT defaults to the parent directory of the HHDS repo, plus /livehd

</details>

<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
Default expected path:

Suggested change
Default expected path:
```text
/Users/hamidsadjadpour/Desktop/masc_ucsc/livehd
```
Override it with:
```bash
LIVEHD_ROOT=/path/to/livehd bash hhds/benchmarks_final/scripts/run_all.sh
```
Default behavior:
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hhds/benchmarks_final/livehd/README.md` around lines 11 - 21, Replace the
hardcoded developer path shown in README.md
("/Users/hamidsadjadpour/Desktop/masc_ucsc/livehd") with a generic example or a
description of the actual default behavior: state that LIVEHD_ROOT defaults to
the parent directory of the HHDS repo plus "/livehd" (and that you can override
it with the LIVEHD_ROOT environment variable when running run_all.sh); reference
the run_all.sh behavior (the default computed on line 10) so readers know where
the default comes from.

Comment on lines +37 to +42
LIVEHD_AVAILABLE=0
if [[ -f "$LIVEHD_ROOT/lgraph/tests/livehd_final_bench.cpp" ]]; then
echo "Building LiveHD benchmark..."
(cd "$LIVEHD_ROOT" && bazel build //lgraph:livehd_final_bench)
LIVEHD_AVAILABLE=1
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

cat -n hhds/benchmarks_final/scripts/run_all.sh | head -50

Repository: masc-ucsc/hhds

Length of output: 2264


🏁 Script executed:

# Check if set -euo pipefail is set and look at full context
cat hhds/benchmarks_final/scripts/run_all.sh

Repository: masc-ucsc/hhds

Length of output: 8835


🏁 Script executed:

# Also search for documentation about LiveHD being optional
find . -name "*.md" -o -name "*.txt" -o -name "*.rst" | head -20 | xargs grep -l "LiveHD" 2>/dev/null || echo "No docs found"

Repository: masc-ucsc/hhds

Length of output: 133


🏁 Script executed:

cat hhds/benchmarks_final/README.md | head -100

Repository: masc-ucsc/hhds

Length of output: 1574


🏁 Script executed:

cat hhds/benchmarks_final/livehd/README.md

Repository: masc-ucsc/hhds

Length of output: 646


Verify build-failure behavior is intentional.

If livehd_final_bench.cpp exists but the bazel build command fails, the script will exit entirely (due to set -euo pipefail at line 2) and prevent all benchmarks from running. This conflicts with the documented design where LiveHD is optional. The current code sets LIVEHD_AVAILABLE=1 only after a successful build, but if the build fails, the script exits before that flag is ever checked, blocking HHDS and Boost benchmark execution.

Consider wrapping the build in explicit error handling to allow the script to continue when LiveHD build fails:

Suggested fix
 LIVEHD_AVAILABLE=0
 if [[ -f "$LIVEHD_ROOT/lgraph/tests/livehd_final_bench.cpp" ]]; then
   echo "Building LiveHD benchmark..."
-  (cd "$LIVEHD_ROOT" && bazel build //lgraph:livehd_final_bench)
-  LIVEHD_AVAILABLE=1
+  if (cd "$LIVEHD_ROOT" && bazel build //lgraph:livehd_final_bench); then
+    LIVEHD_AVAILABLE=1
+  else
+    echo "Warning: LiveHD build failed; continuing without LiveHD benchmarks."
+  fi
 fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
LIVEHD_AVAILABLE=0
if [[ -f "$LIVEHD_ROOT/lgraph/tests/livehd_final_bench.cpp" ]]; then
echo "Building LiveHD benchmark..."
(cd "$LIVEHD_ROOT" && bazel build //lgraph:livehd_final_bench)
LIVEHD_AVAILABLE=1
fi
LIVEHD_AVAILABLE=0
if [[ -f "$LIVEHD_ROOT/lgraph/tests/livehd_final_bench.cpp" ]]; then
echo "Building LiveHD benchmark..."
if (cd "$LIVEHD_ROOT" && bazel build //lgraph:livehd_final_bench); then
LIVEHD_AVAILABLE=1
else
echo "Warning: LiveHD build failed; continuing without LiveHD benchmarks."
fi
fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hhds/benchmarks_final/scripts/run_all.sh` around lines 37 - 42, The LiveHD
build step currently can abort the whole script due to set -e, so modify the
block that references LIVEHD_ROOT and runs bazel build
//lgraph:livehd_final_bench to handle failures explicitly: run the build in a
subshell or capture its exit code, set LIVEHD_AVAILABLE=1 only if the build
exits with code 0, and on non-zero exit print a warning (using echo or logger)
but continue without exiting so subsequent benchmarks (HHDS/Boost) still run;
update the block that sets LIVEHD_AVAILABLE and uses LIVEHD_ROOT accordingly to
reflect this guarded build behavior.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant