From 9b129c41ac1f43d373742697aa2faf6040b9dfab Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 23 Jan 2020 17:01:39 +0100 Subject: arch: use gperf to generate a perfact hash to lookup syscall names This patch significantly improves the performance of seccomp_syscall_resolve_name since it replaces the expensive strcmp for each syscall in the database, with a lookup table. The complexity for syscall_resolve_num is not changed and it uses the linear search, that is anyway less expensive than seccomp_syscall_resolve_name as it uses an index for comparison instead of doing a string comparison. On my machine, calling 1000 seccomp_syscall_resolve_name_arch and seccomp_syscall_resolve_num_arch over the entire syscalls DB passed from ~0.45 sec to ~0.06s. PM: After talking with Giuseppe I made a number of additional changes, some substantial, the highlights include: * various style tweaks * .gitignore fixes * fixed subject line, tweaked the description * dropped the arch-syscall-validate changes as they were masking other problems * extracted the syscalls.csv and file deletions to other patches to keep this one more focused * fixed the x86, x32, arm, all the MIPS ABIs, s390, and s390x ABIs as the syscall offsets were not properly incorporated into this change * cleaned up the ABI specific headers * cleaned up generate_syscalls_perf.sh and renamed to arch-gperf-generate * fixed problems with automake's file packaging Signed-off-by: Giuseppe Scrivano Reviewed-by: Tom Hromatka [PM: see notes in the "PM" section above] Signed-off-by: Paul Moore --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index e8b77f2..40d9dcb 100644 --- a/configure.ac +++ b/configure.ac @@ -119,6 +119,11 @@ AC_DEFINE_UNQUOTED([ENABLE_PYTHON], [$(test "$enable_python" = yes && echo 1 || echo 0)], [Python bindings build flag.]) +AC_CHECK_TOOL(GPERF, gperf) +if test -z "$GPERF"; then + AC_MSG_ERROR([please install gperf]) +fi + dnl #### dnl coverity checks dnl #### -- cgit v1.2.1