Skip to content

feat(stresstest): Configure file sizes as a histogram of size buckets - #823

Closed
lcian wants to merge 3 commits into
mainfrom
lcian/feat/stresstest-size-buckets
Closed

lcian wants to merge 3 commits into
mainfrom
lcian/feat/stresstest-size-buckets

Conversation

@lcian

@lcian lcian commented Nov 24, 2026

Copy link
Copy Markdown
Member

The stresstest fits a lognormal distribution to a p50 and a p99, so it guesses all sizes above p99 and sends up to 3.3x the bytes per request of the production usecase it imitates. A workload can now take its file sizes from a histogram of size buckets pulled from the objectstore.put.size metric, which replays the measured distribution.

file_sizes:
  buckets:          # objects at or below each size, cumulative
    1 KiB: 2500
    2 KiB: 6000
    4 KiB: 9900
    8 KiB: 10000

Each bucket is twice the size of the previous one. Buckets that are 4x wide were not accurate enough: the average was up to 1.38x off. The README explains the syntax and how to pull the counts from Datadog, and config/production.example.yaml has one workload per production usecase. The counts in that file are rounded, so they are close to production but are not the real data. The rounding moves the average by less than 1%.

Accuracy

Each cell is the generated value divided by the production value, for one week of US production. 1.00x is an exact match.

Size buckets. Four million sizes per usecase, drawn from the new sampler with the buckets that Datadog returned.

Usecase Average p50 p90 p99 p99.9
attachments 0.90x 1.01x 0.99x 1.00x 1.14x
debug_files 1.03x 0.98x 0.91x 0.99x 1.06x
preprod 1.03x 1.02x 0.96x 1.05x 1.52x
preprod_size 1.05x 1.04x 1.04x 1.02x 1.83x
preprod_snapshots 1.08x 1.14x 0.99x 0.82x 1.15x
profile_attachments 1.04x 0.95x 1.07x 1.54x 1.42x

Lognormal (current). Fitted to the real p50 and p99 of each usecase, and computed from the fitted distribution. The p50 and p99 match by construction.

Usecase Average p50 p90 p99 p99.9
attachments 0.64x 1.00x 0.72x 1.00x 0.57x
debug_files 1.43x 1.00x 0.62x 1.00x 1.60x
preprod 1.03x 1.00x 0.70x 1.00x 2.77x
preprod_size 0.77x 1.00x 0.66x 1.00x 2.36x
preprod_snapshots 3.31x 1.00x 0.66x 1.00x 4.01x
profile_attachments 1.12x 1.00x 0.89x 1.00x 1.08x

With buckets, the high percentiles of the small usecases can be up to 2x off, because their largest objects are all in the lower part of the last bucket and the sampler spreads them across the full bucket. This has almost no effect on the average.

Add a second form of file_sizes: buckets of sizes with the cumulative count
of objects at or below each size. A size is drawn by picking a bucket in
proportion to the objects it adds, then log-uniformly within the bucket. The
lognormal form with p50 and p99 keeps working unchanged.

The lognormal fit guesses everything above p99, which put the average object
size at 0.64x to 3.3x of production depending on the usecase. Buckets at
every power of two, taken from the objectstore.put.size metric, bring the
average within about 10% for all production usecases.

Add production.example.yaml with one workload per production usecase, with
rounded counts that are close to production, and document in the README how
to pull the buckets from Datadog.
@github-actions

Copy link
Copy Markdown

Semver Impact of This PR

⚪ None (no workspace changed)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR does not change any workspace, so it will not appear in any changelog.


🤖 This preview updates automatically when you update the PR.

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.06452% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.80%. Comparing base (4724de3) to head (348849b).

Files with missing lines Patch % Lines
stresstest/src/main.rs 0.00% 14 Missing ⚠️
stresstest/src/config.rs 80.55% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #823      +/-   ##
==========================================
+ Coverage   91.72%   91.80%   +0.08%     
==========================================
  Files         122      122              
  Lines       24679    24783     +104     
==========================================
+ Hits        22637    22753     +116     
+ Misses       2042     2030      -12     
Components Coverage Δ
Rust Backend 94.12% <ø> (ø)
Rust Client 90.69% <ø> (ø)
Python Client 91.75% <ø> (ø)

☔ 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.

Comment thread stresstest/src/main.rs
Comment on lines 83 to 104
w.validate()?;

let workload = Workload::builder(w.name)
let sizes = w.file_sizes;
let mut workload = Workload::builder(&w.name)
.concurrency(w.concurrency)
.organizations(w.organizations)
.mode(w.mode)
.size_distribution(w.file_sizes.p50.0, w.file_sizes.p99.0)
.min_size(w.file_sizes.min.map_or(0, |b| b.0))
.max_size(w.file_sizes.max.map(|b| b.0))
.action_weights(w.actions.writes, w.actions.reads, w.actions.deletes)
.build();

stresstest = stresstest.workload(workload);
.min_size(sizes.min.map_or(0, |b| b.0))
.max_size(sizes.max.map(|b| b.0))
.action_weights(w.actions.writes, w.actions.reads, w.actions.deletes);

if let (Some(p50), Some(p99)) = (sizes.p50, sizes.p99) {
workload = workload.size_distribution(p50.0, p99.0);
}
if let Some(buckets) = sizes.buckets {
let buckets = SizeBuckets::new(buckets)
.with_context(|| format!("workload '{}': invalid file size buckets", w.name))?;
workload = workload.size_buckets(buckets);
}

stresstest = stresstest.workload(workload.build());
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Invalid p50/p99 pairs pass validate then panic in build()

validate() only checks p50 <= p99 when min is also set, and allows p50 == p99, but Workload::build() always does LogNormal::new(...).unwrap() which requires p99 > p50. A percentile-only config with p99 < p50, or any config with p50 == p99 (e.g. fixed-size objects), passes validation and panics at startup. Fix the ordering check in config.rs to run whenever both percentiles are present and require p99 > p50.

Evidence
  • config.rs validate only enters the min < p50 <= p99 check inside if let (Some(min), Some(p50), Some(p99)), so with min omitted a config like p50: 100 KiB, p99: 50 KiB is accepted.
  • That same check uses p99 < p50, so p50 == p99 is accepted even when min is set, matching the error text p50 <= p99.
  • main.rs then calls size_distribution(p50.0, p99.0) and workload.build().
  • WorkloadBuilder::build computes sigma = (p99.ln() - p50.ln()) / 2.3263 and LogNormal::new(mu, sigma).unwrap(); sigma <= 0.0 returns Err and unwrap panics.

Identified by Warden · code-review · 8GY-GL6

A workload built with size buckets still fitted the lognormal distribution
from the percentile settings, so settings that buckets replace could make
build() panic. The workload now holds one distribution or the other.

Percentiles were only checked when min was set, so a p99 below p50 gave a
wrong distribution and a p50 of zero panicked. They are now always checked.

The Datadog script in the README now reports a scope without data and
objects above the largest bucket. The README section is shorter, and its
field tables cover both forms of file_sizes.
The check of p50 and p99 without min is not related to size buckets, so
this keeps the validation that main has.
@lcian lcian closed this Nov 24, 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.

1 participant