-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
src: don't use __builtin_bswap16() and friends #7644
Conversation
This fix works for me with OSX 10.8 and Clang 3.2 using |
Note that macOS 10.8 is not supported by Apple anymore, last version was released in 2013. This looks like it simplifies some code, though. Are there any performance implications here? |
There are big performance implications, yes. See the benchmark at the top of #7157 (up to 6x speedup) -- that was actually the main goal of the PR. I'd rather detect the Clang version or feature check in the macro, which is easy enough. (Or if the node maintainers decide, really drop support, as technically this isn't a supported compiler already.) |
@gibfahn or @bnoordhuis can you try this patch instead please? This works on ubuntu with clang 3.0 and later but again I can't test on OS X and I had to jerry-rig gnu libs with clang. +++ src/node_buffer.cc
--- src/node_buffer.cc
@@ -55,1 +55,5 @@
- #if defined(__GNUC__) || defined(__clang__)
+ #ifndef __has_builtin
+ # define __has_builtin(x) 0 // compatibility with non-clang
+ #endif
+
+ #if defined(__GNUC__) || (defined(__clang__) && __has_builtin(__builtin_bswap16)) godbolt if you want to play with this Note that LLVM clang 3.2 appears to have (I like that this PR consolidates all of the bswap code though.) Edit See follow-up PR #7645 |
Hmm, we could backport this but I doubt this is worthwhile on |
/cc @nodejs/build @jbergstroem, ref: nodejs/build#367. Any updates on the CI side? @Fishrock123 Google doesn't support 10.7/10.8 since Chrome 50. They could one day just break old clang support on their side (i.e. in v8). Also, 3 years of no security updates from Apple. So yes, +1 for dropping macOS 10.7 and 10.8. |
+1 for dropping older, unsupported versions. |
As I understand it this PR reverts the #7157 performance gains, whereas #7645 uses the newer builtins if available. So in theory there should be no performance loss with #7645. Also, the problem here is with an outdated version of Clang. It should be possible to update to a later version of Xcode on an OSX 10.8 mac, so this issue wouldn't force dropping support for OSX 10.8. In fact, as the v6.0.0 and v4.4.7 BUILDING.md instructions already list Clang 3.4 as the minimum supported version, Clang 3.2 isn't technically supported anyway. Obviously it may well make sense to drop OSX 10.8 support from v7 onwards anyway. Just to clarify, does supporting a version mean that node will build on that OS, or just that it will run there? |
Strictly speaking just run, I think, although I can't really come up with an example where it's known to run but not build on a platform. CentOS 6 without devtoolset comes closest. |
Said builtins are not supported by older versions of apple-gcc, breaking the build on OS X 10.8. Fixes: nodejs#7618 Refs: nodejs#4290 Refs: nodejs#7157
Fixes a couple of strict aliasing violations in the process.
@zbjornson PTAL. I didn't go all out (see footnote) but I get comparable numbers for the aligned case and double or treble the throughput for the unaligned swap32 and swap64 cases. (x86_64 linux, g++ 6.1.1 and clang++ 3.8.0, no -march or -mtune.) Footnote: the swap16 and swap32 cases can probably be sped up by reading and writing 64 bits at a time (on 64 bits architectures, or 32 bits with swap16 on 32 bits architectures.) |
@bnoordhuis on Windows this branch appears substantially slower (using defaults with
(Are different build args used to make the precompiled binaries that would affect use of SSE and AVX?) Testing on linux now... |
Mighty long benchmark. Linux with gcc and default build params I'm getting far closer (avg -5.6%) as you found. (Using std::swap is slow compared to Not sure what to do then... |
no, sorry, everything is terrible still and we only have 10.10 coverage still |
@zbjornson You mentioned that performance on Windows was significantly worse. Did you build with VS 2013 or 2015? |
@bnoordhuis I'm actually not positive which version the above benchmarks came from. I have definitely used 2015 for some of this, but I've also used 2013 and I think even 2012 with some service packs (which I had on one computer until this week!). Haven't looked at the benchmarks side-by-side. I also haven't had time yet to test both PRs with different GCC flags, if only to address linux users building from source with said flags. Will work on some more benchmark comparisons. |
Said builtins are not supported by older versions of apple-gcc, breaking
the build on OS X 10.8.
Fixes: #7618
Refs: #4290
Refs: #7157
CI: https://ci.nodejs.org/job/node-test-pull-request/3235/