-
Notifications
You must be signed in to change notification settings - Fork 304
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 updateConfiguration function to jsg Isolates #3065
base: main
Are you sure you want to change the base?
Conversation
a86082d
to
3a697f2
Compare
This can be used to update the given configuration at runtime. Note that while some jsg structs are lazily using the configuration, others can use it at construction and will have the original configuration value.
3a697f2
to
23172a2
Compare
ping @jasnell or anyone else who feels like reviewing this 😄 |
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.
LGTM but I'd like @kentonv to sign off as well in case there's some edge case I'm not thinking of.
@kentonv you've been pretty involved in the design phase but I don't think you've seen the PRs so far. |
(Sorry for delay, it turns out my mail filters weren't properly labeling threads were I was mentioned.) Oof, this approach seems quite precarious. I take it the zygote really does depend on using ServiceWorkerGlobalScope as the context type? It can't run in a more generic isolate? I believe that skipping memoization will break type checking. That is, if an API function takes Did you try the approach of creating a separate TypeWrapper instance for the zygote? That seems less hacky especially if it means you can defer creation of the final TypeWraper until you know the config, and thus never need to swap out the config on an existing object... |
We could create another context type, but it would either mean a lot of code duplication (which can be prettified with template params but that's also ugly) or it wouldn't help with memoization. I haven't tried using a separate TypeWrapper, it seemed to me like there's a lot more room for error in that approach. A lot of the methods of Of course I could be missing an easier avenue to make this work that you're seeing and I'd love to hear more. What I'm really trying to do here is use as much of jsg as possible and enjoy as much of our existing APIs while not refactoring massive core parts of our codebase that might have side effects for regular isolates. What in your opinion and experience is the best approach here? is there an alternate solution that's clear to you that I have not pointed out? |
I haven't spent time investigating solutions so I only have ideas, don't know what will actually pan out. But not memoizing seems too fragile and inefficient to me. In addition to the type checks failing, you will be constructing new templates for every instance of a type, rather than once per type. Seems like that could cause a lot of unexpected inefficiency if you have, like, a loop calling some API that returns objects somewhere. To restore memoization, it seems like you need one of: |
Converting back to draft until I've got a better solution. |
This can be used to update the given configuration at runtime.
Note that while some jsg structs are lazily using the configuration, others can use it at construction and will have the original configuration value.
This is another step towards Python Isolate Pools and is coming in direct continuation to #2999.
This is another part split from workerd #2936 and internal #9006 for reviewability.