Skip to content

Stop deep-copying the config and spawning an idle task on every API request - #338

Merged
Shine-neko merged 3 commits into
mainfrom
perf/share-config-and-skip-idle-touch
Nov 28, 2026
Merged

Shine-neko merged 3 commits into
mainfrom
perf/share-config-and-skip-idle-touch

Conversation

@Shine-neko

Copy link
Copy Markdown
Contributor

axum clones the state for every extractor and middleware of a request, and AppState held the whole Config by value: a profile of GET /deployments under load showed copying and dropping it (AppState::clone, Config::clone, its drop_glue, the String clones) at about 15% of the sampled CPU. The config is now an Arc<Config>; those frames fall below 0.5% in the same profile.

Token auth also spawned a task on every request to update last_used_at, which is throttled to one write per minute and so returned immediately almost every time. The throttle is now checked before spawning.

On GET /deployments with an empty database, alternating three runs of each build with bench/run.sh (#337): about 8.9k to 12.2k req/s with a session token, 9.0k to 11.9k with an API token, on an 8-core machine where runs of the same build vary by up to 10%.

@Shine-neko
Shine-neko merged commit 2bc17ea into main Nov 28, 2026
6 checks passed
@Shine-neko
Shine-neko deleted the perf/share-config-and-skip-idle-touch branch November 28, 2026 20:06
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