GithubHelp home page GithubHelp logo

Performance Improvement Ideas about opal-rspec HOT 4 CLOSED

wied03 avatar wied03 commented on August 17, 2024
Performance Improvement Ideas

from opal-rspec.

Comments (4)

jgaskins avatar jgaskins commented on August 17, 2024

Posting my initial thoughts here. Keep in mind that some of this is speculation and isn't a reason to at least give it a shot:

Precompilation/minification

I don't think minification improves performance for anything but transfer over the wire. If it's loading from localhost, this is very little time (as in microseconds to transfer a few hundred KB). Precompilation would definitely be great, though. If the Opal compiler doesn't have to process it and only needs to compile the app, that would help a lot unless the Opal::Builder instance is reused between spec runs, in which case the compiled RSpec will be cached.

Closure compilation?

AFAIK, most JS VMs will not compile a function at all until it is executed. I'd need to run more benchmarks to be sure about it, though.

Other profiling

I can see what I can do about this. I've got a couple ideas, but just to clarify before I spend too much time on it, opal-rspec does use the actual RSpec gem code, right? We may be limited in performance by RSpec internals if so.

When specific examples are focused on, see if they can be filtered out BEFORE opal compilation

This would probably be pretty cool, but I wonder if the effort would be worth it. We could check the benefit by precompiling a spec run with and without unfocused specs (that is, literally remove unfocused specs from the spec code) and timing the compilation time. Then run each of those and check the runtimes.

My hypothesis is that they would differ only slightly and that the RSpec load time would dwarf it no matter what we do.

reduce the exception throwing just to get stack traces

This might have a pretty big performance impact for failing specs. Exceptions are probably the worst-performing thing you can do in a JS VM. Generating an exception, throwing it, and catching it all cause deoptimizations โ€”ย which is bad enough on its own, but the process of unwinding the stack and generating that stack trace is also slow inside the VM itself.

JRuby (at least pre-9k) suffers from this same problem and for almost the same reason. MRI has internal optimizations for generating stack traces (so you can call caller from anywhere, not just in exceptions), but most other VMs for any language don't.

from opal-rspec.

wied03 avatar wied03 commented on August 17, 2024

@jgaskins - Thanks for the info. I'll close this now the the main next step will be to get rid of the metadata exception throws to get trace info.

from opal-rspec.

wied03 avatar wied03 commented on August 17, 2024

@jgaskins - Just so you know, the exception throwing I mentioned above used to happen for every example, not just failing ones. It was being used to give RSpec metadata about where each example is (RSpec normally uses #caller on MRI). On master now, this has been removed and there is no location data for examples until they fail, at which point there is a stack trace.

from opal-rspec.

wied03 avatar wied03 commented on August 17, 2024

@jgaskins - https://github.com/karma-runner/karma-closure is doing number 4. In my case, I'd have to do it with a webpack/opal loader because I decided getting into the guts of Karma with https://github.com/wied03/karma-opal-rspec/ was a losing proposition.

from opal-rspec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.