8 ms·
Merge YJIT: an in-process JIT compiler
- xfalcox 5y agoI got some Insertion sort implementation running in 55% of the original time by enabling YJIT. Impressive work!
- montblanc 5y agoHow was the memory between the two?
- adamgordonbell 5y agoThis is so cool and for people who use Jekyll it improves Jekyll's liquid template rendering speed. JRuby and TrufflyRuby's JIT did not, at least for me. https://news.ycombinator.com/item?id=27322533 https://news.ycombinator.com/item?id=27322533
- xal 5y agoMake sure you have liquid-c enabled.
- brian_herman 5y agoCould ruby do something similar to python's gil removal? https://lwn.net/SubscriberLink/872869/0e62bba2db51ec7a/ https://lwn.net/SubscriberLink/872869/0e62bba2db51ec7a/
- ksec 5y agoRuby doesn’t have a reference counting GC, so not really applicable.
- Lerc 5y agoWhen I read Maxime's Basic block versioning paper it gave me a strong sense of "this is the right way". Great to see the concept taking root.
- ufo 5y agoMore than just the JIT itself, I'm very interested in seeing if this will push Ruby towards making other performance-related inprovements to it's data structures and bytecode format: https://pointersgonewild.com/2021/06/02/yjit-building-a-new-jit-compiler-inside-cruby/ https://pointersgonewild.com/2021/06/02/yjit-building-a-new-...
- dwheeler 5y agoThe YouTube video: https://www.youtube.com/watch?v=PBVLf3yfMs8 https://www.youtube.com/watch?v=PBVLf3yfMs8 ... note some other optimizations that they plan to implement that should improve both the JIT and non-JIT performance. Performance improvements are always welcome in any language.
- mappu 5y agoThere was already a JIT since Ruby 2.6, the MJIT: https://k0kubun.medium.com/ruby-3-0-jit-and-beyond-4d9404ce33c https://k0kubun.medium.com/ruby-3-0-jit-and-beyond-4d9404ce3... The author of that article (k0kubun) is also one of the reviewers on this PR. What is the difference between the two JITs?
- pjmlp 5y agoThis one is a proper JIT, whereas the former generated C code, called the C compiler on it, and then loaded the generated code as shared object. You can imagine how much it actually helped in the end. Whatever the native code might help was let down due to the lantency of doing all that work.
- montblanc 5y agoBut you do the process you described only once per "warmed up" method right? Yes it sound expensive but once it's warmed up it should be as good as YJIT or am I missing something?
- pjmlp 5y ago"Why Ruby's JIT was slow" talk at RubyKaigi 2021. https://www.youtube.com/watch?v=db3GHHllRyQ https://www.youtube.com/watch?v=db3GHHllRyQ
- firecall 5y ago"YJIT currently provides average speedups of 23% over the CRuby interpreter on realistic benchmarks, and near-instant warm-up time. Plans are to include YJIT in the Ruby 3.1 preview release so that more users can test it out and benefit from potential performance gains."
- montblanc 5y ago> YJIT uses significantly more memory when active -- e.g. OptCarrot takes 80MB without YJIT and 350MB with YJIT. This can be adjusted by setting --yjit-exec-mem-size. This one gave me a worry. I think it can be addressed, but if it can't this whole effort seems a bit overrated to me.
- tyingq 5y ago>No garbage collection for generated code. Will produce an error if --yjit-exec-mem-size is exceeded. This should be fixed in the coming months. Sounds like at least part of it will be fixed.
- wiremine 5y agoIt's always a trade off of time and space, especially for dynamic languages. Glad the flag is there, and it will be interesting to see more real-world data once it's out in the wild.
- woodruffw 5y agoThis is awesome! Ruby is a notoriously hard language to optimize thanks to its (wonderful) dynamism, so it's very exciting to see substantial performance gains with this new JIT. Something that I noticed that might throw others for a loop as well: the changeset is north of 350K, but the actual JIT is only a couple of thousands of lines of C. 90% of the changeset is two torture test files.
- PikachuEXE 5y ago> torture test files I like this term
- jashmatthews 5y ago> the actual JIT is only a couple of thousands of lines of C Even for Ruby, a basic JIT can be implemented in a few hundred lines of C using a "threaded code" approach. Real JIT compilers got started this way. Safari JavaScriptCore's JIT used a "context threaded code" approach and was just 4k LOC https://webkit.org/blog/214/introducing-squirrelfish-extreme/ https://webkit.org/blog/214/introducing-squirrelfish-extreme...
- stanislavb 5y agoi.e. it's well tested and solid. Including running on some production Shopify systems :)
- dang 5y agoRelated past threads. Others? YJIT: Building a New JIT Compiler for CRuby - https://news.ycombinator.com/item?id=28874283 https://news.ycombinator.com/item?id=28874283 - Oct 2021 (47 comments) Proposal to Merge YJIT into Ruby - https://news.ycombinator.com/item?id=28691048 https://news.ycombinator.com/item?id=28691048 - Sept 2021 (77 comments) YJIT: Building a New JIT Compiler Inside CRuby - https://news.ycombinator.com/item?id=27371977 https://news.ycombinator.com/item?id=27371977 - June 2021 (1 comment)
- pvg 5y agohttps://news.ycombinator.com/item?id=27231556 https://news.ycombinator.com/item?id=27231556 which is not strictly about YJIT but has YJIT things in it.
- collegeburner 5y agoBtw the actual commit is here since the pr was closed and merged separately: https://github.com/ruby/ruby/commit/6a9e2b3cc381fd1b6c5ec5eddb077ea5468ef75e https://github.com/ruby/ruby/commit/6a9e2b3cc381fd1b6c5ec5ed...