runtime creation overhead #459
Replies: 2 comments
-
Creating a Runtime is not cheap. Some effort has been made not to create every single builtin (see lazyObject), but I suspect in v8 it's taken to an even more extreme, all built-ins (including the global Object) are template-backed proxy objects and the properties are created from the templates the first time they are accessed. It's certainly doable but requires a significant amount of work and is not currently on the roadmap. And even if it's done it only makes the initial creation fast, the more builtins your code uses the more performance you will eventually lose. Add to that sourcing your own code. It depends on the size of course but if you have to create a lot of functions for instance, it's not going to be cheap either. If your code is known not to tamper with the global object and the builtins, it's always advisable to use a pool. Also, you can always benchmark it and decide for yourself. |
Beta Was this translation helpful? Give feedback.
-
I have learned that in v8, create a new context is very cheap.
How about goja.New(). Is it doable to create one runtime for one http request.
Beta Was this translation helpful? Give feedback.
All reactions