This is a new port for hyperscan, intel's optimized regex library,
which amongst other things can be used with rspamd to reduce runtime
load. It needs cpu-specific optimization (ssse3 is required and will
work on most machines that run amd64, there are a couple of other
options).

The method on linux is to build with all of them and link them all,
runtime uses "a CPUID check for the presence of the instruction set,
and then an indirect function is resolved so that the right version of
each API function is used" - I am using the low-tech method of
separate builds and a flavour to select the right one.

tar attached, OK to import? If someone using rspamd wants to test,
here's a diff for that.



Index: Makefile
===================================================================
RCS file: /cvs/ports/mail/Makefile,v
retrieving revision 1.398
diff -u -p -r1.398 Makefile
--- Makefile    17 Jan 2021 21:27:56 -0000      1.398
+++ Makefile    2 Feb 2021 21:36:13 -0000
@@ -217,6 +217,7 @@
      SUBDIR += roundcubemail
      SUBDIR += rmilter
      SUBDIR += rspamd
+     SUBDIR += rspamd,hyperscan
      SUBDIR += rss2email
      SUBDIR += ruby-mail
      SUBDIR += ruby-mime
Index: rspamd/Makefile
===================================================================
RCS file: /cvs/ports/mail/rspamd/Makefile,v
retrieving revision 1.89
diff -u -p -r1.89 Makefile
--- rspamd/Makefile     9 Jan 2021 12:50:09 -0000       1.89
+++ rspamd/Makefile     2 Feb 2021 21:36:13 -0000
@@ -5,6 +5,7 @@ COMMENT=        event-driven spam filtering sys
 GH_ACCOUNT=    vstakhov
 GH_PROJECT=    rspamd
 GH_TAGNAME=    2.7
+REVISION=      0
 
 CATEGORIES=    mail
 
@@ -19,10 +20,16 @@ WANTLIB += ${COMPILER_LIBCXX}
 WANTLIB += blas c crypto glib-2.0 icudata icui18n icuuc intl m
 WANTLIB += pcre sodium sqlite3 ssl util z
 
-FLAVORS=       no_luajit
-.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
+FLAVORS=       no_luajit hyperscan
+.if ${MACHINE_ARCH} == "amd64"
+# amd64: any flavour
 FLAVOR?=
+.elif ${MACHINE_ARCH} == "i386"
+# i386: no_luajit or unflavoured
+FLAVOR?=
+FLAVOR:=       ${FLAVOR:Nhyperscan}
 .else
+# others: no_luajit only
 FLAVOR=                no_luajit
 .endif
 
@@ -73,6 +80,12 @@ WANTLIB+=    ${MODLUA_WANTLIB}
 .else
 LIB_DEPENDS+=  lang/luajit
 WANTLIB+=      luajit-5.1
+.endif
+
+.if ${FLAVOR:Mhyperscan}
+CONFIGURE_ARGS+= -DENABLE_HYPERSCAN=ON
+LIB_DEPENDS+=  textproc/hyperscan
+WANTLIB+=      hs
 .endif
 
 # Make sure you have no rspamd or redis instances running and note that the
Index: rspamd/pkg/DESCR
===================================================================
RCS file: /cvs/ports/mail/rspamd/pkg/DESCR,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 DESCR
--- rspamd/pkg/DESCR    9 Oct 2015 16:09:17 -0000       1.1.1.1
+++ rspamd/pkg/DESCR    2 Feb 2021 21:36:13 -0000
@@ -7,3 +7,10 @@ According to this spam score and the use
 for the MTA to apply to the message- for example to pass, reject or add a
 header. Rspamd is designed to process hundreds of messages per second
 simultaneously and has a number of features available.
+
+Some flavours are available, depending on the machine architecture:
+
+       no_luajit       Disable luajit, available on all architectures
+       (unflavoured)   Enable luajit, available on amd64/i386
+       hyperscan       Use Intel's hyperscan library, available on amd64,
+                       requires certain CPU features.




----- End forwarded message -----

Attachment: hyperscan.tgz
Description: application/tar-gz

Reply via email to