How many worker threads do you have? Context.enter() isn't an expensive operation assuming you have the context set up already for each thread. I've executed upwards of 10,000 Context.enter/exit() operations a second (including executing a small amount of JS and resuming+suspending the JS execution) on a single processor (numbers are off the top of my head it was a while ago that I profiled it, but in any case it was a large number). If it's really a big problem for you (perhaps your threads are being destroyed rather than recycled??), you might consider setting up a smaller Work Queue (an executor service) of threads that process javascript and submitting requests to process javascript to that smaller set of threads.
If this is a conceptual concern I suggest profiling the scenario to find out what really happens in your situation. Dave -----Original Message----- From: dev-tech-js-engine-rhino-bounces+davidparks21=yahoo....@lists.mozilla.org [mailto:dev-tech-js-engine-rhino-bounces+davidparks21=yahoo....@lists.mozill a.org] On Behalf Of DVD Sent: Sunday, August 30, 2009 12:51 AM To: [email protected] Subject: Use Rhino in HTTPServlet, poor performance Hello: I intend to use Rhino in my HTTPServlet methods to execute a javascript everytime user request a url. But according to doc, for every method call, I have to first use Context.enter()/Scrope/ before eval the same static script again and again. This is to meet the requirement that Context must be created for each thread and due to servlet model, this incurs huge overhead for performance, particularly when many users hits the url at the same time. Is there a way to have a precompiled form of the Javascript file created only once and used for multple thread? The script file itself can be assumed static and no need for implementing dynamic reload, which would make it easier. Thanks very much _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
