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

Performance is bad when running mini_racer tests #3

Closed
lloeki opened this issue Oct 29, 2020 · 2 comments
Closed

Performance is bad when running mini_racer tests #3

lloeki opened this issue Oct 29, 2020 · 2 comments

Comments

@lloeki
Copy link
Collaborator

lloeki commented Oct 29, 2020

Doesn't seem to affect Linux (glibc at least). Has happened on musl at least once.

Example on macOS (libv8-node):

Fabulous run in 90.207620s, 0.9201 runs/s, 1.5409 assertions/s.

vs (libv8)

Fabulous run in 2.528212s, 32.8295 runs/s, 54.9796 assertions/s.
@lloeki
Copy link
Collaborator Author

lloeki commented Oct 29, 2020

We pinpointed the performance thing to MiniRacer::Context.new:

bundle exec ruby -e 'require "benchmark"; Benchmark.bm { |b| context = nil; b.report { require "mini_racer" }; b.report { context = MiniRacer::Context.new }; b.report { 100.times { context.eval("function f(x) { return \"I need  \"+ x + \" foos\" }") } } }'

gives (libv8-node)

       user     system      total        real
   0.012711   0.005495   0.018206 (  0.662711)
   0.815646   0.021527   0.837173 (  0.837263)
   0.003013   0.002043   0.005056 (  0.003985)

vs (libv8)

       user     system      total        real
   0.011028   0.003825   0.014853 (  0.014875)
   0.002350   0.000868   0.003218 (  0.002852)
   0.003491   0.001899   0.005390 (  0.004307)

Basically all that time is spent when calling MiniRacer::Context.new, to which the test suite is sensitive to, but otherwise it's fine.

More specifically it's Isolate::New. From some lousy printf profiling of rb_context_init_unsafe then IsolateInfo::init:

init took 602 us
new isolateinfo took 32 us
isolateinfo init
    allocator took 2 us
    params took 0 us
    Isolate::New took 868582 us
  took 868605 us
isolateinfo hold took 0 us
isolateinfo lock took 1431 us
datetime took 13 us

@lloeki
Copy link
Collaborator Author

lloeki commented Oct 31, 2020

  • Built with small-icu
  • Rearranged lib building

@lloeki lloeki closed this as completed Oct 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant