]> git.99rst.org Git - openwrt-packages.git/commitdiff
adblock: fix cpu core calculation
authorDirk Brenken <redacted>
Mon, 10 Aug 2026 17:15:09 +0000 (19:15 +0200)
committerDirk Brenken <redacted>
Mon, 10 Aug 2026 17:15:29 +0000 (19:15 +0200)
- 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 <redacted>
net/adblock/Makefile
net/adblock/files/README.md
net/adblock/files/adblock.sh

index 64c863725105c21a860284bcd2c6f8280383da2d..bd9ea42d95b8f9172a3ed57d44f1cfd58fa3b2fe 100644 (file)
@@ -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 <dev@brenken.org>
 
index db017d1a89f3e90f4b22c5f25d6683d4f3c75dd5..65252dfb17ab35b2f1e182f2315a2630f2cfabfa 100644 (file)
@@ -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
index 7ed0cb39262d2fe883db7363b326b26b0f80a465..6be6f3a9389752a272f1d0acaa1ccd5e630010a6 100755 (executable)
@@ -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
        #
git clone https://git.99rst.org/PROJECT