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

Fix layers being cloned for each request #2586

Merged
merged 1 commit into from Mar 14, 2024
Merged

Conversation

davidpdrsn
Copy link
Member

@davidpdrsn davidpdrsn commented Feb 11, 2024

I would expect #2582 to work since we no longer clone the whole router for each request (#2483).

Turns out we were missing a .with_state(()) to eagerly apply layers like we used to do for .into_ make_service(). This might also have a performance impact.

edit(jplatte): Closes #2582.

@dayvejones
Copy link
Contributor

Hello! Will this PR allow the RateLimitLayer (Tower) to be used?

#2520

jplatte
jplatte previously approved these changes Mar 5, 2024
Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

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

This makes me think that there's a performance benefit to be had by having a separate RouterService again (where inner routes are known to not require state be cloned into them anymore).

@PacoDu PacoDu mentioned this pull request Mar 6, 2024
1 task
@jplatte jplatte dismissed their stale review March 14, 2024 20:22

Uncertain if this is actually an improvement

Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

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

Okay I was uncertain because of the comments in #2634 but actually David wrote that this fixes #2582 so assume it is tested. And even if it wasn't fixing anything, we have enough tests to tell that it doesn't break anything obvious.

@jplatte jplatte merged commit 19f6f79 into main Mar 14, 2024
18 checks passed
@jplatte jplatte deleted the david/fix-cloning-layers branch March 14, 2024 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Example in MethodRouter::layer documentation doesn't work
3 participants