Skip to content

Conversation

Boshen
Copy link
Member

@Boshen Boshen commented Sep 15, 2025

Summary

  • Added comprehensive benchmark suite for PackageJson::parse() to measure deserialization performance
  • Made PackageJson::parse() public API to enable benchmarking from outside the crate
  • Benchmarks cover various package.json complexity levels from simple to complex real-world files

Benchmark Results

The new benchmarks test different package.json sizes and parsing scenarios:

Benchmark Time Description
Small ~323ns Basic name/version fields only
Medium ~1.4µs Includes main, exports, imports, browser fields
Large ~3.5µs Complex nested exports/imports with dependencies
Real Complex ~2.3µs Actual package.json from fixtures
Batch (4 files) ~7.7µs Sequential parsing of 4 different files
Parallel Batch ~27.5µs Parallel parsing using rayon

Motivation

Package.json parsing is a critical operation in the resolver that happens frequently. Having benchmarks helps:

  • Track performance regressions
  • Optimize the parsing logic
  • Understand the performance characteristics of different package.json structures

Test Plan

  • Benchmarks compile and run successfully
  • cargo bench package_json_deserialization produces consistent results
  • No breaking changes to existing code (only made one internal function public)

🤖 Generated with Claude Code

- Made PackageJson::parse() public to enable benchmarking
- Added comprehensive benchmarks testing various package.json sizes:
  - Small (323ns): Basic name/version fields
  - Medium (1.4µs): Includes exports, imports, browser fields
  - Large (3.5µs): Complex nested structure with dependencies
  - Real file (2.3µs): Actual package.json from fixtures
  - Batch parsing (7.7µs): Sequential parsing of 4 files
  - Parallel batch (27.5µs): Parallel parsing using rayon

This helps measure and track the performance of package.json parsing,
which is a critical operation in the resolver.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

graphite-app bot commented Sep 15, 2025

How to use the Graphite Merge Queue

Add the label merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link

codecov bot commented Sep 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.89%. Comparing base (79d5752) to head (2e31d85).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #698      +/-   ##
==========================================
- Coverage   94.90%   94.89%   -0.01%     
==========================================
  Files          12       12              
  Lines        2886     2882       -4     
==========================================
- Hits         2739     2735       -4     
  Misses        147      147              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

codspeed-hq bot commented Sep 15, 2025

CodSpeed Performance Report

Merging #698 will not alter performance

Comparing feat/package-json-benchmark (2e31d85) with main (79d5752)

Summary

✅ 3 untouched
🆕 6 new

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 batch_4_files N/A 78.4 µs N/A
🆕 complex_real N/A 35.4 µs N/A
🆕 large N/A 46.6 µs N/A
🆕 medium N/A 25 µs N/A
🆕 parallel_batch_4_files N/A 82.7 µs N/A
🆕 small N/A 10.6 µs N/A

@Boshen Boshen merged commit bd4210f into main Sep 15, 2025
17 checks passed
@Boshen Boshen deleted the feat/package-json-benchmark branch September 15, 2025 06:43
@Boshen Boshen mentioned this pull request Sep 15, 2025
Boshen added a commit that referenced this pull request Sep 15, 2025
## Summary

- Added comprehensive benchmark suite for `PackageJson::parse()` to
measure deserialization performance
- Made `PackageJson::parse()` public API to enable benchmarking from
outside the crate
- Benchmarks cover various package.json complexity levels from simple to
complex real-world files

## Benchmark Results

The new benchmarks test different package.json sizes and parsing
scenarios:

| Benchmark | Time | Description |
|-----------|------|-------------|
| Small | ~323ns | Basic name/version fields only |
| Medium | ~1.4µs | Includes main, exports, imports, browser fields |
| Large | ~3.5µs | Complex nested exports/imports with dependencies |
| Real Complex | ~2.3µs | Actual package.json from fixtures |
| Batch (4 files) | ~7.7µs | Sequential parsing of 4 different files |
| Parallel Batch | ~27.5µs | Parallel parsing using rayon |

## Motivation

Package.json parsing is a critical operation in the resolver that
happens frequently. Having benchmarks helps:
- Track performance regressions
- Optimize the parsing logic
- Understand the performance characteristics of different package.json
structures

## Test Plan

- [x] Benchmarks compile and run successfully
- [x] `cargo bench package_json_deserialization` produces consistent
results
- [x] No breaking changes to existing code (only made one internal
function public)

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
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