From: Dirk Brenken Date: Mon, 10 Aug 2026 17:15:09 +0000 (+0200) Subject: adblock: fix cpu core calculation X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=9f8feb10a359d62bf51a5391b2c05ad9969a1d34;p=openwrt-packages.git adblock: fix cpu core calculation - only cap the cpu core count by available memory if it was auto-detected, a manually set 'adb_cores' is now authoritative and no longer lowered - readme update: clarify that the auto-cap does not apply to a manually set core count Signed-off-by: Dirk Brenken --- diff --git a/net/adblock/Makefile b/net/adblock/Makefile index 64c863725..bd9ea42d9 100644 --- a/net/adblock/Makefile +++ b/net/adblock/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=adblock PKG_VERSION:=4.5.7 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_LICENSE:=GPL-3.0-or-later PKG_MAINTAINER:=Dirk Brenken diff --git a/net/adblock/files/README.md b/net/adblock/files/README.md index db017d1a8..65252dfb1 100644 --- a/net/adblock/files/README.md +++ b/net/adblock/files/README.md @@ -180,7 +180,7 @@ The `report` sub-command accepts an output mode: `cli` (default, human-readable | adb_enabled | 1, enabled | set to 0 to disable the adblock service | | adb_feedfile | /etc/adblock/adblock.feeds | full path to the used adblock feed file | | adb_dns | -, auto-detected | `dnsmasq`, `unbound`, `named`, `kresd`, `smartdns` or `raw` | -| adb_cores | -, auto-detected | limit the cpu cores used by adblock to save RAM; auto-detected and capped to the available memory | +| adb_cores | -, auto-detected | limit the cpu cores used by adblock; only auto-detection is memory-capped | | adb_fetchcmd | -, auto-detected | `uclient-fetch`, `wget` or `curl` | | adb_fetchparm | -, auto-detected | manually override the config options for the selected download utility | | adb_fetchretry | 5 | number of download attempts in case of an error (not supported by uclient-fetch) | @@ -298,7 +298,7 @@ root@blackhole:~# /etc/init.d/adblock status **Recommendation for low memory systems** adblock keeps all working data in RAM to avoid unnecessary flash wear. The number of parallel processing jobs and the sort buffer size are automatically scaled to the available memory, so on constrained devices adblock already throttles itself during feed processing. On devices with only 128–256 MB RAM, you can further reduce memory pressure with the following optimizations: -* Limit CPU parallelism: the core count is auto-capped to the available memory; you can additionally set `adb_cores=1` to force single-threaded processing with minimal peak memory +* Limit CPU parallelism: the auto-detected core count is capped to the available memory; set `adb_cores=1` to force single-threaded processing with minimal peak memory. A manually set value is always used as-is — it is never lowered, so raising it on a constrained device is at your own risk * Use external storage: Set adb_basedir, adb_backupdir and adb_reportdir to a USB drive or SSD to offload temporary and persistent data * Enable blocklist shifting: Activate adb_dnsshift to store the generated blocklist on external storage and keep only a symlink in RAM * Use firewall‑based DNS redirection: Route DNS queries via nftables to external filtered DNS resolvers and keep only a minimal local blocklist active diff --git a/net/adblock/files/adblock.sh b/net/adblock/files/adblock.sh index 7ed0cb392..6be6f3a93 100755 --- a/net/adblock/files/adblock.sh +++ b/net/adblock/files/adblock.sh @@ -142,13 +142,16 @@ f_load() { "${adb_awkcmd}" 'BEGIN{RS="";FS="\n"}{printf "%s, %s, %s %s (%s)",$1,$2,$3,$4,$5}')" # detect cpu cores and available memory for memory-aware parallel processing + # 'mem_cores' is only calculated for auto-detected cores, a manually set 'adb_cores' is never capped # - [ -z "${adb_cores}" ] && adb_cores="$("${adb_grepcmd}" -cm16 '^processor' /proc/cpuinfo 2>>"${adb_errorlog}")" - case "${adb_cores}" in "" | 0 | *[!0-9]*) adb_cores="1" ;; esac free_mem="$(f_mem)" - mem_cores="$((${free_mem} / 48))" - [ "${mem_cores}" -lt "1" ] && mem_cores="1" - [ "${adb_cores}" -gt "1" ] && [ "${mem_cores}" -lt "${adb_cores}" ] && adb_cores="${mem_cores}" + if [ -z "${adb_cores}" ]; then + adb_cores="$("${adb_grepcmd}" -cm16 '^processor' /proc/cpuinfo 2>>"${adb_errorlog}")" + mem_cores="$((${free_mem} / 48))" + [ "${mem_cores}" -lt "1" ] && mem_cores="1" + fi + case "${adb_cores}" in "" | 0 | *[!0-9]*) adb_cores="1" ;; esac + [ -n "${mem_cores}" ] && [ "${mem_cores}" -lt "${adb_cores}" ] && adb_cores="${mem_cores}" # allocate at least 8 MiB of memory per core for sorting #