Migrate Benchmark#731
Open
faridyagubbayli wants to merge 4 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #731 +/- ##
==========================================
+ Coverage 75.57% 75.68% +0.10%
==========================================
Files 57 57
Lines 8195 8195
Branches 1600 1600
==========================================
+ Hits 6193 6202 +9
+ Misses 1381 1370 -11
- Partials 621 623 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Validate benchmark inputs and memory reporting so generated results stay complete and JSON-compatible.
Collaborator
Author
|
@greptile review |
Contributor
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates
benchmark.mscript with some additions.benchmarks/README.mdshows sample usage.Example output json file
Greptile Summary
This PR ports the MATLAB
benchmark.mscript to Python, implementing a 3D solver scaling benchmark that runskspaceFirstOrderacross a sequence of increasing grid sizes and records average runtimes. It also adds thePeakMemorySamplerpolling approach to replace the previously flaggedresource.getrusagepeak-RSS approach, and fixes the earlier case-identity andnan-in-JSON issues.benchmarks/helpers.py: IntroducesBenchmarkOptions(frozen dataclass), grid construction helpers, aPeakMemorySamplercontext manager that polls current RSS in a background thread, and cross-platform memory readers for Linux (/proc/self/statm), macOS/Linux-fallback (ps), and Windows (PSAPI via ctypes).benchmarks/benchmark.py: Implements therun()loop, per-average timing and memory averaging, partial-result persistence after every solver call, and amain()entry point with CLI argument parsing.tests/test_benchmark.py: Adds unit tests covering timing aggregation, case-index correctness,report_mem_usagepath, unsupported platform early failure, and partial-result preservation on solver error.Confidence Score: 5/5
The benchmark is new infrastructure with no impact on existing library code paths; it is safe to merge.
All changed files are new additions under benchmarks/ and tests/. The run loop, rolling averages, partial-result persistence, and cross-platform memory readers are all logically correct and well-tested. Previously identified issues (case-identity collision, nan-in-JSON, unsupported-platform early failure, start_size validation, and ru_maxrss misuse) have been fully addressed. No regressions to existing library code are possible since no existing files are modified.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[run] --> B{report_mem_usage?} B -- yes --> C[validate_memory_bytes early check] B -- no --> D[for each case_index / nx,ny,nz,scale] C --> D D --> E[build_case: kgrid, medium, source, sensor] E --> F[for loop_num in 1..num_averages] F --> G{report_mem_usage?} G -- yes --> H[PeakMemorySampler polls RSS in background thread] H --> I[solver] I --> H2[exit: final sample + thread join] H2 --> J[rolling_average mem_usage] G -- no --> I2[solver] I2 --> K[record elapsed_time] J --> K K --> L[rolling_average loop_time] L --> M[store_case_result by case_index] M --> N[save_results to JSON partial persistence] N --> F F -- all averages done --> D D -- all cases done OR exception --> O{error?} O -- yes --> P[set error_reached + save_results + break] O -- no --> Q[return result dict] P --> QReviews (4): Last reviewed commit: "Merge branch 'master' into migrate-bench..." | Re-trigger Greptile