-
Notifications
You must be signed in to change notification settings - Fork 273
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
Add a private part to the Context structure #2802
Conversation
This is a hashmap-like indexed by the type of the value inserted
This comment has been minimized.
This comment has been minimized.
apollo-router/src/context/mod.rs
Outdated
@@ -36,6 +40,9 @@ pub struct Context { | |||
// Allows adding custom entries to the context. | |||
entries: Entries, | |||
|
|||
#[serde(skip, default)] | |||
pub(crate) private_entries: Arc<std::sync::Mutex<Extensions>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you think a RwLock
could be interesting in that case ? I think we're mostly writing outside of subgraph_service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that could be, but there would not be much performance benefit, there will very rarely be concurrent accesses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High Level Comment: External CoProcessors received all the contents of the context, so moving things out of context will change that behaviour.
I think that's a good thing, but I'm just noting it here so that everyone understands this will happen.
yup, it's just that before, some internal details, that we did not meant as public API, were sent to the coprocessor. This will be stricter now |
There's a cost in using the `Context` structure throughout a request's lifecycle, due to the JSON serialization and deserialization, so it should be reserved from inter plugin communication between rhai, coprocessor and Rust. But for internal router usage, we can have a more efficient structure that avoids serialization costs, and does not expose data that should not be modified by plugins. That structure is based on a map indexed by type id, which means that if some part of the code can see that type, then it can access it in the map. This means that some context data that was accessible from rhai and all plugins, is now inaccessible
Batch of performance improvements: * linux: replace default allocator with jemalloc (#2882) * Add a private part to the Context structure (#2802) * lighter path manipulation in response formatting (#2854) * prevent span attributes from being formatted to write logs (#2890) * Parse Accept headers once instead of three times (#2847) * use a parking-lot mutex in Context (#2885) * Filter spans before sending them to the opentelemetry layer (#2894)
Fix #2800
Checklist
Complete the checklist (and note appropriate exceptions) before a final PR is raised.
Exceptions
Note any exceptions here
Notes
[^1]. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.
[^2]. Configuration is an important part of many changes. Where applicable please try to document configuration examples.
[^3]. Tick whichever testing boxes are applicable. If you are adding Manual Tests:
- please document the manual testing (extensively) in the Exceptions.
- please raise a separate issue to automate the test and label it (or ask for it to be labeled) as
manual test