124 karma · joined Apr 6, 2012 (14y ago) · 40 submissions
comment 7mo ago · link · parent
To give one example, DB adapters work just fine.
2.
Contributions to Ruby/spec by Ruby implementation(eregon.me ↗)
5 points · by eregon · 1y ago · discuss
comment 1y ago · link · parent
> Cool, but what about replacing the regexp with straightforward parsing code written manually?
If you take a look at the linked snippets of C code, I think it's clear it's all but straightforward. The regexps OTOH are really short and expressive.
Ruby has no access to SIMD. And writing SIMD is basically writing inline assembly, so it's really tedious and messy.
> relying on the compiler doing autovectorization to make it fast.
I can relate to that, but Regexps are a much smaller domain, and there it's clear SIMD is always a win, so if the regexp engine uses SIMD it's very unlikely it would ever stop using it (unless something faster comes up).
5.
Benchmarking Ruby Parsers(eregon.me ↗)
2 points · by eregon · 2y ago · discuss
comment 4y ago · link · parent
There were compatibility issues with BigDecimal, but TruffleRuby now uses the C extension, hence it should be exactly the same behavior as CRuby.
> Numerical to string formatting is a bit different too.
AFAIK that was fixed years ago if you mean float formatting.
> Regexes behave differently if they worked at all.
TruffleRuby always used Joni, which is literally a translation of CRuby's Regexp engine to Java (by the JRuby team), so that is very surprising and I have a really hard time to believe it. At least "Regexes behave differently if they worked at all" seems harsh and highly inaccurate to me. There likely were a couple Regexp issues but the generalization seems wildly exaggerated.
comment 4y ago · link · parent
Some things are expected to be slower, for instance constantly redefining (monkey-patching) methods or constants is slower on TruffleRuby, but that's typically because the program is broken and so it'd be slow on CRuby as well.
comment 4y ago · link · parent
comment 4y ago · link · parent
Persisting the JITed code is what we think can solve the slower startup entirely: https://www.graalvm.org/graalvm-as-a-platform/language-imple... Also other things mentioned in https://eregon.me/blog/2022/01/06/benchmarking-cruby-mjit-yj...
comment 4y ago · link · parent
comment 4y ago · link · parent
Keeping up compatibility (while keeping things efficient) is a lot of work, TruffleRuby tries to reduce that by reusing as much as possible existing code, including reusing C extensions shipped with CRuby.
comment 4y ago · link · parent
comment 5y ago · link · parent
comment 5y ago · link · parent
comment 5y ago · link · parent
> instead of having to ship an entire language runtime to production
Except they ship the CRuby language runtime in production. Ruby is not a language that can run without a runtime.
> Not only did we not need Java VM-level interoperability
So they almost discard the entire idea because they don't need a specific additional feature?
> choosing either alternative Ruby implementation would have made for a difficult migration path.
So what is it?
> Stripe relies heavily on gems with native extensions
Yes that's a problem on JRuby (when there is no java extension in that gem), but TruffleRuby supports native extensions, as very clearly stated in many places.
> as you can imagine, a multi-million line Ruby codebase over time starts to depend on Ruby-the-implementation, not just Ruby-the-language.
Except all serious Ruby implementations know they need to be compatible with whatever CRuby does, not just an incomplete ISO specification of the language. In fact alternative Ruby implementations match CRuby behavior as much as possible for compatibility, even when it seems weird or makes little sense (they report it in this case but have to match behavior anyway).
TruffleRuby might not be 100% compatible with CRuby yet, but I would say it is [pretty close](https://eregon.me/blog/2020/06/27/ruby-spec-compatibility-re...).
> To adopt JRuby or TruffleRuby in Stripe’s most important services, we’d have to be able to run all the code or none of the code [of a service].
Well yes, to get significant performance gains, one needs to try new things. Don't they have a staging environment where they can do experiments?
comment 5y ago · link · parent
comment 5y ago · link · parent
I'll try to run these benchmarks on TruffleRuby (and maybe JRuby) too, would be an interesting comparison.
BTW, is there any reason you used 2.1.0 and not 2.0.0? Maybe some issue with 2.0.0?
comment 5y ago · link · parent
And the PR is by someone not at Oracle, and his interest is to run some Rails app on TruffleRuby, and for that he'd like to ensure all gems work fine on TruffleRuby, which seems a very legitimate thing to do, isn't it?
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 7y ago · link · parent
Why not? It'd be possible to have TLABs, isn't it? But yes, GC would still be for all Guilds at once.
Racket places don't allow to share objects, only arrays of primitive types, which seems very restrictive. And Racket futures are even more restricted.
I'm not sure about Guilds since it's not there yet, but it already sounds closer to Ruby multithreading and more flexible to me from an usage point of view.
comment 7y ago · link · parent
I think one difficulty there is some global state in C extensions might expect to be truly process-global.
Also, how would you isolate global variables in the C extension? If the C extension is a dynamic library, it's typically only loaded once per process. Maybe something like dlmopen() to load multiple copies of a native library would help, but it's not portable.