You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our scenario we parallize validations with 20 Threads in a single JVM.
We recognized a big bottleneck in the JavaScriptEvaluator.getTestEvalResult-Method, since it is synchronized and only one thread at a time can evaluate its result.
I have tried to fix it locally by adjusting JavaScriptEvaluator to use ThreadLocals.
I got the following results:
Testscenario:
Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
20 parallel threads
100 validations per thread
Result before optimization:
537 seconds in total
268 milliseconds per validation
4 validations per second
Result after optimization:
114 seconds in total after optimization
57 milliseconds per validation after optimization
17 validations per second
Thus an validation speed improvement of 325% in the concurrent case with 20 threads.
As far as I understand the JavaScriptEvaluator code, the change should be ok.
All testcases work and the rhino javascript engine can execute scripts in parallel.
But maybe you have further insight, why the synchronisation was used?
It got introduced in #960 because multithreading was not possible before.
Now I would like to improve the performance for multithreading.
Thanks a lot, @SalomScala ! Looks like a great optimization indeed! We have enabled thread-safety of veraPDF only recently and there are still places that need improvements. We'll review and merge your PR if all goes well.
In our scenario we parallize validations with 20 Threads in a single JVM.
We recognized a big bottleneck in the
JavaScriptEvaluator.getTestEvalResult
-Method, since it is synchronized and only one thread at a time can evaluate its result.To show the problem I have attached
I have tried to fix it locally by adjusting
JavaScriptEvaluator
to useThreadLocals
.I got the following results:
Testscenario:
Result before optimization:
Result after optimization:
Thus an validation speed improvement of 325% in the concurrent case with 20 threads.
As far as I understand the
JavaScriptEvaluator
code, the change should be ok.All testcases work and the rhino javascript engine can execute scripts in parallel.
But maybe you have further insight, why the synchronisation was used?
It got introduced in #960 because multithreading was not possible before.
Now I would like to improve the performance for multithreading.
I have created pull request #1409
I welcome any feedback.
Thanks.
The text was updated successfully, but these errors were encountered: