Browse Source

pcre2: Add JIT-support for select architectures in PCRE2

- This commit adds a config-option for JIT in libpcre2.

  According to research published on
  https://rust-leipzig.github.io/regex/2017/03/28/comparison-of-regex-engines/
  this should give a 10x performance increase on JIT operations
  which can be desireable for high performance Apache mod_rewrite
  or haproxy reqrep operations.

  This option is available on all officially supported architecutres
  which are listed on https://pcre.org/current/doc/html/pcre2jit.html#SEC2.
  Furthermore, it is enabled by default on the following
  architectures: arm, i686, x86_64.

Signed-off-by: Christian Lachner <gladiac@gmail.com>
lilik-openwrt-22.03
Christian Lachner 5 years ago
parent
commit
21bee17652
2 changed files with 40 additions and 2 deletions
  1. +30
    -0
      libs/pcre2/Config.in
  2. +10
    -2
      libs/pcre2/Makefile

+ 30
- 0
libs/pcre2/Config.in View File

@ -0,0 +1,30 @@
config PCRE2_JIT_ENABLED
bool
depends on PACKAGE_libpcre2 && (aarch64 || aarch64_be || arm || i386 || i686 || x86_64 || mips || mipsel || mips64 || mips64el || powerpc || powerpc64 || powerpcle || sparc)
default y if (arm || i686 || x86_64)
prompt "Enable JIT compiler support"
help
Enable JIT (Just-In-Time) compiler support.
Just-in-time compiling is a heavyweight optimization that can greatly
speed up pattern matching. However, it comes at the cost of extra
processing before the match is performed, so it is of most benefit when
the same pattern is going to be matched many times. This does not
necessarily mean many calls of a matching function; if the pattern is
not anchored, matching attempts may take place many times at various
positions in the subject, even for a single call. Therefore, if the
subject string is very long, it may still pay to use JIT even for
one-off matches. JIT support is available for all of the 8-bit, 16-bit
and 32-bit PCRE2 libraries and adds about 100KB to the resulting
libpcre2.so. JIT support applies only to the traditional Perl-compatible
matching function. It does not apply when the DFA matching function is
being used.
Enabling this option can give an about 10x performance increase on JIT
operations. It can be desireable for e.g. high performance Apache
mod_rewrite or HA-Proxy reqrep operations.
However, JIT should _only_ be enabled on architectures that are supported.
Enabling JIT on unsupported platforms will result in a compilation
failure. A list of supported architectures can be found here:
https://pcre.org/current/doc/html/pcre2jit.html#SEC2

+ 10
- 2
libs/pcre2/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=pcre2
PKG_VERSION:=10.32
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=@SF/pcre/$(PKG_NAME)/$(PKG_VERSION)
@ -25,6 +25,9 @@ PKG_FIXUP:=autoreconf
PKG_BUILD_PARALLEL:=1
PKG_INSTALL:=1
PKG_CONFIG_DEPENDS:=\
CONFIG_PCRE2_JIT_ENABLED
include $(INCLUDE_DIR)/package.mk
define Package/libpcre2/default
@ -33,6 +36,10 @@ define Package/libpcre2/default
URL:=https://www.pcre.org/
endef
define Package/libpcre2/config
source "$(SOURCE)/Config.in"
endef
define Package/libpcre2
$(call Package/libpcre2/default)
TITLE:=A Perl Compatible Regular Expression library
@ -53,7 +60,8 @@ TARGET_CFLAGS += $(FPIC)
CONFIGURE_ARGS += \
--enable-pcre2-16 \
--enable-pcre2-32
--enable-pcre2-32 \
$(if $(CONFIG_PCRE2_JIT_ENABLED),--enable-jit,--disable-jit)
MAKE_FLAGS += \
CFLAGS="$(TARGET_CFLAGS)"


Loading…
Cancel
Save