Skip to content

Commit

Permalink
c-deps: localize RocksDB's SSE4.2 usage to CRC32C
Browse files Browse the repository at this point in the history
Previously, RocksDB was compiled with `-msse4.2` across the board. The
compiler, unsurprisingly took the liberty of actually emitting SSE4.2
instructions, which could cause `SIGILL` crashes on pre-SSE4.2 CPUs
(i.e, CPUs released before ca. November 2008).

The only part of RocksDB that really benefits from SSE4.2 instructions,
however, is the CRC32C checksum code, which can use the hardware CRC32C
instructions provided by SSE4.2. This commit simply removes `-msse4.2`
from the RocksDB compile flags, and renables it for the FastCRC32
function only via a GCC attribute. Since FastCRC32 is already properly
guarded by a CPUID check, which falls back to a slower implementation at
runtime if the CPU does not support SSE4.2, this should get us nearly
all of the performance benefits of compiling with `-msse4.2` while still
supporting pre-SSE4.2 CPUs.

Fixes cockroachdb#15589.
  • Loading branch information
benesch committed Jul 10, 2017
1 parent a26544c commit 1796c41
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ $(ROCKSDB_DIR)/Makefile: $(C_DEPS_DIR)/rocksdb-rebuild | libsnappy $(if $(USE_ST
@# NOTE: If you change the CMake flags below, bump the version in
@# $(C_DEPS_DIR)/rocksdb-rebuild. See above for rationale.
cd $(ROCKSDB_DIR) && cmake $(CMAKE_FLAGS) $(ROCKSDB_SRC_DIR) \
$(if $(findstring release,$(TYPE)),,-DWITH_$(if $(findstring mingw,$(TARGET_TRIPLE)),AVX2,SSE42)=OFF) \
-DWITH_$(if $(findstring mingw,$(TARGET_TRIPLE)),AVX2,SSE42)=OFF \
-DSNAPPY_LIBRARIES=$(SNAPPY_DIR)/libsnappy.a -DSNAPPY_INCLUDE_DIR="$(SNAPPY_SRC_DIR);$(SNAPPY_DIR)" -DWITH_SNAPPY=ON \
$(if $(USE_STDMALLOC),,-DJEMALLOC_LIBRARIES=$(JEMALLOC_DIR)/lib/libjemalloc.a -DJEMALLOC_INCLUDE_DIR=$(JEMALLOC_DIR)/include -DWITH_JEMALLOC=ON) \
$(if $(ENABLE_ROCKSDB_ASSERTIONS),,-DCMAKE_CXX_FLAGS=-DNDEBUG)
Expand Down
2 changes: 1 addition & 1 deletion c-deps/rocksdb

0 comments on commit 1796c41

Please sign in to comment.