Skip to content

Conversation

@moreal
Copy link
Contributor

@moreal moreal commented Jan 13, 2026

This pull request adds a benchmark for the json_loads function under the executions category. The dummy data is the metadata of the psutil package, which is decoded during the pip install pyperf process. I hope it becomes trackable at https://rustpython.github.io/benchmarks.

If there are any changes needed for the benchmark category or the benchmark dummy data, please let me know.


NOTE: This pull request was extracted from PR #6704.

Summary by CodeRabbit

  • Chores
    • Added JSON loading benchmark script for performance testing.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

A new JSON loading benchmark script is added that reads and parses a JSON file from the data directory using the standard library's json module to measure JSON deserialization performance.

Changes

Cohort / File(s) Summary
Benchmark script
benches/benchmarks/json_loads.py
New benchmark script that reads and parses benches/_data/pypi_org__simple__psutil.json using json.loads() to measure JSON deserialization performance.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A JSON file hops in with glee,
Loads parse swift as can be,
With benchmark so keen,
Performance we'll glean,
Speedier parsing for you and me! 📊

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: introducing a new benchmark for json_loads executions, which aligns with the PR's objective of adding a json_loads benchmark.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

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
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: 0

🧹 Nitpick comments (2)
benches/benchmarks/json_loads.py (2)

3-4: Consider specifying explicit UTF-8 encoding.

JSON files are UTF-8 by specification. Without an explicit encoding parameter, Python uses the system's default encoding, which may differ on some platforms.

Suggested improvement
-with open('benches/_data/pypi_org__simple__psutil.json') as f:
+with open('benches/_data/pypi_org__simple__psutil.json', encoding='utf-8') as f:
     data = f.read()

5-7: Remove extra blank line.

PEP 8 recommends a single blank line between logical sections within a module. There are two consecutive blank lines here.

Suggested fix
 with open('benches/_data/pypi_org__simple__psutil.json') as f:
     data = f.read()

-
 loaded = json.loads(data)
📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb57724 and 08ecffc.

📒 Files selected for processing (2)
  • benches/_data/pypi_org__simple__psutil.json
  • benches/benchmarks/json_loads.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.py: In most cases, Python code should not be edited; bug fixes should be made through Rust code modifications only
Follow PEP 8 style for custom Python code
Use ruff for linting Python code

Files:

  • benches/benchmarks/json_loads.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Run rust tests (windows-2025)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests (windows-2025)
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Ensure compilation on various targets
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Check Rust code with clippy
  • GitHub Check: Run snippets and cpython tests on wasm-wasi

@fanninpm
Copy link
Contributor

I hope it becomes trackable at https://rustpython.github.io/benchmarks.

Unfortunately the benches action is currently broken because the microbenchmarks job fails. Therefore, it won't get uploaded to the website until the microbenchmarks job gets fixed. Fixing the microbenchmarks job, however, is likely beyond the scope of this PR.

@moreal
Copy link
Contributor Author

moreal commented Jan 14, 2026

Unfortunately the benches action is currently broken because the microbenchmarks job fails. Therefore, it won't get uploaded to the website until the microbenchmarks job gets fixed. Fixing the microbenchmarks job, however, is likely beyond the scope of this PR.

I'm fixing the benchmark job in cron-ci workflow in #6724

(Although you've already seen the PR and added revisions, I'm leaving a comment on this PR to preserve context. 😅)

@youknowone youknowone merged commit 2e5257d into RustPython:main Jan 14, 2026
11 of 13 checks passed
terryluan12 pushed a commit to terryluan12/RustPython that referenced this pull request Jan 15, 2026
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.

3 participants