11
31
Fork
You've already forked silverfish
19

Investigate recent performance degradation #129

Open
opened 2025年10月19日 18:25:26 +02:00 by zkat · 15 comments
Owner
Copy link

Sometime in the past couple of months, we went from processing literally 1m reqs/s to barely managing 9k reqs/s on my machine. This is almost certainly database access related but we might just be doing too much access, or we could be caching certain things.

We need to investigate what happened and fix it. Current performance levels are unacceptable.

Sometime in the past couple of months, we went from processing literally 1m reqs/s to barely managing 9k reqs/s on my machine. This is almost certainly database access related but we might just be doing _too much_ access, or we could be caching certain things. We need to investigate what happened and fix it. Current performance levels are unacceptable.
Author
Owner
Copy link

A clue: Someone on mastodon pointed me to https://htmlpreview.github.io/?https://github.com/diesel-rs/metrics/blob/results/plots/table_bench_trivial_query_sqlite.html, and that might mean we need to choose something other than sqlx for most of our sqlite-related stuff (I still think it's nice to use it for migrations!).

A clue: Someone on mastodon pointed me to https://htmlpreview.github.io/?https://github.com/diesel-rs/metrics/blob/results/plots/table_bench_trivial_query_sqlite.html, and that might mean we need to choose something other than sqlx for most of our sqlite-related stuff (I still think it's nice to use it for migrations!).

I'm gonna be taking a look at this to see if there's easy issues to resolve.

I'm gonna be taking a look at this to see if there's easy issues to resolve.
Author
Owner
Copy link

@pyrox one thing I just noticed, since I have my logs enabled now, is that we're creating and setting session cookies unconditionally, even if someone is logged out. This is... wildly unnecessary.

@pyrox one thing I just noticed, since I have my logs enabled now, is that we're creating and setting session cookies unconditionally, even if someone is logged out. This is... wildly unnecessary.
Author
Owner
Copy link

also: https://docs.rs/tower-sessions/latest/tower_sessions/#layered-caching might be beneficial, alongside not creating those sessions at all for open pages.

We should perhaps use moka in general for various things??

also: https://docs.rs/tower-sessions/latest/tower_sessions/#layered-caching might be beneficial, alongside not creating those sessions at all for open pages. We should perhaps use moka in general for various things??

Tried adding a cache to the sessions store with the layered cache provided by tower_sessions.

Before: screenshot-19_14-58-01

After: screenshot-19_15-18-24

Turns out, this cache actually decreases performance, using the plow load testing tool. Therefore, at this moment, I don't believe this is useful. However, I am using purely unauthenticated requests, so maybe it's better with authenticated requests.

Tried adding a cache to the sessions store with the layered cache provided by tower_sessions. Before: ![screenshot-19_14-58-01](/attachments/29a91e57-43b8-4ab8-bce2-8ec721e944b8) After: ![screenshot-19_15-18-24](/attachments/1740b98a-7f1b-439b-9951-f87ea8e53ab9) Turns out, this cache actually decreases performance, using the `plow` load testing tool. Therefore, at this moment, I don't believe this is useful. However, I am using purely unauthenticated requests, so maybe it's better with authenticated requests.
Author
Owner
Copy link

idea that we might spin up a separate issue for: "precompress Pages into brotli/gzip", so we have them pre-saved in the database in their compressed formats, and serve those directly. We compress them whenever data gets saved.

idea that we might spin up a separate issue for: "precompress Pages into brotli/gzip", so we have them pre-saved in the database in their compressed formats, and serve _those_ directly. We compress them whenever data gets saved.
Author
Owner
Copy link

this whole thing is cursed

this whole thing is cursed
Contributor
Copy link

I'm thinking doing regular benchmarks might be helpful, maybe automated on PR to monitor performance changes if possible.
Additionally we should be able to check out past revisions and see how performance has shifted over time

I'm thinking doing regular benchmarks might be helpful, maybe automated on PR to monitor performance changes if possible. Additionally we should be able to check out past revisions and see how performance has shifted over time
Author
Owner
Copy link

I don't think it's prudent to put our CI machine under load. It's not like one of the random "free resources" machines you get out of GitHub

I don't think it's prudent to put our CI machine under load. It's not like one of the random "free resources" machines you get out of GitHub
Contributor
Copy link

What about weekly benchmarking on CI? so we have a range to bisect for regressions? And maybe add a perf-sensitive label that triggers CI benchmarks?

I could do that, I have some experience with those kinds of setups

What about weekly benchmarking on CI? so we have a range to bisect for regressions? And maybe add a `perf-sensitive` label that triggers CI benchmarks? I could do that, I have some experience with those kinds of setups
Author
Owner
Copy link

I wonder what @conjured/seeing-eye thinks about this. I'm just kinda like hm about putting that machine under too much load.

I wonder what @conjured/seeing-eye thinks about this. I'm just kinda like hm about putting that machine under too much load.
Contributor
Copy link

Maybe we could do it without CI, we'd just have to remember to actually do it.

Maybe we could do it without CI, we'd just have to remember to actually do it.
Author
Owner
Copy link

My latest notes on this is that we're creating session cookies for any and all visitors, even when they're not logged in or trying to log in. People should be able to browse the site without a session cookie getting created. Just gotta fix the middleware.

My latest notes on this is that we're creating session cookies for any and all visitors, even when they're not logged in or trying to log in. People should be able to browse the site without a session cookie getting created. Just gotta fix the middleware.
Author
Owner
Copy link

I'm gonna investigate this

I'm gonna investigate this
Author
Owner
Copy link

https://github.com/maxcountryman/axum-login/discussions/307#discussioncomment-15324144 this seems to be a way to make it possible to have our context-middleware conditionally do AuthSession extraction

https://github.com/maxcountryman/axum-login/discussions/307#discussioncomment-15324144 this seems to be a way to make it possible to have our context-middleware conditionally do AuthSession extraction
Sign in to join this conversation.
No Branch/Tag specified
main
zkat/products
150_musl_build
zkat/scaffolder
v0.0.1
Labels
Clear labels
Compat
Breaking
Breaking change that won't be backward compatible
Flag/Good First Issue
Good issue for first-time contributors
Kind/Accessibility
Accessibility issue, bug or otherwise
Kind/Appearance
Design, styling, and other aesthetic and visual items
Kind/Bug
Something is not working
Kind/Compliance
Legal, policy, or some other kind of compliance
Kind/DevOps
CI/CD, releases, etc
Kind/Documentation
Documentation changes
Kind/Enhancement
Improve existing functionality
Kind/Feature
New functionality
Kind/Performance
Gotta go fast
Kind/Security
This is security issue
Kind/Technical Improvement
Underlying technical improvement that is not necessarily user-impacting or visible.
Kind/Testing
Issue or pull request related to testing
Kind/UX
Related to user experience/product
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Size
L
Significant change
Size
M
Medium-size change
Size
S
Small change
Size
XL
Very large change that might take months to complete and impact many components
Size
XS
Trivially small change
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
Status
Needs Design
Requires design/review from Alchemists (product/UX)
Status
Needs Discussion
A discussion needs to happen before implementation
Milestone
Clear milestone
No items
Projects
Clear projects
No items
Assignees
Clear assignees
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
conjured/silverfish#129
Reference in a new issue
conjured/silverfish
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?