Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack usage #215

Closed
stepantubanov opened this issue Feb 7, 2024 · 2 comments
Closed

Stack usage #215

stepantubanov opened this issue Feb 7, 2024 · 2 comments

Comments

@stepantubanov
Copy link
Contributor

stepantubanov commented Feb 7, 2024

Hi,

Probably a minor issue, but I've noticed some functions in fred have pretty big stack frames, which sometimes leads to stack overflow in our tests.

For example, when using fred 8.0.1 compiled with these features ["custom-reconnect-errors", "dns", "serde-json", "metrics", "enable-rustls", "partial-tracing", "sha-1", "serde-json"] fn fred::router::commands::process_command takes up ~400 KB of stack space in debug build (~100 KB in release build). There are more functions in the ballpark of 100KB-200KB.

Just wondering if there is some low hanging fruit there to be able to reduce stack usage. It's most likely due to large argument/return types (and Future return types can get large pretty fast due to rust-lang/rust#59087).

Clippy can help keep sizes in check with lints like clippy::large_types_passed_by_value, clippy::large_stack_frames, clippy::large_futures.

@aembke
Copy link
Owner

aembke commented Feb 12, 2024

Yikes, that's a really punishing issue for this library due to how many async functions are nested and reused across the various server deployment models.

Thanks for the background though. I'll explore some manual Box::pin tricks to try to work around this in the meantime.

@aembke aembke mentioned this issue Feb 15, 2024
@aembke
Copy link
Owner

aembke commented Feb 20, 2024

Should be addressed in /~https://github.com/aembke/fred.rs/releases/tag/v8.0.3

@aembke aembke closed this as completed Feb 20, 2024
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

No branches or pull requests

2 participants