Repository navigation
Description
Summary
Loading a large wordlist peaks at about 150 bytes per entry and takes several seconds before the first query. The memory comes from several full copies of the list: raw lines, the Prepare index, the dispatcher's visited map, and a set rebuilt for each passive source and for -permute.
Where
internal/wordlist/reader.go:93-124(ReadLinesFromkeeps every raw line in a[]string)internal/wordlist/reader.go:146-168(Preparebuilds amap[string]intplusentriesandcounts)internal/scan/dispatcher.go:52,:136-150: avisitedmap sized to the whole list, built per target and per passmain_ct.go:84-117:withCTEntriesbuilds a fullhavemap on each call, andwithCTSeedscopies the seeds mapmain_permute.go:73-81:permutationCandidatesbuilds another fullskipmapmain_session.go:395-402,main_session.go:636-651
Details
Measured with the built binary on a synthetic 5M-line wordlist (54 MB) and -simulate -max-queries 1: 763 MB peak working set, 6.8 s before the first query finished.
- The
visitedmap alone costs about 218 MB and 1.3 s at 5M entries. - In non-recursive scans (the default) it never finds a duplicate: at depth 1 the key is the entry itself, and every caller already deduplicates
Entries(Prepare,withCTEntries,wordlist.Build). - Each full-list
map[string]bool(one per passive source, one for-axfr, one for-permute) costs about 1.2 s and 130 MB at 5M entries.
Impact
Lists of 9-10M lines (common public DNS wordlists) need about 1.5 GB and more than 10 s of startup per target. That risks OOM in 1-2 GB containers and CI runners, and -dL repeats the cost for every target.
Suggested fix
- Allocate and consult
visitedonly whencfg.Recursiveis set. Document thatEntriesmust be unique. - Normalize and deduplicate while streaming the file, so the raw
linesslice is never held. Make thePrepareindex the only set. - Build the entry set once per target, or expose
Prepared's index, and reuse it across sources, AXFR and permute.
Acceptance criteria
- Peak RSS for a 5M-line list with
-max-queries 1drops by at least 40%, as measured by a benchmark or a documented manual run. - No change in candidate order or deduplication results (existing wordlist and dispatcher tests pass).
Getting started
- Relevant files: listed above
- How to run tests:
go test ./internal/wordlist/ ./internal/scan/ .; benchmarks withgo test -run=^$ -bench=. ./internal/wordlist/ - Related docs:
docs/ARCHITECTURE.md
Filed by repo-audit/full-audit at 3f671b2. Severity: medium. Effort: M. audit-key: performance|internal/wordlist/reader.go|load-memory
Activity
Cut wordlist memory: stream -w, skip visited when flat (#248)
TMHSDigital commentedon Nov 14, 2026
Partial fix in 09b2475: all three steps from the issue are done.
-wfiles are normalized while they are read (wordlist.Preparer,EachLine), so the raw lines are never held.visitedset.candidatesset per target.Measured on a 5M-line list with
-simulate -max-queries 1(peak working set, 3 runs each):That is about 23% lower, short of the 40% acceptance criterion, so this stays open. The peak now comes from
Prepareitself: its dedupe index (map[string]int, one entry per unique label) coexists with the entries and counts slices while the list is read. Options for the rest:map[string]int32index andint32counts, worth roughly 10%;TMHSDigital commentedon Nov 14, 2026
Fixed in dddb5eb, which takes the remaining step after 09b2475.
Prepare'smap[string]intdedupe index is now an open-addressing table ofuint32positions that compares against the entries already held, and the per-entry counts areuint32.Peak working set of the built binary on a 5M-line list with
-simulate -max-queries 1(Windows, polled):That is about 38% below the previous HEAD and about 50% below the ~740 MB in the original report, so the 40% criterion is met.
BenchmarkBuild1Malso went from ~520 ms / 241 MB per op to ~380 ms / 126 MB per op.Order and dedupe results are unchanged: the existing wordlist and dispatcher tests pass, and the new
TestPrepareIndexAcrossGrowthchecks the index against the reference build across ~8 table doublings, with case-variant repeats.