This project has moved. For the latest updates, please go here.

Is the following thread concerning Server-Side execution still accurate?

Dec 11, 2014 at 1:18 AM
Hey guys, there was a thread that I had based some work off of, but there was some indication that some optimizations may be made in ClearScript to better help deal with some of these issues. Has anything changed in regards to this thread? (Is was over a year ago)

https://clearscript.codeplex.com/discussions/467415
Coordinator
Dec 11, 2014 at 12:54 PM
Hi Eric,

ClearScript and V8 have not changed in terms of their basic architectures. However, ClearScript 5.4 includes a number of important changes for server-side usage, including fixes for memory leaks, more deterministic disposal of V8 resources, and performance improvements for repeated script execution.

Thanks!
Dec 11, 2014 at 6:57 PM
Cool, thanks for the fast responses. Can you elaborate any on "perfomance improvements for repeated execution"? I did read the release notes and I get the gist, but the details are somewhat cryptic to me. I've been taking the approach of having a pool of runtimes and creating engines when needed via CreateScriptEngine from the runtime. I also compile and cache the scripts per runtime for reuse. Would that still be a recommended approach for a server-side implementation? Is there anything new that might help perf/scalability?

Thanks,
Eric
Coordinator
Dec 12, 2014 at 2:09 AM
Edited Dec 12, 2014 at 2:10 AM
Hi Eric,

Can you elaborate any on "perfomance improvements for repeated execution"?

Sure. The biggest performance improvement for V8 users affects repeated invocation of host methods.

Let's say you've exposed the Console type and are running a script that repeatedly calls Console.WriteLine(). Because methods in JavaScript are just function-valued properties, each call consists of two steps - fetching the "WriteLine" property and invoking the result.

Previously this required two expensive round trips across the native-managed boundary, but now host methods are cached as native JavaScript properties, so after the initial call, subsequent calls require only one round trip.

This caching mechanism is also used to speed up repeated access to host events and const/readonly fields (most significantly enum tokens).
​​
I've been taking the approach of having a pool of runtimes and creating engines when needed via CreateScriptEngine from the runtime. I also compile and cache the scripts per runtime for reuse. Would that still be a recommended approach for a server-side implementation?

Yes, that's the best general-purpose design for concurrent script execution via V8.

Cheers!
Marked as answer by ericswann on 12/12/2014 at 6:19 AM
Dec 12, 2014 at 1:19 PM
Nice thanks for the info!