Skip to content

Commit 01c00be

Browse files
committed
[Fix] Warn when scan_hashtype forces software SHA-256 on non-SHA-NI CPU
When scan_hashtype is explicitly set to "sha256" or "both" on a system without SHA-NI hardware acceleration, SHA-256 runs ~30% slower than MD5 in software. Previously this was silent — the admin had no indication their override was costing performance. Now logs a NOTICE (not a fallback — the admin's explicit choice is honored) when _sha_capability="software" and scan_hashtype is sha256 or both, advising them to consider scan_hashtype=auto. The default scan_hashtype=auto is unaffected — it already correctly selects SHA-256 only with hardware support and MD5 otherwise.
1 parent 6449d62 commit 01c00be

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

files/internals/lmd_init.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ _resolve_hashtype() {
5959
eout "{scan} WARNING: scan_hashtype=sha256 but sha256sum not found, falling back to md5" 1
6060
_effective_hashtype="md5"
6161
else
62+
if [ "$_sha_capability" == "software" ]; then
63+
eout "{scan} NOTICE: scan_hashtype=sha256 without hardware SHA-NI — software SHA-256 is ~30% slower than MD5; consider scan_hashtype=auto" 1
64+
fi
6265
_effective_hashtype="sha256"
6366
fi
6467
;;
@@ -67,6 +70,9 @@ _resolve_hashtype() {
6770
eout "{scan} WARNING: scan_hashtype=both but sha256sum not found, falling back to md5" 1
6871
_effective_hashtype="md5"
6972
else
73+
if [ "$_sha_capability" == "software" ]; then
74+
eout "{scan} NOTICE: scan_hashtype=both without hardware SHA-NI — SHA-256 pass will use slower software hashing" 1
75+
fi
7076
_effective_hashtype="both"
7177
fi
7278
;;

0 commit comments

Comments
 (0)