Skip to content

Commit

Permalink
config: disable FSRM fd_memcpy by default
Browse files Browse the repository at this point in the history
As of 2024-Apr FSRM is almost certainly slower on AMD Zen 2,3.
(the architecture primarily run by the validator community)

We also expect a sizable part of the community to use the native
Make profile.  It is therefore preferable to disable FSRM by
default and use the compiler's __builtin_memcpy instead.

Furthermore, most security tools (ASan, CBMC) offer less
protection with the FSRM backend instead of __builtin_memcpy.

Keep FSRM enabled for Icelake targets.
  • Loading branch information
riptl authored and ripatel-fd committed Apr 22, 2024
1 parent 540caa1 commit a18fe01
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions config/machine/linux_clang_icelake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ include config/extra/with-zstd.mk
# -mbranch-cost=5

CPPFLAGS+=-march=icelake-server -mtune=icelake-server -mfpmath=sse \
-DFD_HAS_INT128=1 -DFD_HAS_DOUBLE=1 -DFD_HAS_ALLOCA=1 -DFD_HAS_X86=1 -DFD_HAS_SSE=1 -DFD_HAS_AVX=1 \
-DFD_HAS_SHANI=1 -DFD_HAS_GFNI=1 -DFD_HAS_AESNI=1 -DFD_HAS_AESNI=1 -DFD_HAS_AVX512=1
-DFD_HAS_INT128=1 -DFD_HAS_DOUBLE=1 -DFD_HAS_ALLOCA=1 -DFD_HAS_X86=1 -DFD_HAS_SSE=1 -DFD_HAS_AVX=1 \
-DFD_HAS_SHANI=1 -DFD_HAS_GFNI=1 -DFD_HAS_AESNI=1 -DFD_HAS_AVX512=1 \
-DFD_USE_ARCH_MEMCPY=1 -DFD_USE_ARCH_MEMSET=1

FD_HAS_INT128:=1
FD_HAS_DOUBLE:=1
Expand Down
5 changes: 3 additions & 2 deletions config/machine/linux_gcc_icelake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ include config/extra/with-zstd.mk


CPPFLAGS+=-march=icelake-server -mtune=icelake-server \
-DFD_HAS_INT128=1 -DFD_HAS_DOUBLE=1 -DFD_HAS_ALLOCA=1 -DFD_HAS_X86=1 -DFD_HAS_SSE=1 -DFD_HAS_AVX=1 \
-DFD_HAS_SHANI=1 -DFD_HAS_GFNI=1 -DFD_HAS_AESNI=1
-DFD_HAS_INT128=1 -DFD_HAS_DOUBLE=1 -DFD_HAS_ALLOCA=1 -DFD_HAS_X86=1 -DFD_HAS_SSE=1 -DFD_HAS_AVX=1 \
-DFD_HAS_SHANI=1 -DFD_HAS_GFNI=1 -DFD_HAS_AESNI=1 \
-DFD_USE_ARCH_MEMCPY=1 -DFD_USE_ARCH_MEMSET=1

FD_COMPILER_MAJOR_VERSION:=$(shell echo | $(CC) -march=native -E -dM - | grep __GNUC__ | awk '{print $$3}')
ifeq ($(shell test $(FD_COMPILER_MAJOR_VERSION) -lt 10 && echo 1),1)
Expand Down
6 changes: 3 additions & 3 deletions src/util/fd_util_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ FD_PROTOTYPES_BEGIN
/* FIXME: CONSIDER MEMCPY RELATED FUNC ATTRS */

#ifndef FD_USE_ARCH_MEMCPY
#define FD_USE_ARCH_MEMCPY 1
#define FD_USE_ARCH_MEMCPY 0
#endif

#if FD_HAS_X86 && FD_USE_ARCH_MEMCPY && !defined(CBMC) && !FD_HAS_MSAN
Expand Down Expand Up @@ -966,7 +966,7 @@ fd_memcpy( void * FD_RESTRICT d,
/* FIXME: CONSIDER MEMSET RELATED FUNC ATTRS */

#ifndef FD_USE_ARCH_MEMSET
#define FD_USE_ARCH_MEMSET 1
#define FD_USE_ARCH_MEMSET 0
#endif

#if FD_HAS_X86 && FD_USE_ARCH_MEMSET && !defined(CBMC) && !FD_HAS_MSAN
Expand Down Expand Up @@ -1005,7 +1005,7 @@ static void * (* volatile fd_memset_explicit)(void *, int, size_t) = memset;
preferable to __builtin_memcmp in some cases. */

#ifndef FD_USE_ARCH_MEMEQ
#define FD_USE_ARCH_MEMEQ 1
#define FD_USE_ARCH_MEMEQ 0
#endif

#if FD_HAS_X86 && FD_USE_ARCH_MEMEQ && defined(__GCC_ASM_FLAG_OUTPUTS__) && __STDC_VERSION__>=199901L
Expand Down

0 comments on commit a18fe01

Please sign in to comment.