Skip to content

test: add loadtest with normally distributed server delay - #319

Open
mkaruza wants to merge 4 commits into
masterfrom
mkaruza/loadtest-gaussian-delay
Open

mkaruza wants to merge 4 commits into
masterfrom
mkaruza/loadtest-gaussian-delay

Conversation

@mkaruza

@mkaruza mkaruza commented Oct 16, 2026

Copy link
Copy Markdown

Add a /delay?s= nginx endpoint, where can be fractional (e.g. /delay?s=0.087),
and let wait_for_many_gets() send each request there with a delay drawn from a normal distribution,
so the loadtest can simulate the latency of "normal" servers instead of an instant local reply:

net-loadtest 10000 200 100 30   # mean 100ms, stddev 30ms

The delay is generated by random_delay_ms() using the Box-Muller transform (written with AI assistance).

Also remove the unused /slow-reply and /really-slow-reply locations, superseded by /delay.

Add a /delay?s=<seconds> nginx endpoint, where <seconds> can be
fractional (e.g. /delay?s=0.087), and let wait_for_many_gets() send
each request there with a delay drawn from a normal distribution, so
the loadtest can simulate the latency of "normal" servers instead of an
instant local reply:

    net-loadtest 10000 200 100 30   # mean 100ms, stddev 30ms

The delay is generated by random_delay_ms() using the Box-Muller
transform (written with AI assistance).

Also remove the unused /slow-reply and /really-slow-reply locations,
superseded by /delay.
@mkaruza
mkaruza requested a review from a team as a code owner October 16, 2026 12:25
@steve-chavez

Copy link
Copy Markdown
Member

This looks interesting. @mkaruza Could you clarify what's the motivation here? Is it just for removing /slow-reply and /really-slow-reply?

@mkaruza

mkaruza commented Oct 16, 2026 •

Copy link
Copy Markdown
Author

This looks interesting. @mkaruza Could you clarify what's the motivation here? Is it just for removing /slow-reply and /really-slow-reply?

I was looking around why we have / how extension will behave if we remove 1 sec sleep after batch is processed. Wanted to run test that simulate "real" world scenario where i can simulate network delay. Other endpoints are removed because they are not used and they can be used with this one.

Comment thread nix/loadtest.nix
Comment thread test/utils/loadtest.sql
last_failure_error text
);

-- random delay in ms from a normal distribution with the given mean and standard deviation.

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.

idk about everyone else but I'm not a huge fan of putting performance testing scripts into CI before merge. I feel like CI should be only for hard failures: testing internal logic, thread safety issues, memory safety stuff, etc. Maybe I'm totally off base here but just wondering what everyone else thinks.

@mkaruza mkaruza Oct 17, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

PR doesn't enable or add load test that will run in CI with this feature. But I share same view that for CI performance/benchmark should not be running.

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.

Yeah I was not criticising this PR in particular, just using it as an opportunity to open discussion.

I do think performance testing is important and should be done, just not sure when/how. Maybe on every commit on merge so u can look at the exact commit a regression occurred? Idk

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

idk about everyone else but I'm not a huge fan of putting performance testing scripts into CI before merge

I'm not sure about this PR, but continuous benchmarking has been very helpful to ensure correctness. At some point we got random timeouts during big batches and CI detects those (request failures at 0) plus it shows that CPU usage should be low. The runs are pretty stable too (see CI results, all the batches are completed in < 1 min and that has been maintained)

It's yet incomplete though, it should fail when time_taken and CPU usage surpasses a threshold.

@steve-chavez steve-chavez Oct 20, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just checked the loadtest and there's a regression #321, this proves it's useful and should keep running on PRs IMO.

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.

A per-commit performance regression suite is indeed valuable. What we also need are graphs that show performance over time which is easier to spot visually than visit each commit's results as Steve did above. Also a little more sophisticated statistical analysis will help gauge the trends better as currently we only have raw numbers.

Ideally we run the benchmarks on non-GH runners to avoid noisy-neighbour problems. I ran the CI multiple times on the master branch and there is a noise of at least 2%, this run's max CPU was 13%, while this one was at 11%. I also suspect there's a regression but it becomes harder to compare these small changes on GH runners. Maybe have dedicated machines for benchmarking?

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.

The noise is worse than 2%. Another example of two runs on the same commit:

  • This run had the max CPU at around 7% with one outlier at 9%.
  • This run had the max CPU at around 12% with a couple of them on 13%.

This has a variation of 5% points in max CPU, which is not great to compare performance. Also we should be comparing the mean and standard deviation to meaningfully compare two runs, but with the current runs this is what we have.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I would suggest that we move CI discussion and tradeoffs to some other channel so we have clear picture what would be acceptable behavior.

Comment thread test/utils/loadtest.sql Outdated
Comment thread test/utils/loadtest.sql
@mkaruza
mkaruza requested a review from imor October 19, 2026 11:54

This branch has not been deployed

No deployments
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.

4 participants