Skip to content

Wordlist is re-normalized with a regex per label for every -dL target #182

Closed

Description

@TMHSDigital

Summary

The wordlist is re-normalised from raw lines for every target in a -dL run, with a regex match per label and a strings.Split per entry. On a 1M-line list that is about 0.8 s and 216 MB of garbage per target before any lookup starts.

Where

  • internal/wordlist/reader.go:16, 39-51 (labelRegex.MatchString per label, strings.Split per entry)
  • main.go:698 (probe Build), main.go:707 (resume Build), main.go:872 (Build again per target in the -dL loop), main.go:693 (raw []string retained for the run)

Details

Measurement Result
Build on 1M lines 774 ms, 216 MB allocated, 1.0M allocs per call
-simulate -w w1m.txt -max-queries 1, 1 target 2.24 s
same with -dL of 5 targets 8.02 s (about 1.45 s per extra target)
Peak RSS loading a 13 MB list 214 to 258 MB

The only per-target dependency is the 253-character FQDN length check; everything else is target-independent.

Impact

A -dL of 100 domains with a 1M list spends roughly 2.5 minutes and churns about 20 GB of allocations before scanning.

Steps to reproduce

go test -bench Build1M -benchmem on wordlist.Build with a 1M-line fixture; time -max-queries 1 with -dL of 1 vs 5 domains.

Suggested fix

Normalise once: a hand-rolled label validator instead of the regex, scan for dots instead of strings.Split, keep the normalised entries, and per target filter only on len(entry)+1+len(domain) > 253 (or compute maxEntryLen once and skip the pass when it cannot exceed the limit). Drop the probe Build at main.go:698 in favour of the first target's result and release the raw lines after normalising.

Acceptance criteria

  • Per-target cost for a 1M list under 50 ms after the first target
  • Build allocations reduced by at least 5x on the benchmark
  • Existing wordlist validation tests unchanged

Getting started

  • Relevant files: internal/wordlist/reader.go, main.go, main_wordlist.go
  • How to run tests: go test ./internal/wordlist/ .

Related: #56, #49


Filed by repo-audit/full-audit at 3139c44. Severity: medium. Effort: M. audit-key: performance|internal/wordlist/reader.go|Build

Activity

  1. added
    area: cli
    performance
    severity: medium
    on Nov 9, 2026
  2. TMHSDigital commented on Nov 9, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in 3e2cb2b: wordlist.Prepare normalizes once (hand-rolled label check, no regexp or Split) and Prepared.For applies only the per-target length limit. On 1M lines, Build went from 813 ms / 1.0M allocs to 524 ms / 8.3k allocs, and each further -dL target costs 0.5 ms with 0 allocs. Verified with a randomized equivalence test against the old regexp algorithm, the existing wordlist tests, go test -race ./... and golangci-lint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cliperformanceseverity: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions