Lionel Debroux - 2024-05-04

There's a drawback to memoizing the output of strings, though: DoS upon huge rcfiles...
Here's another take on optimizing the possible_rkt_strings check, which no longer memoizes anything. I split the work between a fast path which tries to find all strings at once in every rcfile, and a slow path if the first check returns at least one match.

Core i7-6700 HQ (SMP, SMT disabled), 32 GB DDR4-2133, Debian sid amd64, cache hot:
before: \time rkhunter_ --cronjob --report-warnings-only --enable possible_rkt_strings 44.21user 37.16system 0:45.80elapsed 177%CPU (0avgtext+0avgdata 16116maxresident)k 0inputs+80outputs (23major+7266578minor)pagefaults 0swaps

changes from #186 + changes from this patch: \time rkhunter --cronjob --report-warnings-only --enable possible_rkt_strings 6.22user 3.40system 0:07.61elapsed 126%CPU (0avgtext+0avgdata 16116maxresident)k 0inputs+96outputs (0major+1088480minor)pagefaults 0swaps

PIII 1 GHz (UP), 256 MB RAM, Debian sid amd64, cache hot:
before: \time rkhunter --cronjob --report-warnings-only --enable possible_rkt_strings 49.05user 165.23system 3:39.00elapsed 97%CPU (0avgtext+0avgdata 8448maxresident)k 1128inputs+128outputs (0major+4008509minor)pagefaults 0swaps

changes from #186 + changes from this patch: \time rkhunter --cronjob --report-warnings-only --enable possible_rkt_strings 12.58user 32.50system 0:46.05elapsed 97%CPU (0avgtext+0avgdata 8704maxresident)k 0inputs+80outputs (0major+831752minor)pagefaults 0swaps

Nearly 30" saved on the former, nearly 3' on the latter.

This version of the patch also contains minor optimizations in other tests.