The developers of MongoDB have decided to require AVX instructions for MongoDB 5.x and upwards. It would be a good idea to make this optimization optional. The optimization option is in SConstruct as part of a list of so called experimental optimizations. ///// experimental_optimizations = [ 'O3', 'builtin-memcmp', 'fnsi', 'nofp', 'nordyn', 'sandybridge', 'tbaa', 'treevec', 'vishidden', ] /////
The same would apply to databases/mongodb60 actually. By default it uses arch=sandybridge.
Some messages about this are on the mongodb forum also. https://www.mongodb.com/community/forums/t/mongodb-5-0-cpu-intel-g4650-compatibility/116610 Are you able to create a patch and show that it works?
I'm on it, updating a system. I will post it once it works.
(In reply to Borja Marcos from comment #3) Thank you for looking into it. Out of curiosity I googled AVX & Sandybridge and the technology seems about 10 years old (2011). What kind of hardware are you trying to run MongoDB 5 on?
(In reply to Ronald Klop from comment #4) Testing patch, turns out to be trivial once you know scons (I must admit I am and old Makefile guy). Added a NOAVX option to the port Makefile that adds --experimental-optimization="-sandybridge" to the scons options. I am testing right now making sure it works. I've named the option "NOAVX" because Mongodb by default enables it despite being labelled as "experimental" on the SCons file. The same happens with MongoDB 6. As for the hardware, my development/testing platform is old. But from what I've digged, some hypervisors won't support the AVX instructions either, so the problem can be more widespread than it seems. In my case, CPU: Intel(R) Xeon(R) CPU L5640 @ 2.27GHz (2266.86-MHz K8-class CPU) Origin="GenuineIntel" Id=0x206c2 Family=0x6 Model=0x2c Stepping=2 Features=0xbfebfbff<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,HTT,TM,PBE> Features2=0x29ee3ff<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,POPCNT,AESNI> AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM> AMD Features2=0x1<LAHF> VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID TSC: P-state invariant, performance statistics
Created attachment 239085 [details] Patch to add an option disabling AVX instructions
Comment on attachment 239085 [details] Patch to add an option disabling AVX instructions *** Makefile.orig Wed Dec 28 10:00:29 2022 --- Makefile Wed Dec 28 13:51:49 2022 *************** *** 59,66 **** USERS= mongodb GROUPS= mongodb ! OPTIONS_DEFINE= LTO SASL SSL OPTIONS_DEFAULT= LTO SASL SSL LTO_MAKE_ARGS= --lto=on --- 59,70 ---- USERS= mongodb GROUPS= mongodb ! OPTIONS_DEFINE= LTO SASL SSL NOAVX OPTIONS_DEFAULT= LTO SASL SSL + + NOAVX_DESC= "Disable AVX instructions on amd64 (Sandybridge+)" + + NOAVX_MAKE_ARGS= --experimental-optimization="-sandybridge" LTO_MAKE_ARGS= --lto=on
The patch did not apply cleanly. It does not look like a "unified" diff. I applied the changed manually and it looks good to me.
Created attachment 239209 [details] patch for databases/mongodb5
Created attachment 239210 [details] patch for databases/mongodb6
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=fb2179e9408960e3715e49ef32cf1b71aed191f9 commit fb2179e9408960e3715e49ef32cf1b71aed191f9 Author: Borja Marcos <borjam@sarenet.es> AuthorDate: 2023-01-01 12:22:15 +0000 Commit: Ronald Klop <ronald@FreeBSD.org> CommitDate: 2023-01-03 12:05:18 +0000 databases/mongodb50: optionally support pre-AVX CPUs Upstream defaults to Sandybridge+ CPUs for amd64. It is reported to still work with older CPUs. No revision bump as the change does not impact the default build. PR: 268510 Approved by: rene (mentor) Differential Revision: https://reviews.freebsd.org/D37924 databases/mongodb50/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
Committed. Thanks for your work! I will piggyback the mongodb60 change on a future update of that port.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=146e6a4b49a196747bff0edbe6fee3f21069faa8 commit 146e6a4b49a196747bff0edbe6fee3f21069faa8 Author: Ronald Klop <ronald@FreeBSD.org> AuthorDate: 2023-01-03 13:46:13 +0000 Commit: Ronald Klop <ronald@FreeBSD.org> CommitDate: 2023-01-13 19:01:46 +0000 databases/mongodb60: update to 6.0.3 - Trivial version bump. - Mark IGNORE as it fails on runtime. Upstream has an issue on this open. (See: PR #267668) - Add option NOAVX to support building for older CPUs. (Thanks to Borja Marcos) - Make portmft/portlint/portclippy even more happy. PR: 268510 Approved by: rene (mentor) Differential Revision: https://reviews.freebsd.org/D38016 databases/mongodb60/Makefile | 23 ++++++++++++++--------- databases/mongodb60/distinfo | 6 +++--- 2 files changed, 17 insertions(+), 12 deletions(-)