-
Notifications
You must be signed in to change notification settings - Fork 10
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
refactor(proxy-wasm) better instance/ctx lifecycle management #422
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thibaultcha
force-pushed
the
refactor/proxy-wasm
branch
from
September 29, 2023 01:42
ce24de9
to
ef7004e
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #422 +/- ##
===================================================
+ Coverage 90.11787% 90.18238% +0.06450%
===================================================
Files 46 46
Lines 8399 8444 +45
===================================================
+ Hits 7569 7615 +46
+ Misses 830 829 -1
|
thibaultcha
force-pushed
the
refactor/proxy-wasm
branch
14 times, most recently
from
October 5, 2023 05:04
22ac50f
to
69e8801
Compare
thibaultcha
added
pr/on-hold
PR: Do not merge/close
and removed
pr/work-in-progress
PR: Work in progress
labels
Oct 5, 2023
thibaultcha
force-pushed
the
refactor/proxy-wasm
branch
2 times, most recently
from
October 8, 2023 16:16
979dd72
to
752e100
Compare
thibaultcha
force-pushed
the
refactor/proxy-wasm
branch
from
October 23, 2023 18:29
752e100
to
9a14384
Compare
thibaultcha
force-pushed
the
refactor/proxy-wasm
branch
6 times, most recently
from
October 31, 2023 22:25
a944270
to
72960d7
Compare
thibaultcha
force-pushed
the
refactor/proxy-wasm
branch
6 times, most recently
from
November 6, 2023 18:11
54f7d26
to
ea6d6eb
Compare
thibaultcha
force-pushed
the
refactor/proxy-wasm
branch
from
November 8, 2023 01:40
ea6d6eb
to
72c9723
Compare
* Allow for recycling the root instance (which is not managed by isolation modes). * Allow for smoother recycling of http instances (including when the root instance has trapped, e.g. during on_tick). * Also recycle trapped instances in the busy queue. * Less verbose context creation of fresh and/or recycled instances starting in atypical steps (e.g. on_response_headers).
Prior, the sweeping queue was only destroyed at worker shutdown, but it was intended for it to be swept sooner. This removes the sweeping queue and frees instances on the spot instead.
thibaultcha
force-pushed
the
refactor/proxy-wasm
branch
2 times, most recently
from
November 8, 2023 02:07
31fe7cf
to
1f908bc
Compare
The main goal of this overhaul is to simplify `on_context_create`, make it fully re-entrant *and* properly handle instance recycling at the same time. The way to do so, in my opinion, was to move `pwexec` creation where `rexec` already was. In other words, always lookup the context id in the instance rbtree, and if not found, create it. This means that surrounding code also needed big overhauls. It also removes the reference counting poor man's GC of the older implementation. The code became really ugly by then so I took the time to also review this module's code structure instead of making a *very* ugly commit. This new ngx_proxy_wasm.c file should be much easier to read and follow now. One change I do not fully like is moving the `next_id` to a global counter, but we do not have a "global proxy-wasm conf" object yet. I also started thinking about pre-allocating a number of `pwexecs` (like `worker_connections`) and use free/busy queue that all filter chains can dip into to get a context id + context memory zone. Perhaps for a later time.
thibaultcha
force-pushed
the
refactor/proxy-wasm
branch
from
November 8, 2023 16:08
1f908bc
to
194d97d
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
on_tick
).on_response_headers
).on_context_create
supporting code and unifies it between root and http instances which now both use the same context creation code. This makes instance recycling much more robust in a number of tricky situations with low isolation modes.