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

[proxy] Migrate to async #1270

Merged
merged 2 commits into from
Feb 17, 2022
Merged

[proxy] Migrate to async #1270

merged 2 commits into from
Feb 17, 2022

Conversation

funbringer
Copy link
Contributor

@funbringer funbringer commented Feb 14, 2022

This makes most of the proxy async (except for mgmt, but we expect to drop it soon). The auth logic is left almost untouched, since this patch is big enough, and it would be good to merge it and unlock further changes.

@funbringer
Copy link
Contributor Author

I've just realized that I forgot about NUM_BYTES_PROXIED_COUNTER. While it's quite easy to restore this logic, I'm a bit hesitant, since the current approach means that all runtime threads will compete for atomic var's cacheline. I might be overthinking, because there's an awful lot more happening inside tokio's runtime. Thoughts?

@bojanserafimov
Copy link
Contributor

I've just realized that I forgot about NUM_BYTES_PROXIED_COUNTER. While it's quite easy to restore this logic, I'm a bit hesitant, since the current approach means that all runtime threads will compete for atomic var's cacheline. I might be overthinking, because there's an awful lot more happening inside tokio's runtime. Thoughts?

There is some cache contention but we only update when we flush, so I wouldn't expect visible performance impact. If there is any, we can just buffer the metric updates even more aggressively.

proxy/src/main.rs Outdated Show resolved Hide resolved
@funbringer funbringer force-pushed the funbringer-proxy-async branch 2 times, most recently from 1f08a46 to 9a7dc7d Compare February 14, 2022 20:19
@funbringer funbringer force-pushed the funbringer-proxy-async branch 2 times, most recently from 3d34e7c to 1b72066 Compare February 15, 2022 14:26
Copy link
Contributor

@LizardWizzard LizardWizzard left a comment

Choose a reason for hiding this comment

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

Nice! Great Work! Having this covered by unittests is a huge plus.

What do you think about hypothetical Proxy struct that can hold reqwest::Client for console interaction and a cancellation keys map? This way we can also avoid global variables. May also simplify some future tests that manipulate this state.

I've left just a few minor nitpicks

proxy/src/auth.rs Show resolved Hide resolved
proxy/src/cancellation.rs Outdated Show resolved Hide resolved
proxy/src/cplane_api.rs Show resolved Hide resolved
proxy/src/cplane_api.rs Show resolved Hide resolved
proxy/src/cplane_api.rs Show resolved Hide resolved
proxy/src/http.rs Show resolved Hide resolved
proxy/src/proxy.rs Show resolved Hide resolved
@funbringer
Copy link
Contributor Author

@LizardWizzard

What do you think about hypothetical Proxy struct that can hold reqwest::Client for console interaction and a cancellation keys map?

Could you elaborate? I don't see why they should live in a single map.

This way we can also avoid global variables.

How so? You never said anything about this map's lifetime. Besides, I've just re-introduced some private global maps exactly for the sake of simplicity.

May also simplify some future tests that manipulate this state.

Not necessarily.

@funbringer funbringer force-pushed the funbringer-proxy-async branch 2 times, most recently from 0700f32 to 770bd74 Compare February 16, 2022 11:59
This change makes most parts of the code asynchronous, except
for the `mgmt` subsystem (we're going to drop it anyway).

Co-authored-by: bojanserafimov <bojan.serafimov7@gmail.com>
This is a cleaner approach which might facilitate testing.
@funbringer funbringer merged commit a26d565 into main Feb 17, 2022
@funbringer funbringer deleted the funbringer-proxy-async branch February 17, 2022 08:54
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.

None yet

3 participants