Taritsyn / JavaScriptEngineSwitcher

JavaScript Engine Switcher determines unified interface for access to the basic features of popular JavaScript engines. This library allows you to quickly and easily switch to using of another JavaScript engine.
Apache License 2.0
446 stars 49 forks source link

Switch Jint support to use version 3 previews #75

Closed lahma closed 5 years ago

lahma commented 5 years ago

Could you consider a PR which would change the used Jint version to 3 preview build? Version 3 has:

There would be one obvious breaking change though. The oldest supported .NET full framework version is 4.5, and might even change to something like 4.6.1 later on. But the general guidance seems to be to support .NET 4.6.1 and .NET Standard 2.0, older versions are at the end of the road.

Taritsyn commented 5 years ago

Hello, Marko!

I added support of the Jint version 3.0.0 Beta 1598 in the JavaScriptEngineSwitcher.Jint module (9c144b2).

At the moment, unit tests defined in the PrecompilationTestsBase class are failing (error is unstable and is associated with multithreading). I may have to store the instance of the Esprima.Ast.Program class in serialized form.

lahma commented 5 years ago

Great news, thank you for following up so quickly! Engine indeed is not thread-safe and should not be shared between threads. If you have time at some point to run benchmarks, I'd love to hear about possible performance improvements 🙂

Taritsyn commented 5 years ago

Hello, Marko!

To make release and real benchmarks I need a new version of the Jint package that will include fixes for error #667.

lahma commented 5 years ago

Thanks, pinging @sebastienros for a new release

sebastienros commented 5 years ago

https://www.nuget.org/packages/Jint/3.0.0-beta-1612

Taritsyn commented 5 years ago

Thanks! Tomorrow I will make release.

In the meantime, here are the results of the JsExecutionBenchmark benchmark:

.NET Framework 4.6.1

Jint v2.11.58

| Method | withPrecompilation |     Mean |     Error |    StdDev |     Gen 0 |     Gen 1 |   Gen 2 | Allocated |
|------- |------------------- |---------:|----------:|----------:|----------:|----------:|--------:|----------:|
|   Jint |              False | 24.12 ms | 0.1001 ms | 0.0836 ms | 2781.2500 | 1375.0000 |       - |  16.04 MB |
|   Jint |               True | 14.98 ms | 0.2813 ms | 0.3557 ms | 1281.2500 |  609.3750 | 93.7500 |   7.37 MB |

Jint v3.0.0 Beta 1612

| Method | withPrecompilation |      Mean |     Error |    StdDev |     Gen 0 | Gen 1 | Gen 2 | Allocated |
|------- |------------------- |----------:|----------:|----------:|----------:|------:|------:|----------:|
|   Jint |              False | 12.698 ms | 0.1049 ms | 0.0930 ms | 1000.0000 |     - |     - |   7.31 MB |
|   Jint |               True |  4.917 ms | 0.0915 ms | 0.0940 ms |         - |     - |     - |   2.63 MB |

.NET Core App 2.0

Jint v2.11.58

| Method | withPrecompilation |     Mean |     Error |    StdDev |     Gen 0 |     Gen 1 |   Gen 2 | Allocated |
|------- |------------------- |---------:|----------:|----------:|----------:|----------:|--------:|----------:|
|   Jint |              False | 24.01 ms | 0.3713 ms | 0.3291 ms | 2750.0000 | 1375.0000 |       - |  15.92 MB |
|   Jint |               True | 14.53 ms | 0.2710 ms | 0.2661 ms | 1265.6250 |  593.7500 | 62.5000 |   7.27 MB |

Jint v3.0.0 Beta 1612

| Method | withPrecompilation |      Mean |     Error |    StdDev |     Gen 0 | Gen 1 | Gen 2 | Allocated |
|------- |------------------- |----------:|----------:|----------:|----------:|------:|------:|----------:|
|   Jint |              False | 12.842 ms | 0.1123 ms | 0.0995 ms | 1000.0000 |     - |     - |   7.27 MB |
|   Jint |               True |  5.062 ms | 0.1173 ms | 0.1441 ms |         - |     - |     - |   2.61 MB |
lahma commented 5 years ago

I like these numbers 🥳

sebastienros commented 5 years ago

Good job Marko, and thanks Andrey.

lahma commented 5 years ago

Thank you @Taritsyn for upgrading, I hope the new version is a worthwhile upgrade.