Skip to content

feat(perf): add microbenchmark suite for cat_ranges - #1035

Open
yuxin00j wants to merge 11 commits into
fsspec:mainfrom
yuxin00j:microbenchmark-cat-ranges
Open

feat(perf): add microbenchmark suite for cat_ranges#1035
yuxin00j wants to merge 11 commits into
fsspec:mainfrom
yuxin00j:microbenchmark-cat-ranges

Conversation

@yuxin00j

@yuxin00j yuxin00j commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Overview

This PR adds a comprehensive microbenchmark suite for cat_ranges under gcsfs/tests/perf/microbenchmarks/cat_ranges. It benchmarks multi-range read throughput and latency across Regional, Zonal (Rapid), and Hierarchical Namespace (HNS) buckets under various access patterns and parameter combinations.

Summary of Changes

  1. Benchmark Suite (gcsfs/tests/perf/microbenchmarks/cat_ranges/):

    • parameters.py: Defines CatRangesBenchmarkParameters capturing range counts, range selection patterns, chunk sizes, max_gap, and batch_size.
    • configs.py: Implements CatRangesConfigurator to generate test matrices from YAML configurations.
    • configs.yaml: Defines baseline scenarios covering:
      • cat_ranges_seq: Sequential adjacent ranges across a file.
      • cat_ranges_rand: Uniform random ranges across a file.
      • cat_ranges_mixed_sizes: Variable chunk sizes (64 KB, 1 MB, 4 MB, 16 MB) within the same call.
      • cat_ranges_multi_file: Multi-file range requests distributed round-robin across 5 files.
      • cat_ranges_batch_size_sweep: Concurrency sweep evaluating batch sizes 16, 64, and 128.
      • cat_ranges_large_file_large_ranges: Scale scenario requesting 1,000 mixed ranges across a 10 GB file with batch size 64.
    • test_cat_ranges.py: Implements test_cat_ranges_single_threaded benchmark runner using pytest-benchmark and pre-generated range offsets to avoid measuring setup overhead.
  2. Fixtures and Metrics Reporting (gcsfs/tests/perf/microbenchmarks/conftest.py):

    • Added gcsfs_benchmark_cat_ranges fixture to manage lifecycle of temporary test files across bucket types.
    • Enhanced publish_benchmark_extra_info to record num_ranges, max_gap, and batch_size in the benchmark report and output CSVs.
  3. Test Framework Registration (gcsfs/tests/conftest.py):

    • Registered cat_ranges in benchmark_subdirs to ensure test collection when passing --run-benchmarks.
  4. Unit Test Coverage (gcsfs/tests/perf/microbenchmarks/test_configs.py):

    • Added test_cat_ranges_configurator unit test.
    • Registered get_cat_ranges_benchmark_cases() in test_validate_actual_yaml_configs to validate YAML integrity in CI.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces a new microbenchmark suite for the cat_ranges operation in gcsfs, including configuration setups, benchmark parameters, and single-threaded test cases. The review feedback highlights several critical improvement opportunities: correcting the sequential range generation logic to prevent backward jumps, adding validation to ensure range sizes do not exceed file sizes, and robustly handling potentially empty or null configuration values for chunk sizes, batch sizes, and maximum gaps to avoid runtime errors.

Comment thread gcsfs/tests/perf/microbenchmarks/cat_ranges/test_cat_ranges.py
Comment thread gcsfs/tests/perf/microbenchmarks/cat_ranges/configs.py
Comment thread gcsfs/tests/perf/microbenchmarks/cat_ranges/configs.py Outdated
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.08%. Comparing base (8a3d3f5) to head (78c3c36).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1035      +/-   ##
==========================================
- Coverage   90.10%   90.08%   -0.02%     
==========================================
  Files          16       16              
  Lines        3679     3683       +4     
==========================================
+ Hits         3315     3318       +3     
- Misses        364      365       +1     

☔ View full report in Codecov by Harness.
📢 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.

@yuxin00j
yuxin00j force-pushed the microbenchmark-cat-ranges branch from 69b76f3 to b6756d6 Compare September 2, 2026 06:23

@Yonghui-Lee Yonghui-Lee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Throughput calculation in run.py is wrong for cat_ranges. For cat_ranges, the actual data transferred is not file_size * files.

Comment thread gcsfs/tests/perf/microbenchmarks/cat_ranges/test_cat_ranges.py
Comment thread gcsfs/tests/perf/microbenchmarks/cat_ranges/test_cat_ranges.py
Comment thread gcsfs/tests/perf/microbenchmarks/cat_ranges/parameters.py Outdated
…rn, and error raising

- Track sequential offsets per file in _generate_ranges to ensure each file experiences contiguous sequential reads when files > 1.
- Wrap around to offset 0 instead of terminating early when offset exceeds max_offset, ensuring exactly num_ranges are generated.
- Add support for pattern="mixed" in _generate_ranges with valid bounds.
- Pass on_error="raise" and inspect return elements in _cat_ranges_op so errors fail fast rather than silently recording misleading latencies.
- Clean up outdated cat_ranges documentation and examples in README files.
- Update and add comprehensive unit tests in test_configs.py.
- Remove mixed pattern from CatRangesBenchmarkParameters docstring in parameters.py.
- Remove mixed pattern handling from _generate_ranges in test_cat_ranges.py.
- Update test_configs.py to test supported patterns (seq, rand) and verify mixed raises ValueError.
@yuxin00j

yuxin00j commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

Throughput calculation in run.py is wrong for cat_ranges. For cat_ranges, the actual data transferred is not file_size * files.

Done. Updated the throughput calculation logic to use total_bytes.

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.

2 participants