Hi, I spent some time analyzing performance bottlenecks in v8cgi. A typical program flow in FastCGI/Apachemodule scenario is the following:
1) program & V8 initialization, 2) new request arrives, 3) new context is created, 4) default libraries (*.js files) are compiled and executed, 5) requested file (.js) is compiled and executed, 6) wait for new request, GOTO #2, 7) shutdown. According to valgrind, most problematic operation is #4. Every (http) request means compiling and executing of several javascript variables. In theory, there are two possible approaches to speed this up: A) Compile these files only once, execute them on each request; B) Do not create new context each time; save the initialized context and re-use it (this removes points #3 and #4 from all but first request). However, I am unable to successfully implement any of these points, because: A) It is _not_ possible to compile a script in context C1 and run it in other context C2 in V8. No errors are raised, but the compilation closely binds script to C1 and results in C2 are totally unpredictable. B) I don't know how to "freeze" or "clean" the context for re-using; user code (#5) can for instance do "Array.prototype.XXX = 3;" and I am not sure how to detect/revert this. Please, can you share your thoughts about how to solve these issues? Has anyone encountered the need to speed up script (re)compilation and/ or context reusing? Sincerely, Ondrej Zara --~--~---------~--~----~------------~-------~--~----~ v8-users mailing list [email protected] http://groups.google.com/group/v8-users -~----------~----~----~----~------~----~------~--~---
