Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6 modules + new String #1973

Closed
wants to merge 48 commits into from

Conversation

janbiedermann
Copy link
Member

@janbiedermann janbiedermann commented May 8, 2019

continue work of #1970
experimental
use new String instead of string primitives to support ruby String semantics in "use strict" mode

@janbiedermann
Copy link
Member Author

all strings are new String() and no primitives, at least all those cases that are covered by the tests.
Lets benchmark ...

add task bench:opal_strict
add task bench:opal_strict
@janbiedermann
Copy link
Member Author

janbiedermann commented May 8, 2019

Benchmarks:
run in nodejs v12.1.0, one run only, possibly highly scientific

  • 1_opal-1-0-0-beta1 : es6_modules_string in nodejs runner new String()
  • 2_opal-1-0-0-beta1 : es6_modules_string in strictnodejs runner new String()
  • 3_opal-1-0-0-beta1 : es6_modules in nodejs runner string primitives
  • 4_opal-1-0-0-beta1 : es6_modules in strictnodejs runner string primitives
Base: 1_opal-1-0-0-beta1
Benchmark                                               1_opal-1-0-0-beta1 |      4_opal-1-0-0-beta1 |      2_opal-1-0-0-beta1 |      3_opal-1-0-0-beta1 | 
test/cruby/benchmark/bm_loop_times.rb                              3.840ms |      -95.84%    0.160ms |      -95.92%    0.157ms |       +9.45%    4.203ms | 
test/cruby/benchmark/bm_vm2_dstr.rb                                1.647ms |      -95.18%    0.079ms |       -2.26%    1.610ms |      -94.87%    0.085ms | 
test/cruby/benchmark/bm_vm1_gc_short_lived.rb                      5.388ms |      -93.93%    0.327ms |       -3.15%    5.219ms |      -93.55%    0.348ms | 
test/cruby/benchmark/bm_vm2_poly_method_ov.rb                      1.904ms |      -91.38%    0.164ms |      -90.81%    0.175ms |       -3.71%    1.833ms | 
test/cruby/benchmark/bm_so_nested_loop.rb                          2.882ms |      -85.70%    0.412ms |      -85.59%    0.415ms |       +8.32%    3.122ms | 
test/cruby/benchmark/bm_vm2_poly_method.rb                         1.831ms |      -76.92%    0.422ms |      -89.95%    0.184ms |       +6.92%    1.957ms | 
test/cruby/benchmark/bm_vm1_neq.rb                                 4.219ms |      -74.23%    1.087ms |      -70.76%    1.234ms |       -2.12%    4.130ms | 
test/cruby/benchmark/bm_hash_aref_str.rb                           2.606ms |      -71.67%    0.738ms |      -72.69%    0.712ms |       +8.22%    2.820ms | 
test/cruby/benchmark/bm_so_random.rb                               1.668ms |      -56.25%    0.730ms |      -53.84%    0.770ms |       +2.40%    1.708ms | 
test/cruby/benchmark/bm_so_ackermann.rb                            0.279ms |      -40.64%    0.166ms |      -42.96%    0.159ms |      -11.53%    0.247ms | 
test/cruby/benchmark/bm_vm2_send.rb                                1.424ms |      -35.45%    0.919ms |      -36.47%    0.905ms |       +6.98%    1.523ms | 
test/cruby/benchmark/bm_app_answer.rb                              0.020ms |      -30.67%    0.014ms |      -32.83%    0.013ms |       +1.99%    0.020ms | 
test/cruby/benchmark/bm_vm1_attr_ivar_set.rb                      44.378ms |      -26.41%   32.658ms |       -2.68%   43.187ms |      -23.68%   33.868ms | 
test/cruby/benchmark/bm_vm2_struct_big_aset.rb                     4.391ms |      -25.56%    3.268ms |       -1.71%    4.316ms |      -16.07%    3.685ms | 
test/cruby/benchmark/bm_vm2_struct_small_aset.rb                   4.247ms |      -25.46%    3.166ms |       -0.60%    4.222ms |      -21.47%    3.335ms | 
test/cruby/benchmark/bm_so_object.rb                               1.901ms |      -23.44%    1.455ms |      -27.23%    1.383ms |       +7.53%    2.044ms | 
test/cruby/benchmark/bm_so_lists.rb                                4.879ms |      -17.71%    4.015ms |      -25.23%    3.648ms |       -4.64%    4.653ms | 
test/cruby/benchmark/bm_vm2_struct_big_aref_lo.rb                  0.133ms |      -15.01%    0.113ms |      -11.98%    0.118ms |      -15.59%    0.113ms | 
test/cruby/benchmark/bm_vm2_zsuper.rb                              2.194ms |      -12.33%    1.923ms |      -14.68%    1.872ms |      +13.05%    2.480ms | 
test/cruby/benchmark/bm_vm2_case.rb                                5.270ms |      -10.67%    4.708ms |      -16.50%    4.401ms |       -3.37%    5.092ms | 
test/cruby/benchmark/bm_vm2_method_missing.rb                      0.081ms |      -10.65%    0.072ms |       -8.58%    0.074ms |       -5.34%    0.077ms | 
test/cruby/benchmark/bm_so_matrix.rb                               2.046ms |      -10.41%    1.833ms |       -1.46%    2.017ms |      +16.07%    2.375ms | 
test/cruby/benchmark/bm_loop_for.rb                                0.208ms |       -9.60%    0.188ms |       -5.04%    0.198ms |       -7.19%    0.193ms | 
test/cruby/benchmark/bm_vm1_not.rb                                 0.644ms |       -9.49%    0.583ms |       -8.50%    0.589ms |       -6.09%    0.605ms | 
test/cruby/benchmark/bm_vm1_swap.rb                                0.387ms |       -7.50%    0.358ms |       -8.25%    0.355ms |       -1.48%    0.381ms | 
test/cruby/benchmark/bm_hash_aref_miss.rb                          0.971ms |       -7.37%    0.899ms |      -11.29%    0.861ms |       -5.39%    0.919ms | 
test/cruby/benchmark/bm_vm3_clearmethodcache.rb                    6.286ms |       -7.13%    5.838ms |       -7.56%    5.811ms |       -1.08%    6.218ms | 
test/cruby/benchmark/bm_hash_keys.rb                               3.187ms |       -5.30%    3.018ms |       -1.92%    3.125ms |       -1.33%    3.144ms | 
test/cruby/benchmark/bm_vm2_array.rb                               0.074ms |       -4.78%    0.071ms |       -6.98%    0.069ms |       -9.00%    0.068ms | 
test/cruby/benchmark/bm_loop_whileloop.rb                          0.348ms |       -3.78%    0.335ms |       -5.56%    0.329ms |       -4.25%    0.333ms | 
test/cruby/benchmark/bm_app_tak.rb                                 0.229ms |       -3.76%    0.220ms |       -3.61%    0.220ms |       +2.76%    0.235ms | 
test/cruby/benchmark/bm_vm1_block.rb                               5.447ms |       -3.39%    5.262ms |       -1.53%    5.364ms |       +1.06%    5.505ms | 
test/cruby/benchmark/bm_vm2_super.rb                               1.347ms |       -1.32%    1.329ms |       -3.34%    1.302ms |       -3.84%    1.295ms | 
test/cruby/benchmark/bm_vm1_simplereturn.rb                        0.365ms |       -0.98%    0.361ms |       -6.98%    0.340ms |       -3.74%    0.351ms | 
test/cruby/benchmark/bm_vm2_proc.rb                                1.025ms |       -0.57%    1.019ms |       +0.85%    1.034ms |       +8.13%    1.108ms | 
test/cruby/benchmark/bm_vm2_bigarray.rb                            0.065ms |       -0.32%    0.065ms |       +1.17%    0.066ms |       +0.03%    0.065ms | 
test/cruby/benchmark/bm_hash_shift.rb                             26.586ms |       -0.02%   26.581ms |       -0.09%   26.561ms |       +5.92%   28.160ms | 
test/cruby/benchmark/bm_app_tarai.rb                               0.173ms |       +0.20%    0.174ms |       -0.34%    0.173ms |       +1.72%    0.176ms | 
test/cruby/benchmark/bm_vm2_method.rb                              0.071ms |       +0.40%    0.071ms |      +10.12%    0.078ms |      +16.99%    0.083ms | 
test/cruby/benchmark/bm_vm2_unif1.rb                               0.072ms |       +0.45%    0.072ms |       -0.79%    0.071ms |      +10.70%    0.079ms | 
test/cruby/benchmark/bm_vm1_lvar_set.rb                            0.322ms |       +0.91%    0.325ms |       -2.01%    0.316ms |       +9.19%    0.352ms | 
test/cruby/benchmark/bm_vm2_method_with_block.rb                   4.916ms |       +0.99%    4.965ms |       +0.51%    4.941ms |       +1.56%    4.993ms | 
test/cruby/benchmark/bm_vm1_lvar_init.rb                           6.904ms |       +1.74%    7.025ms |       +1.00%    6.973ms |      +25.87%    8.691ms | 
test/cruby/benchmark/bm_vm2_defined_method.rb                      0.077ms |       +2.21%    0.079ms |       +0.19%    0.077ms |      +17.20%    0.090ms | 
test/cruby/benchmark/bm_vm1_ensure.rb                              0.351ms |       +2.94%    0.361ms |       +1.09%    0.355ms |       -1.62%    0.345ms | 
test/cruby/benchmark/bm_vm1_attr_ivar.rb                           0.366ms |       +3.59%    0.380ms |       -8.68%    0.335ms |       +4.94%    0.384ms | 
test/cruby/benchmark/bm_hash_values.rb                             2.990ms |       +3.93%    3.107ms |       +3.13%    3.084ms |       +4.51%    3.125ms | 
test/cruby/benchmark/bm_vm2_newlambda.rb                           0.728ms |       +4.41%    0.760ms |       +2.77%    0.748ms |       +5.35%    0.767ms | 
test/cruby/benchmark/bm_vm1_float_simple.rb                        0.463ms |       +4.99%    0.486ms |       +4.94%    0.486ms |       +2.99%    0.477ms | 
test/cruby/benchmark/bm_app_strconcat.rb                           0.029ms |       +5.15%    0.030ms |       +1.45%    0.029ms |      +19.94%    0.035ms | 
test/cruby/benchmark/bm_app_fib.rb                                 0.153ms |       +5.24%    0.161ms |       +2.07%    0.156ms |      +10.11%    0.169ms | 
test/cruby/benchmark/bm_vm1_ivar.rb                                0.363ms |       +5.48%    0.383ms |       -3.93%    0.349ms |      +10.78%    0.403ms | 
test/cruby/benchmark/bm_vm1_yield.rb                               1.740ms |       +7.10%    1.864ms |       +3.26%    1.797ms |      +18.84%    2.068ms | 
test/cruby/benchmark/bm_vm1_ivar_set.rb                            0.341ms |       +8.16%    0.369ms |       +5.88%    0.361ms |       +2.26%    0.349ms | 
test/cruby/benchmark/bm_vm2_struct_small_aref.rb                   0.078ms |       +8.84%    0.085ms |       +8.87%    0.085ms |      +70.65%    0.134ms | 
test/cruby/benchmark/bm_loop_whileloop2.rb                         0.066ms |       +9.17%    0.072ms |       +4.73%    0.069ms |       +0.32%    0.066ms | 
test/cruby/benchmark/bm_vm1_length.rb                              0.557ms |       +9.38%    0.610ms |       +1.57%    0.566ms |      +17.66%    0.656ms | 
test/cruby/benchmark/bm_vm1_rescue.rb                              0.315ms |      +11.17%    0.351ms |       +2.16%    0.322ms |       +4.09%    0.328ms | 
test/cruby/benchmark/bm_hash_flatten.rb                            1.293ms |      +11.48%    1.442ms |       +2.19%    1.321ms |       +5.67%    1.366ms | 
test/cruby/benchmark/bm_app_factorial.rb                           0.011ms |      +12.99%    0.013ms |       -1.10%    0.011ms |      +17.83%    0.013ms | 
test/cruby/benchmark/bm_vm2_struct_big_aref_hi.rb                  0.112ms |      +22.87%    0.137ms |      +31.72%    0.147ms |      +25.66%    0.141ms | 
test/cruby/benchmark/bm_vm1_const.rb                               2.427ms |      +23.46%    2.997ms |      +10.89%    2.692ms |      +20.41%    2.923ms | 
test/cruby/benchmark/bm_vm2_bighash.rb                            17.081ms |      +98.11%   33.840ms |      -32.88%   11.466ms |      +43.34%   24.484ms |

@janbiedermann
Copy link
Member Author

janbiedermann commented May 8, 2019

conclusions:

  • strict mode gives a nice performance boost in nodejs v12.1.0, see run 1 vs. run 2, run 3 vs. run 4
  • new String() has advantages and disadvantages, see run 1 vs. run 3, run 2 vs. run 4
  • strict mode and new String() is on average faster than non strict mode with string primitives, see run 2 vs. run 3

@janbiedermann janbiedermann mentioned this pull request May 9, 2019
properly simply doesnt work. Either it works for webpack, or it works
for the other runners/traditional require,
but no way to make it work for both. Solution: integrate js as %x{},
works for everybody.
cleanup some naming
fix: one global. prefix was missing
properly simply doesnt work. Either it works for webpack, or it works
for the other runners/traditional require,
but no way to make it work for both. Solution: integrate js as %x{},
works for everybody.
cleanup some naming
fix: one global. prefix was missing
@janbiedermann
Copy link
Member Author

obsolete, Javascript 'boxed' values are to be avoided

@janbiedermann janbiedermann deleted the es6_modules_string branch March 13, 2022 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants