Details
-
Bug
-
Resolution: Fixed
-
P4
-
None
-
b104
-
generic
-
generic
Description
Looking at JDK-8040884 I found that object allocation through constructor functions suffers quite heavily due to multiple synchronization in allocator map retrieval.
Both ScriptFunction.getAllocatorMap and AllocationStrategy.getAllocatorMap are synchronized. If I remove just the synchronization in ScriptFunction, a simple microbenchmark is almost twice as fast, and Octane raytrace.js and box2d.js get significantly faster.
It seems we can safely remove synchronization in ScriptFunction.getAllocationMap.
Raytrace and Box2d results with double synchronization:
octane-raytrace-nashorn:
run-octane-nashorn:
[java] [nashorn] [raytrace] loading 'raytrace' [raytrace.js]... /home/hannes/work/nashorn9-dev/test/script/basic/../external/octane/raytrace.js
[java] [nashorn] [raytrace] running 'raytrace' for 25 iterations of no less than 5 seconds
[java] [nashorn] [raytrace] warmup finished 22 ops/minute
[java] [nashorn] [raytrace] iteration 1 finished 420 ops/minute
[java] [nashorn] [raytrace] iteration 2 finished 2803 ops/minute
[java] [nashorn] [raytrace] iteration 3 finished 4048 ops/minute
[java] [nashorn] [raytrace] iteration 4 finished 4609 ops/minute
[java] [nashorn] [raytrace] iteration 5 finished 5299 ops/minute
[java] [nashorn] [raytrace] iteration 6 finished 6260 ops/minute
[java] [nashorn] [raytrace] iteration 7 finished 6343 ops/minute
[java] [nashorn] [raytrace] iteration 8 finished 6392 ops/minute
[java] [nashorn] [raytrace] iteration 9 finished 6417 ops/minute
[java] [nashorn] [raytrace] iteration 10 finished 6470 ops/minute
[java] [nashorn] [raytrace] iteration 11 finished 6483 ops/minute
[java] [nashorn] [raytrace] iteration 12 finished 6483 ops/minute
[java] [nashorn] [raytrace] iteration 13 finished 6395 ops/minute
[java] [nashorn] [raytrace] iteration 14 finished 6520 ops/minute
[java] [nashorn] [raytrace] iteration 15 finished 6724 ops/minute
[java] [nashorn] [raytrace] iteration 16 finished 6752 ops/minute
[java] [nashorn] [raytrace] iteration 17 finished 6656 ops/minute
[java] [nashorn] [raytrace] iteration 18 finished 6767 ops/minute
[java] [nashorn] [raytrace] iteration 19 finished 6653 ops/minute
[java] [nashorn] [raytrace] iteration 20 finished 6687 ops/minute
[java] [nashorn] [raytrace] iteration 21 finished 6652 ops/minute
[java] [nashorn] [raytrace] iteration 22 finished 6655 ops/minute
[java] [nashorn] [raytrace] iteration 23 finished 6677 ops/minute
[java] [nashorn] [raytrace] iteration 24 finished 6663 ops/minute
[java] [nashorn] [raytrace] iteration 25 finished 6655 ops/minute
[java] [nashorn] [raytrace] 5939 ops/minute (420-6767), warmup=22
octane-box2d-nashorn:
run-octane-nashorn:
[java] [nashorn] [box2d] loading 'box2d' [box2d.js]... /home/hannes/work/nashorn9-dev/test/script/basic/../external/octane/box2d.js
[java] [nashorn] [box2d] running 'box2d' for 25 iterations of no less than 5 seconds
[java] [nashorn] [box2d] warmup finished 6 ops/minute
[java] [nashorn] [box2d] iteration 1 finished 16 ops/minute
[java] [nashorn] [box2d] iteration 2 finished 17 ops/minute
[java] [nashorn] [box2d] iteration 3 finished 23 ops/minute
[java] [nashorn] [box2d] iteration 4 finished 29 ops/minute
[java] [nashorn] [box2d] iteration 5 finished 35 ops/minute
[java] [nashorn] [box2d] iteration 6 finished 38 ops/minute
[java] [nashorn] [box2d] iteration 7 finished 45 ops/minute
[java] [nashorn] [box2d] iteration 8 finished 45 ops/minute
[java] [nashorn] [box2d] iteration 9 finished 55 ops/minute
[java] [nashorn] [box2d] iteration 10 finished 106 ops/minute
[java] [nashorn] [box2d] iteration 11 finished 150 ops/minute
[java] [nashorn] [box2d] iteration 12 finished 207 ops/minute
[java] [nashorn] [box2d] iteration 13 finished 201 ops/minute
[java] [nashorn] [box2d] iteration 14 finished 192 ops/minute
[java] [nashorn] [box2d] iteration 15 finished 166 ops/minute
[java] [nashorn] [box2d] iteration 16 finished 345 ops/minute
[java] [nashorn] [box2d] iteration 17 finished 610 ops/minute
[java] [nashorn] [box2d] iteration 18 finished 617 ops/minute
[java] [nashorn] [box2d] iteration 19 finished 606 ops/minute
[java] [nashorn] [box2d] iteration 20 finished 639 ops/minute
[java] [nashorn] [box2d] iteration 21 finished 637 ops/minute
[java] [nashorn] [box2d] iteration 22 finished 653 ops/minute
[java] [nashorn] [box2d] iteration 23 finished 650 ops/minute
[java] [nashorn] [box2d] iteration 24 finished 654 ops/minute
[java] [nashorn] [box2d] iteration 25 finished 649 ops/minute
[java] [nashorn] [box2d] 295 ops/minute (16-654), warmup=6
Raytrace and Box2d results with synchronization in AllocationStrategy.getAllocatorMap only>:
octane-raytrace-nashorn:
run-octane-nashorn:
[java] [nashorn] [raytrace] loading 'raytrace' [raytrace.js]... /home/hannes/work/nashorn9-dev/test/script/basic/../external/octane/raytrace.js
[java] [nashorn] [raytrace] running 'raytrace' for 25 iterations of no less than 5 seconds
[java] [nashorn] [raytrace] warmup finished 70 ops/minute
[java] [nashorn] [raytrace] iteration 1 finished 707 ops/minute
[java] [nashorn] [raytrace] iteration 2 finished 4929 ops/minute
[java] [nashorn] [raytrace] iteration 3 finished 5723 ops/minute
[java] [nashorn] [raytrace] iteration 4 finished 7251 ops/minute
[java] [nashorn] [raytrace] iteration 5 finished 7521 ops/minute
[java] [nashorn] [raytrace] iteration 6 finished 7531 ops/minute
[java] [nashorn] [raytrace] iteration 7 finished 7630 ops/minute
[java] [nashorn] [raytrace] iteration 8 finished 7738 ops/minute
[java] [nashorn] [raytrace] iteration 9 finished 7543 ops/minute
[java] [nashorn] [raytrace] iteration 10 finished 7638 ops/minute
[java] [nashorn] [raytrace] iteration 11 finished 7627 ops/minute
[java] [nashorn] [raytrace] iteration 12 finished 8023 ops/minute
[java] [nashorn] [raytrace] iteration 13 finished 8161 ops/minute
[java] [nashorn] [raytrace] iteration 14 finished 8174 ops/minute
[java] [nashorn] [raytrace] iteration 15 finished 8169 ops/minute
[java] [nashorn] [raytrace] iteration 16 finished 8110 ops/minute
[java] [nashorn] [raytrace] iteration 17 finished 8128 ops/minute
[java] [nashorn] [raytrace] iteration 18 finished 7894 ops/minute
[java] [nashorn] [raytrace] iteration 19 finished 7220 ops/minute
[java] [nashorn] [raytrace] iteration 20 finished 7833 ops/minute
[java] [nashorn] [raytrace] iteration 21 finished 8016 ops/minute
[java] [nashorn] [raytrace] iteration 22 finished 7746 ops/minute
[java] [nashorn] [raytrace] iteration 23 finished 7593 ops/minute
[java] [nashorn] [raytrace] iteration 24 finished 7974 ops/minute
[java] [nashorn] [raytrace] iteration 25 finished 8172 ops/minute
[java] [nashorn] [raytrace] 7322 ops/minute (707-8174), warmup=70
octane-box2d-nashorn:
run-octane-nashorn:
[java] [nashorn] [box2d] loading 'box2d' [box2d.js]... /home/hannes/work/nashorn9-dev/test/script/basic/../external/octane/box2d.js
[java] [nashorn] [box2d] running 'box2d' for 25 iterations of no less than 5 seconds
[java] [nashorn] [box2d] warmup finished 6 ops/minute
[java] [nashorn] [box2d] iteration 1 finished 17 ops/minute
[java] [nashorn] [box2d] iteration 2 finished 21 ops/minute
[java] [nashorn] [box2d] iteration 3 finished 27 ops/minute
[java] [nashorn] [box2d] iteration 4 finished 33 ops/minute
[java] [nashorn] [box2d] iteration 5 finished 36 ops/minute
[java] [nashorn] [box2d] iteration 6 finished 65 ops/minute
[java] [nashorn] [box2d] iteration 7 finished 81 ops/minute
[java] [nashorn] [box2d] iteration 8 finished 103 ops/minute
[java] [nashorn] [box2d] iteration 9 finished 130 ops/minute
[java] [nashorn] [box2d] iteration 10 finished 168 ops/minute
[java] [nashorn] [box2d] iteration 11 finished 225 ops/minute
[java] [nashorn] [box2d] iteration 12 finished 262 ops/minute
[java] [nashorn] [box2d] iteration 13 finished 366 ops/minute
[java] [nashorn] [box2d] iteration 14 finished 561 ops/minute
[java] [nashorn] [box2d] iteration 15 finished 615 ops/minute
[java] [nashorn] [box2d] iteration 16 finished 633 ops/minute
[java] [nashorn] [box2d] iteration 17 finished 659 ops/minute
[java] [nashorn] [box2d] iteration 18 finished 652 ops/minute
[java] [nashorn] [box2d] iteration 19 finished 661 ops/minute
[java] [nashorn] [box2d] iteration 20 finished 669 ops/minute
[java] [nashorn] [box2d] iteration 21 finished 671 ops/minute
[java] [nashorn] [box2d] iteration 22 finished 668 ops/minute
[java] [nashorn] [box2d] iteration 23 finished 671 ops/minute
[java] [nashorn] [box2d] iteration 24 finished 642 ops/minute
[java] [nashorn] [box2d] iteration 25 finished 606 ops/minute
[java] [nashorn] [box2d] 370 ops/minute (17-671), warmup=6
Both ScriptFunction.getAllocatorMap and AllocationStrategy.getAllocatorMap are synchronized. If I remove just the synchronization in ScriptFunction, a simple microbenchmark is almost twice as fast, and Octane raytrace.js and box2d.js get significantly faster.
It seems we can safely remove synchronization in ScriptFunction.getAllocationMap.
Raytrace and Box2d results with double synchronization:
octane-raytrace-nashorn:
run-octane-nashorn:
[java] [nashorn] [raytrace] loading 'raytrace' [raytrace.js]... /home/hannes/work/nashorn9-dev/test/script/basic/../external/octane/raytrace.js
[java] [nashorn] [raytrace] running 'raytrace' for 25 iterations of no less than 5 seconds
[java] [nashorn] [raytrace] warmup finished 22 ops/minute
[java] [nashorn] [raytrace] iteration 1 finished 420 ops/minute
[java] [nashorn] [raytrace] iteration 2 finished 2803 ops/minute
[java] [nashorn] [raytrace] iteration 3 finished 4048 ops/minute
[java] [nashorn] [raytrace] iteration 4 finished 4609 ops/minute
[java] [nashorn] [raytrace] iteration 5 finished 5299 ops/minute
[java] [nashorn] [raytrace] iteration 6 finished 6260 ops/minute
[java] [nashorn] [raytrace] iteration 7 finished 6343 ops/minute
[java] [nashorn] [raytrace] iteration 8 finished 6392 ops/minute
[java] [nashorn] [raytrace] iteration 9 finished 6417 ops/minute
[java] [nashorn] [raytrace] iteration 10 finished 6470 ops/minute
[java] [nashorn] [raytrace] iteration 11 finished 6483 ops/minute
[java] [nashorn] [raytrace] iteration 12 finished 6483 ops/minute
[java] [nashorn] [raytrace] iteration 13 finished 6395 ops/minute
[java] [nashorn] [raytrace] iteration 14 finished 6520 ops/minute
[java] [nashorn] [raytrace] iteration 15 finished 6724 ops/minute
[java] [nashorn] [raytrace] iteration 16 finished 6752 ops/minute
[java] [nashorn] [raytrace] iteration 17 finished 6656 ops/minute
[java] [nashorn] [raytrace] iteration 18 finished 6767 ops/minute
[java] [nashorn] [raytrace] iteration 19 finished 6653 ops/minute
[java] [nashorn] [raytrace] iteration 20 finished 6687 ops/minute
[java] [nashorn] [raytrace] iteration 21 finished 6652 ops/minute
[java] [nashorn] [raytrace] iteration 22 finished 6655 ops/minute
[java] [nashorn] [raytrace] iteration 23 finished 6677 ops/minute
[java] [nashorn] [raytrace] iteration 24 finished 6663 ops/minute
[java] [nashorn] [raytrace] iteration 25 finished 6655 ops/minute
[java] [nashorn] [raytrace] 5939 ops/minute (420-6767), warmup=22
octane-box2d-nashorn:
run-octane-nashorn:
[java] [nashorn] [box2d] loading 'box2d' [box2d.js]... /home/hannes/work/nashorn9-dev/test/script/basic/../external/octane/box2d.js
[java] [nashorn] [box2d] running 'box2d' for 25 iterations of no less than 5 seconds
[java] [nashorn] [box2d] warmup finished 6 ops/minute
[java] [nashorn] [box2d] iteration 1 finished 16 ops/minute
[java] [nashorn] [box2d] iteration 2 finished 17 ops/minute
[java] [nashorn] [box2d] iteration 3 finished 23 ops/minute
[java] [nashorn] [box2d] iteration 4 finished 29 ops/minute
[java] [nashorn] [box2d] iteration 5 finished 35 ops/minute
[java] [nashorn] [box2d] iteration 6 finished 38 ops/minute
[java] [nashorn] [box2d] iteration 7 finished 45 ops/minute
[java] [nashorn] [box2d] iteration 8 finished 45 ops/minute
[java] [nashorn] [box2d] iteration 9 finished 55 ops/minute
[java] [nashorn] [box2d] iteration 10 finished 106 ops/minute
[java] [nashorn] [box2d] iteration 11 finished 150 ops/minute
[java] [nashorn] [box2d] iteration 12 finished 207 ops/minute
[java] [nashorn] [box2d] iteration 13 finished 201 ops/minute
[java] [nashorn] [box2d] iteration 14 finished 192 ops/minute
[java] [nashorn] [box2d] iteration 15 finished 166 ops/minute
[java] [nashorn] [box2d] iteration 16 finished 345 ops/minute
[java] [nashorn] [box2d] iteration 17 finished 610 ops/minute
[java] [nashorn] [box2d] iteration 18 finished 617 ops/minute
[java] [nashorn] [box2d] iteration 19 finished 606 ops/minute
[java] [nashorn] [box2d] iteration 20 finished 639 ops/minute
[java] [nashorn] [box2d] iteration 21 finished 637 ops/minute
[java] [nashorn] [box2d] iteration 22 finished 653 ops/minute
[java] [nashorn] [box2d] iteration 23 finished 650 ops/minute
[java] [nashorn] [box2d] iteration 24 finished 654 ops/minute
[java] [nashorn] [box2d] iteration 25 finished 649 ops/minute
[java] [nashorn] [box2d] 295 ops/minute (16-654), warmup=6
Raytrace and Box2d results with synchronization in AllocationStrategy.getAllocatorMap only>:
octane-raytrace-nashorn:
run-octane-nashorn:
[java] [nashorn] [raytrace] loading 'raytrace' [raytrace.js]... /home/hannes/work/nashorn9-dev/test/script/basic/../external/octane/raytrace.js
[java] [nashorn] [raytrace] running 'raytrace' for 25 iterations of no less than 5 seconds
[java] [nashorn] [raytrace] warmup finished 70 ops/minute
[java] [nashorn] [raytrace] iteration 1 finished 707 ops/minute
[java] [nashorn] [raytrace] iteration 2 finished 4929 ops/minute
[java] [nashorn] [raytrace] iteration 3 finished 5723 ops/minute
[java] [nashorn] [raytrace] iteration 4 finished 7251 ops/minute
[java] [nashorn] [raytrace] iteration 5 finished 7521 ops/minute
[java] [nashorn] [raytrace] iteration 6 finished 7531 ops/minute
[java] [nashorn] [raytrace] iteration 7 finished 7630 ops/minute
[java] [nashorn] [raytrace] iteration 8 finished 7738 ops/minute
[java] [nashorn] [raytrace] iteration 9 finished 7543 ops/minute
[java] [nashorn] [raytrace] iteration 10 finished 7638 ops/minute
[java] [nashorn] [raytrace] iteration 11 finished 7627 ops/minute
[java] [nashorn] [raytrace] iteration 12 finished 8023 ops/minute
[java] [nashorn] [raytrace] iteration 13 finished 8161 ops/minute
[java] [nashorn] [raytrace] iteration 14 finished 8174 ops/minute
[java] [nashorn] [raytrace] iteration 15 finished 8169 ops/minute
[java] [nashorn] [raytrace] iteration 16 finished 8110 ops/minute
[java] [nashorn] [raytrace] iteration 17 finished 8128 ops/minute
[java] [nashorn] [raytrace] iteration 18 finished 7894 ops/minute
[java] [nashorn] [raytrace] iteration 19 finished 7220 ops/minute
[java] [nashorn] [raytrace] iteration 20 finished 7833 ops/minute
[java] [nashorn] [raytrace] iteration 21 finished 8016 ops/minute
[java] [nashorn] [raytrace] iteration 22 finished 7746 ops/minute
[java] [nashorn] [raytrace] iteration 23 finished 7593 ops/minute
[java] [nashorn] [raytrace] iteration 24 finished 7974 ops/minute
[java] [nashorn] [raytrace] iteration 25 finished 8172 ops/minute
[java] [nashorn] [raytrace] 7322 ops/minute (707-8174), warmup=70
octane-box2d-nashorn:
run-octane-nashorn:
[java] [nashorn] [box2d] loading 'box2d' [box2d.js]... /home/hannes/work/nashorn9-dev/test/script/basic/../external/octane/box2d.js
[java] [nashorn] [box2d] running 'box2d' for 25 iterations of no less than 5 seconds
[java] [nashorn] [box2d] warmup finished 6 ops/minute
[java] [nashorn] [box2d] iteration 1 finished 17 ops/minute
[java] [nashorn] [box2d] iteration 2 finished 21 ops/minute
[java] [nashorn] [box2d] iteration 3 finished 27 ops/minute
[java] [nashorn] [box2d] iteration 4 finished 33 ops/minute
[java] [nashorn] [box2d] iteration 5 finished 36 ops/minute
[java] [nashorn] [box2d] iteration 6 finished 65 ops/minute
[java] [nashorn] [box2d] iteration 7 finished 81 ops/minute
[java] [nashorn] [box2d] iteration 8 finished 103 ops/minute
[java] [nashorn] [box2d] iteration 9 finished 130 ops/minute
[java] [nashorn] [box2d] iteration 10 finished 168 ops/minute
[java] [nashorn] [box2d] iteration 11 finished 225 ops/minute
[java] [nashorn] [box2d] iteration 12 finished 262 ops/minute
[java] [nashorn] [box2d] iteration 13 finished 366 ops/minute
[java] [nashorn] [box2d] iteration 14 finished 561 ops/minute
[java] [nashorn] [box2d] iteration 15 finished 615 ops/minute
[java] [nashorn] [box2d] iteration 16 finished 633 ops/minute
[java] [nashorn] [box2d] iteration 17 finished 659 ops/minute
[java] [nashorn] [box2d] iteration 18 finished 652 ops/minute
[java] [nashorn] [box2d] iteration 19 finished 661 ops/minute
[java] [nashorn] [box2d] iteration 20 finished 669 ops/minute
[java] [nashorn] [box2d] iteration 21 finished 671 ops/minute
[java] [nashorn] [box2d] iteration 22 finished 668 ops/minute
[java] [nashorn] [box2d] iteration 23 finished 671 ops/minute
[java] [nashorn] [box2d] iteration 24 finished 642 ops/minute
[java] [nashorn] [box2d] iteration 25 finished 606 ops/minute
[java] [nashorn] [box2d] 370 ops/minute (17-671), warmup=6