tarantool / tarantool/tarantool
luajit: bit ops works differently with -march=native on Tiger Lake
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 3.7k
- Forks
- 419
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 88
Description
Tarantool version:
2.10.0-beta2-5-gdc19be406
Successful build:
$ cmake . -DCMAKE_BUILD_TYPE=Debug -DENABLE_BACKTRACE=ON -DENABLE_DIST=ON -DENABLE_FEEDBACK_DAEMON=OFF -DENABLE_BUNDLED_LIBCURL=OFF && make -j
Failed build:
$ CFLAGS="-march=native -O2" cmake . -DCMAKE_BUILD_TYPE=Debug -DENABLE_BACKTRACE=ON -DENABLE_DIST=ON -DENABLE_FEEDBACK_DAEMON=OFF -DENABLE_BUNDLED_LIBCURL=OFF && make -j
# or
$ CFLAGS="-march=native" cmake . -DCMAKE_BUILD_TYPE=Debug -DENABLE_BACKTRACE=ON -DENABLE_DIST=ON -DENABLE_FEEDBACK_DAEMON=OFF -DENABLE_BUNDLED_LIBCURL=OFF && make -j
How it fails:
./src/tarantool third_party/luajit/test/LuaJIT-tests/lib/ffi/bit64.lua
LuajitError: third_party/luajit/test/LuaJIT-tests/lib/ffi/bit64.lua:49: assertion failed!
fatal error, exiting the event loop
The test case itself:
9 ffi.cdef[[
10 typedef enum { ZZI = -1 } ienum_t;
11 typedef enum { ZZU } uenum_t;
12 ]]
<...>
44 do --- tobit/band negative unsigned enum
45 local x = ffi.new("uenum_t", -10)
46 local y = tobit(x)
47 local z = band(x)
48 assert(type(y) == "number")
49 assert(y == -10)
50 assert(type(z) == "cdata")
51 assert(z == 2^32-10)
52 end
Hardware
Dell Latitude 5420. Tiger Lake CPU.
$ cat /proc/cpuinfo | head -n 27
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 140
model name : 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
stepping : 1
microcode : 0x86
cpu MHz : 1799.998
cache size : 12288 KB
physical id : 0
siblings : 8
core id : 0
cpu cores : 4
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 27
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l2 invpcid_single cdp_l2 ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves split_lock_detect dtherm arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid movdiri movdir64b fsrm avx512_vp2intersect md_clear flush_l1d arch_capabilities
vmx flags : vnmi preemption_timer posted_intr invvpid ept_x_only ept_ad ept_1gb flexpriority apicv tsc_offset vtpr mtf vapic ept vpid unrestricted_guest vapic_reg vid ple shadow_vmcs pml ept_mode_based_exec tsc_scaling
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs
bogomips : 3609.60
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:
Environment
$ head -n 1 /etc/os-release
NAME=Gentoo
$ uname -a
Linux rade 5.14.0-gentoo #20 SMP Tue Nov 30 01:58:29 MSK 2021 x86_64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz GenuineIntel GNU/Linux
$ gcc --version | head -n 1
gcc (Gentoo 11.2.0 p1) 11.2.0
- glibc-2.34-r2
- binutils-2.37_p1-r1
The problem was initially found, when I built tarantool using emerge, and then it was narrowed down to the reproducer above. I'll share configuration applied on tarantool package just in case.
emerge configuration
Ebuild is here.
$ grep -R dev-db/tarantool /etc/portage/
/etc/portage/package.accept_keywords/tarantool:dev-db/tarantool **
/etc/portage/package.use/tarantool:dev-db/tarantool debug
/etc/portage/package.env/debug.env.list:dev-db/tarantool debug.conf
$ cat /etc/portage/env/debug.conf
# > If nostrip is in your default FEATURES, splitdebug won't do anything!
# https://wiki.gentoo.org/wiki/Debugging
CFLAGS="${CFLAGS} -ggdb"
CXXFLAGS="${CXXFLAGS} -ggdb"
FEATURES="${FEATURES} splitdebug compressdebug installsources -nostrip"
USE="debug"
USE flags: backtrace debug system-libcurl system-libyaml system-zstd -feedback-daemon -gcov -gprof -systemd -test CPU_FLAGS_X86="avx sse2".
$ cat /etc/portage/make.conf
CFLAGS="-march=native -O2"
CXXFLAGS="${CFLAGS}"
CHOST="x86_64-pc-linux-gnu"
MAKEOPTS="-j9 -l8"
CPU_FLAGS_X86="aes avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3"
USE="${USE} ${CPU_FLAGS_X86}"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
ACCEPT_KEYWORDS="~amd64"
EMERGE_DEFAULT_OPTS="--with-bdeps=y --quiet-build=y --jobs=4 --load-average=4"
PORTAGE_RSYNC_EXTRA_OPTS="--quiet"
INPUT_DEVICES="keyboard synaptics mouse evdev wacom"
VIDEO_CARDS="fbdev vesa intel i965 i915 iris"
# HDA Intel doesn't require anything special,
# disable other (default enabled) cards
ALSA_CARDS=""
# Moved to /etc/portage/package.use/python as suggested by
# eselect news read 35.
# 'Python 3.7 to become the default target'.
# PYTHON_TARGETS="python3_6 python3_7 python3_8 python3_9"
# PYTHON_SINGLE_TARGET="python3_7"
# I don't really care about versions here.
#RUBY_TARGETS="ruby26"
# Enable X-related features in apps
USE="${USE} X"
# Fonts supporting antialiasing and so on
USE="${USE} xft"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reported CMake build with and without -march=native, then execute third_party/luajit/test/LuaJIT-tests/lib/ffi/bit64.lua. Compare the failing enum bit-operation assertions around lines 44-51 and inspect the bundled LuaJIT path involved. Done means the test passes on the reported Tiger Lake configuration with the native optimization flags.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, lua
- Domain
- build-system, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100