Skip to content

Make benchmark link count configurable: 10 for PRs, 1000 for main branch#12

Merged
konard merged 3 commits intomainfrom
issue-11-e4b0910fa505
Dec 26, 2025
Merged

Make benchmark link count configurable: 10 for PRs, 1000 for main branch#12
konard merged 3 commits intomainfrom
issue-11-e4b0910fa505

Conversation

@konard
Copy link
Member

@konard konard commented Dec 26, 2025

📋 Summary

This PR implements a configurable benchmark link count to optimize CI/CD performance:

  • Pull Requests: Execute benchmarks with 10 links per operation for faster feedback
  • Main/Master Branch: Execute benchmarks with 1000 links per operation for comprehensive performance data

🔧 Implementation Details

Changes Made

  1. Modified rust/src/lib.rs:

    • Changed LINK_COUNT from a constant (const) to a lazy-initialized static that reads from the BENCHMARK_LINK_COUNT environment variable
    • Defaults to 10 links when the environment variable is not set
    • Uses once_cell::Lazy for thread-safe initialization
  2. Updated benchmark files:

    • Modified all benchmark code to dereference the lazy static using *LINK_COUNT
    • Files updated: create.rs, delete.rs, update.rs
  3. Modified .github/workflows/rust.yml:

    • Added BENCHMARK_LINK_COUNT environment variable to the "Run benchmark" step
    • Conditionally sets value based on GitHub context:
      • 1000 when pushing to main or master branch
      • 10 for all pull requests
  4. Code formatting:

    • Applied cargo fmt to ensure all Rust code follows the project's formatting standards

Benefits

  • Faster PR feedback: Benchmarks run ~100x faster in PRs (10 links vs 1000 links)
  • Accurate main branch data: Full 1000-link benchmarks preserved for merged code
  • Configurable: Can be overridden locally via environment variable for testing

Testing

  • ✅ Code compiles successfully (cargo check)
  • ✅ Formatting applied (cargo fmt)
  • ✅ Changes verified to match issue requirements

📚 Technical Approach

The implementation uses Rust's Lazy<T> type from the once_cell crate to initialize the link count once at runtime by reading the environment variable. This approach:

  • Maintains backward compatibility (defaults to 10)
  • Allows runtime configuration without recompilation
  • Thread-safe initialization
  • Zero runtime overhead after first access

🔗 Related

Fixes #11


🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #11
@konard konard self-assigned this Dec 26, 2025
- Changed LINK_COUNT from a constant to a lazy static that reads from BENCHMARK_LINK_COUNT env var
- Defaults to 10 links for faster PR benchmarks
- Set to 1000 links for main/master branch via GitHub Actions workflow
- Updated all benchmark code to dereference the lazy static with *LINK_COUNT
- Applied cargo fmt to format all Rust code

Fixes #11

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Make that in Pull Requests benchmark execute only 10 links per type of operation, but when merged to default branch 1000 links per type of operations are executed in benchmark Make benchmark link count configurable: 10 for PRs, 1000 for main branch Dec 26, 2025
@konard konard marked this pull request as ready for review December 26, 2025 14:59
@konard
Copy link
Member Author

konard commented Dec 26, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $1.497674 USD
  • Calculated by Anthropic: $0.889932 USD
  • Difference: $-0.607742 (-40.58%)
    📎 Log file uploaded as GitHub Gist (382KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit 5667609 into main Dec 26, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant