From: jean.boussier@... Date: 2020-01-10T13:22:56+00:00 Subject: [ruby-core:96764] [Ruby master Misc#16487] Potential for SIMD usage in ruby-core Issue #16487 has been updated by byroot (Jean Boussier). > My concern here is who can read, understand and maintain that code? > Such complexity is likely to have bugs or need tweaks over time. It's a totally understandable concern. A few responses to that: - In that specific case, the UTF8 spec probably won't change before a while, so that limits the amount of maintenance required - In a more general case, if for some reason the SIMD version of a function is too hard to maintain, it can simply be removed. > It's unfortunate the C compiler cannot do this on its own. As @ahorek showed, they can do it to some extent. I doubt they can auto-vectorize `coderange_scan`, but maybe they can do it to `search_nonascii`, if so it could yield a decent speedup with very little code to maintain. It's likely worth a try. ---------------------------------------- Misc #16487: Potential for SIMD usage in ruby-core https://bugs.ruby-lang.org/issues/16487#change-83758 * Author: byroot (Jean Boussier) * Status: Open * Priority: Normal * Assignee: ---------------------------------------- ### Context There are several ruby core methods that could be optimized with the use of SIMD instructions. I experimented a bit on `coderange_scan` https://github.com/Shopify/ruby/pull/2, and Pavel Rosick� experimented on `String#strip` https://github.com/ruby/ruby/pull/2815. ### Problem The downside of SIMD instructions is that they are not universally available. So it means maintaining several versions of the same code, and switching them either statically or dynamically. And since most Ruby users use precompiled binaries from repositories and such, it would need to be dynamic if we want most users to benefit from it. So it's not exactly "free speed", as it means a complexified codebase. ### Question So the question is to know wether ruby-core is open to patches using SIMD instructions ? And if so under which conditions. cc @shyouhei -- https://bugs.ruby-lang.org/ Unsubscribe: