## Case-insensitive matching helpers
`EqualFold`, `IndexFold`, `ContainsFold`, `HasPrefixFold`, and
`HasSuffixFold` compare ASCII case-insensitively using the SWAR word
loops: only `A`..`Z`/`a`..`z` fold, every other byte (including bytes
>= 0x80) must match exactly. `HasPrefixFold` and `HasSuffixFold` cover
the header checks Fiber otherwise spells as an allocation-prone
`ToLower` + `HasPrefix`/`HasSuffix` pair (authorization schemes such as
`Bearer`, content-type prefixes such as `multipart/form-data`, suffixes
such as `+json`), and like the other Fold helpers they take the needle
as a plain string because call sites pass constant tokens. Their
`Benchmark_HasPrefixFold`/`Benchmark_HasSuffixFold` numbers are tracked
on the [benchmark charts](https://gofiber.github.io/utils/benchmarks/)
and join the catalog above on its next regeneration.
## HTTP dates
`AppendHTTPDate` and `FormatHTTPDate` write a time in the RFC 9110
preferred HTTP date format (`Mon, 02 Jan 2006 15:04:05 GMT`,
`net/http.TimeFormat`), byte-identical to `time.Format` with that layout
but without walking a layout string: the calendar fields come from one
civil-date conversion of `t.Unix()` (Hinnant's era arithmetic, instead of
the three `abs()` walks behind `Date`, `Clock`, and `Weekday`), and are
written into the fixed-width template with two-digit table lookups.
`ParseHTTPDate` is the reverse: canonical preferred-format input takes a
strict scalar fast path whose validated fields feed `time.Unix` directly
— the same `Time` value `time.Date` builds, minus its normalization pass —
and everything else — the obsolete RFC 850 and asctime forms, unusual
casing, non-GMT zone names, padding — falls back to `time.Parse` with
`net/http.ParseTime` semantics, including its errors. Both directions are
pinned to the `time` package by a day-by-day sweep over the years
0..9999. `Date`, `Last-Modified`, and `If-Modified-Since` handling sit on
every request/response, which makes these the highest-leverage helpers in
this group for Fiber.
## URL escaping
`AppendQueryEscape`/`AppendPathEscape` and
`AppendQueryUnescape`/`AppendPathUnescape` produce byte-identical results
(and, for the unescape pair, identical `url.EscapeError` values) to their
`net/url` counterparts, as append-style, allocation-free single passes.
The escape tables are pinned to `net/url.shouldEscape` by exhaustive
per-byte tests. Unescaping jumps between escape sites with the vectorized
scans (`IndexAny2` when `+` needs rewriting, `bytes.IndexByte` otherwise)
and copies clean spans wholesale, so route parameters and query values
without escapes — the common case — cost one scan and one copy. Decoding
never grows the input, so `dst` may be `s[:0]` on a common backing array
to unescape in place; escaping can grow the input, so there `dst` must
not alias `s`.
## JSON string escaping
`AppendJSONString` appends a value as a double-quoted JSON string,
byte-identical to `encoding/json.Marshal` of the same string — including
its default HTML escaping (`<`, `>`, `&`), the `\ufffd` replacement of
invalid UTF-8 bytes, and the U+2028/U+2029 escapes — without any of
`Marshal`'s reflection or allocation. Clean spans are located with a SWAR
scan (the same first-match-mask technique as `IndexNonQuotable`) and
copied wholesale. This is the building block for hand-rolled JSON hot
paths such as access-log lines and error bodies.
## IP address parsing
`ParseIPv4` and `ParseIPv6` parse addresses into `netip.Addr`, accepting
exactly the strings `netip.ParseAddr` accepts for the respective family
(pinned by fuzzing) while reporting failure with a `bool` instead of a
constructed error. Both take strings or byte slices, so fasthttp-style
callers skip the `string` conversion entirely; remote-address and
trusted-proxy checks parse an IP on every request in Fiber.
## Header key canonicalization
`CanonicalHeaderKey` Title-Cases an HTTP header key exactly like
`net/http.CanonicalHeaderKey`, including its return-unchanged guard for
keys containing non-token bytes. Already-canonical keys — the common case
on receive paths — are validated in a single table pass and returned
as-is with zero allocations for strings and byte slices alike. Keys that
do need rewriting cost one allocation; note that for the ~40 header names
in the stdlib's interning table the stdlib returns a cached string
without allocating, so this helper's edge there is time, not allocations.
## Control-byte scanning
`IndexControl` returns the index of the first ASCII control byte — a byte
below 0x20 or DEL (0x7F), the RFC 5234 CTL set — and `IndexControlExceptTab`
is the same scan with HTAB permitted, which is the byte set an RFC 9110
field value may not contain. Both are SWAR first-match scans
(two words per branch, one overlapping word for the tail) over strings or
byte slices; the HTAB exemption is tested only in words that hold a
control byte, so clean input costs the same either way. They never match
bytes >= 0x80, so unlike
`strings.IndexFunc(s, unicode.IsControl)` they neither decode UTF-8 nor
flag the C1 range hidden inside it. Fiber spells this check by hand in
half a dozen places — header values before they are echoed, request IDs,
`Location` values, log fields, Basic auth credentials — and each copy is
one of these two calls.
## Byte-separator cuts
`CutByte` and `LastCutByte` are `strings.Cut`/`bytes.Cut` for a single
byte separator, around its first or last occurrence, generic over strings
and byte slices. They return the two parts and a found flag exactly like
the stdlib pair (including the `""`/`nil` after-part of a miss), cost one
`IndexByte`/`LastIndexByte`, and spare `[]byte` callers the `[]byte{sep}`
needle and the length dispatch inside `bytes.Index`. `CutByte` beats
`strings.Cut`; `LastCutByte` has no stdlib counterpart, so its row is
measured against a hand-written `LastIndexByte` split, which it trails by
the cost of the call — its value is the generic `[]byte` support and the
readable spelling. Header parameter splits (`;`), `key=value` pairs, and
host/port and name/extension splits are the intended call sites.
## Host and port splitting
`SplitHostPort` splits `host:port`, `host%zone:port`, `[host]:port`, and
`[host%zone]:port` with exactly `net.SplitHostPort`'s acceptance rules
(pinned by fuzzing against it), but reports failure with a `bool` instead
of constructing a `*net.AddrError`, and accepts byte slices. Valid input
costs the same as the stdlib — the scan is the same three `IndexByte`
calls — so the win is on the rejection path, where a malformed `Host` or
`Forwarded` value no longer costs an allocation, and on `[]byte` input,
which no longer needs a string conversion first.
## List field iteration
`SplitTrimSeq` returns an iterator over the elements of a list separated
by one byte, with ASCII whitespace trimmed from each element and empty
elements skipped — how HTTP list fields such as `Accept-Encoding`,
`Connection`, `Vary`, and `Cache-Control` are read (RFC 9110 Section
5.6.1: optional whitespace around the commas, empty elements ignored).
It replaces the `strings.SplitSeq` + `TrimSpace` + emptiness-check
triplet, locates each separator with a single `IndexByte`, works on
strings and byte slices alike, and yields subslices without copying. In
an ordinary caller the iterator inlines and allocates nothing, like
`strings.SplitSeq`; the benchmark ranges inside a helper function for
that reason, because calls made directly inside a `b.Loop` body are
never inlined and would show the closure allocations instead.
## Duration formatting
`AppendDuration` renders a `time.Duration` exactly as `d.String()` does —
"72h3m0.5s", "1.5ms", "0s" — into the caller's buffer, with the two-digit
table for the field digits; a value with no fraction, the common case,
never touches the fraction digits. `d.String()` allocates its result and
`fmt.Fprintf("%v", d)`, which Fiber's logger uses for the latency column,
costs several times more on top; an append-style form makes per-request
duration rendering (access logs, `Server-Timing`) allocation-free.
## Decimal formatting
`FormatUint`/`FormatInt` (and their 32- and 16-bit variants) and
`AppendUint`/`AppendInt` render integers eight digits at a time: a value
below 1e8 becomes eight zero-padded digit lanes through a fixed sequence
of multiplies, shifts, and masks (the SWAR inverse of the 8-digit parse
step in `ParseInt`), so a 64-bit value costs at most three such
conversions and two divisions, all independent of each other, instead of
one dependent divide-and-store per digit; the first significant digit is
found with a trailing-zero count. Values below 100 come from a
precomputed table, and the output is pinned to `strconv` by a dense sweep
plus every decimal and lane-group boundary. `GetMIME` in the same spirit
looks up extensions through a hash table keyed by the extension packed
into one lower-cased word with its length in the top lane, so a hit is a
multiply, a shift, and one slot comparison, with no allocation even for
upper-case input.
These helpers were added on an amd64 machine, so like the `simd` numbers
their benchmarks are recorded separately from the arm64 catalog above and
join it on its next regeneration. The block also carries the current
numbers for the paths reworked on the same machine (integer formatting,
`GetMIME`, token-sized `EqualFold`), whose arm64 rows above predate that
work:
Environment:
goos: linux
goarch: amd64
pkg: github.com/gofiber/utils/v2
cpu: Intel(R) Xeon(R) Processor @ 2.80GHz
```text
// go test -benchmem -run=^$ -count=1 . -bench='^Benchmark_(FormatUint|FormatInt|FormatUint32|FormatInt32|FormatUint16|FormatInt16|AppendUint|AppendInt|EqualFold_Short|GetMIME|AppendHTTPDate|ParseHTTPDate|AppendDuration|AppendQueryEscape|AppendQueryUnescape|AppendPathUnescape|AppendJSONString|ParseIPv4|ParseIPv6|CanonicalHeaderKey|IndexControl|CutByte|LastCutByte|SplitHostPort|SplitTrimSeq)$'
Benchmark_EqualFold_Short/3B/fiber-4 229602248 5.312 ns/op 0 B/op 0 allocs/op
Benchmark_EqualFold_Short/3B/default-4 204528979 5.852 ns/op 0 B/op 0 allocs/op
Benchmark_EqualFold_Short/4B/fiber-4 229813917 5.255 ns/op 0 B/op 0 allocs/op
Benchmark_EqualFold_Short/4B/default-4 156456847 7.464 ns/op 0 B/op 0 allocs/op
Benchmark_EqualFold_Short/5B/fiber-4 229097964 5.234 ns/op 0 B/op 0 allocs/op
Benchmark_EqualFold_Short/5B/default-4 197214793 6.189 ns/op 0 B/op 0 allocs/op
Benchmark_EqualFold_Short/7B/fiber-4 232463892 5.179 ns/op 0 B/op 0 allocs/op
Benchmark_EqualFold_Short/7B/default-4 160397131 7.450 ns/op 0 B/op 0 allocs/op
Benchmark_EqualFold_Short/8B/fiber-4 216077086 5.531 ns/op 0 B/op 0 allocs/op
Benchmark_EqualFold_Short/8B/default-4 159104245 7.543 ns/op 0 B/op 0 allocs/op
Benchmark_EqualFold_Short/10B/fiber-4 144306822 8.317 ns/op 0 B/op 0 allocs/op
Benchmark_EqualFold_Short/10B/default-4 120878482 9.925 ns/op 0 B/op 0 allocs/op
Benchmark_EqualFold_Short/16B/fiber-4 143038372 8.357 ns/op 0 B/op 0 allocs/op
Benchmark_EqualFold_Short/16B/default-4 85405070 14.49 ns/op 0 B/op 0 allocs/op
Benchmark_IndexControl/clean-16B/fiber-4 169144147 7.146 ns/op 0 B/op 0 allocs/op
Benchmark_IndexControl/clean-16B/fiber-except-tab-4 167529128 7.135 ns/op 0 B/op 0 allocs/op
Benchmark_IndexControl/clean-16B/default-4 32870788 36.35 ns/op 0 B/op 0 allocs/op
Benchmark_IndexControl/clean-64B/fiber-4 75379568 16.27 ns/op 0 B/op 0 allocs/op
Benchmark_IndexControl/clean-64B/fiber-except-tab-4 73955293 16.14 ns/op 0 B/op 0 allocs/op
Benchmark_IndexControl/clean-64B/default-4 8875356 135.6 ns/op 0 B/op 0 allocs/op
Benchmark_IndexControl/ctl-at-end-64B/fiber-4 72450939 16.83 ns/op 0 B/op 0 allocs/op
Benchmark_IndexControl/ctl-at-end-64B/fiber-except-tab-4 71671362 16.68 ns/op 0 B/op 0 allocs/op
Benchmark_IndexControl/ctl-at-end-64B/default-4 8478050 141.1 ns/op 0 B/op 0 allocs/op
Benchmark_CutByte/fiber-4 180741241 6.688 ns/op 0 B/op 0 allocs/op
Benchmark_CutByte/default-4 100000000 10.28 ns/op 0 B/op 0 allocs/op
Benchmark_CutByte/fiber-bytes-4 168499478 7.147 ns/op 0 B/op 0 allocs/op
Benchmark_CutByte/default-bytes-4 141645026 8.407 ns/op 0 B/op 0 allocs/op
Benchmark_LastCutByte/fiber-4 190695121 6.336 ns/op 0 B/op 0 allocs/op
Benchmark_LastCutByte/default-4 201893814 5.937 ns/op 0 B/op 0 allocs/op
Benchmark_AppendDuration/micros/fiber-4 94853876 12.96 ns/op 0 B/op 0 allocs/op
Benchmark_AppendDuration/micros/default-4 37404410 30.76 ns/op 8 B/op 1 allocs/op
Benchmark_AppendDuration/micros/fmt-4 9448436 127.8 ns/op 16 B/op 2 allocs/op
Benchmark_AppendDuration/millis-frac/fiber-4 57206034 20.25 ns/op 0 B/op 0 allocs/op
Benchmark_AppendDuration/millis-frac/default-4 28241080 39.08 ns/op 16 B/op 1 allocs/op
Benchmark_AppendDuration/millis-frac/fmt-4 8029897 144.3 ns/op 24 B/op 2 allocs/op
Benchmark_AppendDuration/hours/fiber-4 77311298 15.06 ns/op 0 B/op 0 allocs/op
Benchmark_AppendDuration/hours/default-4 26855806 42.60 ns/op 8 B/op 1 allocs/op
Benchmark_AppendDuration/hours/fmt-4 8546384 146.6 ns/op 16 B/op 2 allocs/op
Benchmark_FormatUint/small/fiber-4 629069014 1.888 ns/op 0 B/op 0 allocs/op
Benchmark_FormatUint/small/strconv-4 505295925 2.371 ns/op 0 B/op 0 allocs/op
Benchmark_FormatUint/medium/fiber-4 40310542 28.33 ns/op 16 B/op 1 allocs/op
Benchmark_FormatUint/medium/strconv-4 36065356 33.07 ns/op 16 B/op 1 allocs/op
Benchmark_FormatUint/large/fiber-4 36428881 33.66 ns/op 24 B/op 1 allocs/op
Benchmark_FormatUint/large/strconv-4 24582408 49.04 ns/op 24 B/op 1 allocs/op
Benchmark_FormatInt/small_pos/fiber-4 568438807 2.074 ns/op 0 B/op 0 allocs/op
Benchmark_FormatInt/small_pos/strconv-4 509641584 2.378 ns/op 0 B/op 0 allocs/op
Benchmark_FormatInt/small_neg/fiber-4 552536096 2.169 ns/op 0 B/op 0 allocs/op
Benchmark_FormatInt/small_neg/strconv-4 67741922 18.14 ns/op 3 B/op 1 allocs/op
Benchmark_FormatInt/medium_pos/fiber-4 36409581 28.36 ns/op 16 B/op 1 allocs/op
Benchmark_FormatInt/medium_pos/strconv-4 34719836 34.57 ns/op 16 B/op 1 allocs/op
Benchmark_FormatInt/medium_neg/fiber-4 43244299 27.74 ns/op 16 B/op 1 allocs/op
Benchmark_FormatInt/medium_neg/strconv-4 36308307 33.28 ns/op 16 B/op 1 allocs/op
Benchmark_FormatInt/large_pos/fiber-4 34108224 34.78 ns/op 24 B/op 1 allocs/op
Benchmark_FormatInt/large_pos/strconv-4 23271465 49.00 ns/op 24 B/op 1 allocs/op
Benchmark_FormatInt/large_neg/fiber-4 35237299 34.85 ns/op 24 B/op 1 allocs/op
Benchmark_FormatInt/large_neg/strconv-4 24433351 47.63 ns/op 24 B/op 1 allocs/op
Benchmark_FormatUint32/fiber-4 46063810 26.37 ns/op 16 B/op 1 allocs/op
Benchmark_FormatUint32/strconv-4 34846262 33.88 ns/op 16 B/op 1 allocs/op
Benchmark_FormatInt32/fiber-4 42975921 27.59 ns/op 16 B/op 1 allocs/op
Benchmark_FormatInt32/strconv-4 36954268 33.17 ns/op 16 B/op 1 allocs/op
Benchmark_FormatUint16/fiber-4 60632233 19.36 ns/op 5 B/op 1 allocs/op
Benchmark_FormatUint16/strconv-4 51189382 22.75 ns/op 5 B/op 1 allocs/op
Benchmark_FormatInt16/fiber-4 55760065 20.90 ns/op 8 B/op 1 allocs/op
Benchmark_FormatInt16/strconv-4 48868172 24.20 ns/op 8 B/op 1 allocs/op
Benchmark_AppendUint/fiber-4 91578640 12.35 ns/op 0 B/op 0 allocs/op
Benchmark_AppendUint/strconv-4 72172658 17.55 ns/op 0 B/op 0 allocs/op
Benchmark_AppendInt/small_neg/fiber-4 314797556 3.782 ns/op 0 B/op 0 allocs/op
Benchmark_AppendInt/small_neg/strconv-4 100000000 10.91 ns/op 0 B/op 0 allocs/op
Benchmark_AppendInt/medium_neg/fiber-4 91859277 13.20 ns/op 0 B/op 0 allocs/op
Benchmark_AppendInt/medium_neg/strconv-4 70492820 17.12 ns/op 0 B/op 0 allocs/op
Benchmark_CanonicalHeaderKey/canonical/fiber-4 66962880 17.98 ns/op 0 B/op 0 allocs/op
Benchmark_CanonicalHeaderKey/canonical/default-4 46076755 26.65 ns/op 0 B/op 0 allocs/op
Benchmark_CanonicalHeaderKey/common-lower/fiber-4 28066642 44.43 ns/op 16 B/op 1 allocs/op
Benchmark_CanonicalHeaderKey/common-lower/default-4 23367423 50.83 ns/op 0 B/op 0 allocs/op
Benchmark_CanonicalHeaderKey/custom-lower/fiber-4 20437851 58.07 ns/op 24 B/op 1 allocs/op
Benchmark_CanonicalHeaderKey/custom-lower/default-4 13395525 87.34 ns/op 24 B/op 1 allocs/op
Benchmark_SplitHostPort/host-port/fiber-4 66885448 17.17 ns/op 0 B/op 0 allocs/op
Benchmark_SplitHostPort/host-port/default-4 73398602 16.60 ns/op 0 B/op 0 allocs/op
Benchmark_SplitHostPort/ipv6-port/fiber-4 69142788 17.70 ns/op 0 B/op 0 allocs/op
Benchmark_SplitHostPort/ipv6-port/default-4 68252304 17.28 ns/op 0 B/op 0 allocs/op
Benchmark_SplitHostPort/missing-port/fiber-4 167778152 7.224 ns/op 0 B/op 0 allocs/op
Benchmark_SplitHostPort/missing-port/default-4 30424182 38.16 ns/op 32 B/op 1 allocs/op
Benchmark_GetMIME/fiber-4 39471765 29.38 ns/op 0 B/op 0 allocs/op
Benchmark_GetMIME/default-4 10284040 112.3 ns/op 0 B/op 0 allocs/op
Benchmark_AppendHTTPDate/fiber-4 47681026 25.21 ns/op 0 B/op 0 allocs/op
Benchmark_AppendHTTPDate/default-4 8757169 134.9 ns/op 0 B/op 0 allocs/op
Benchmark_ParseHTTPDate/fiber-4 58871844 18.57 ns/op 0 B/op 0 allocs/op
Benchmark_ParseHTTPDate/default-4 6421057 187.1 ns/op 0 B/op 0 allocs/op
Benchmark_ParseIPv4/fiber-4 66056898 18.34 ns/op 0 B/op 0 allocs/op
Benchmark_ParseIPv4/default-4 44932904 26.84 ns/op 0 B/op 0 allocs/op
Benchmark_ParseIPv6/compressed/fiber-4 25820896 46.48 ns/op 0 B/op 0 allocs/op
Benchmark_ParseIPv6/compressed/default-4 17371059 65.48 ns/op 0 B/op 0 allocs/op
Benchmark_ParseIPv6/full/fiber-4 20636487 60.00 ns/op 0 B/op 0 allocs/op
Benchmark_ParseIPv6/full/default-4 12097987 84.13 ns/op 0 B/op 0 allocs/op
Benchmark_AppendJSONString/clean-16B/fiber-4 57606924 21.13 ns/op 0 B/op 0 allocs/op
Benchmark_AppendJSONString/clean-16B/default-4 8575510 143.9 ns/op 40 B/op 2 allocs/op
Benchmark_AppendJSONString/clean-64B/fiber-4 20014062 60.74 ns/op 0 B/op 0 allocs/op
Benchmark_AppendJSONString/clean-64B/default-4 5525064 222.1 ns/op 96 B/op 2 allocs/op
Benchmark_AppendJSONString/escaped-64B/fiber-4 7843610 149.5 ns/op 0 B/op 0 allocs/op
Benchmark_AppendJSONString/escaped-64B/default-4 4009515 291.9 ns/op 96 B/op 2 allocs/op
Benchmark_AppendJSONString/unicode-64B/fiber-4 4916204 239.6 ns/op 0 B/op 0 allocs/op
Benchmark_AppendJSONString/unicode-64B/default-4 3485493 347.0 ns/op 112 B/op 2 allocs/op
Benchmark_SplitTrimSeq/accept-encoding/fiber-4 54431074 21.50 ns/op 0 B/op 0 allocs/op
Benchmark_SplitTrimSeq/accept-encoding/default-4 50593407 24.16 ns/op 0 B/op 0 allocs/op
Benchmark_SplitTrimSeq/accept/fiber-4 19936736 59.24 ns/op 0 B/op 0 allocs/op
Benchmark_SplitTrimSeq/accept/default-4 18168722 65.87 ns/op 0 B/op 0 allocs/op
Benchmark_AppendQueryEscape/clean-64B/fiber-4 25016198 49.70 ns/op 0 B/op 0 allocs/op
Benchmark_AppendQueryEscape/clean-64B/default-4 6857455 176.6 ns/op 0 B/op 0 allocs/op
Benchmark_AppendQueryEscape/mixed-64B/fiber-4 5858684 213.5 ns/op 0 B/op 0 allocs/op
Benchmark_AppendQueryEscape/mixed-64B/default-4 1989934 600.0 ns/op 192 B/op 2 allocs/op
Benchmark_AppendQueryUnescape/plain-64B/fiber-4 76538192 15.30 ns/op 0 B/op 0 allocs/op
Benchmark_AppendQueryUnescape/plain-64B/default-4 10383134 116.5 ns/op 0 B/op 0 allocs/op
Benchmark_AppendQueryUnescape/escaped-64B/fiber-4 4906606 218.5 ns/op 0 B/op 0 allocs/op
Benchmark_AppendQueryUnescape/escaped-64B/default-4 4306238 274.6 ns/op 48 B/op 1 allocs/op
Benchmark_AppendPathUnescape/plain-25B/fiber-4 100000000 12.00 ns/op 0 B/op 0 allocs/op
Benchmark_AppendPathUnescape/plain-25B/default-4 24661267 45.81 ns/op 0 B/op 0 allocs/op
Benchmark_AppendPathUnescape/escaped-31B/fiber-4 20543667 58.60 ns/op 0 B/op 0 allocs/op
Benchmark_AppendPathUnescape/escaped-31B/default-4 8119328 147.5 ns/op 24 B/op 1 allocs/op
```
## SWAR primitives
The [`swar`](swar/) package exports the SWAR (SIMD within a register)
building blocks the helpers above are composed from: `Load8`/`Store8`,
`Broadcast`, `ZeroLanes`, `MatchByteMask`/`MatchRangeMask`,
`ToLowerWord`/`ToUpperWord`, `FirstLane`/`LastLane`, and the `WordLen`,
`Ones`, `HighBits`, and `LowSeven` constants. They are exported so
downstream packages (Fiber itself, middleware) can fuse their own byte
scans — for example, finding a delimiter while classifying the bytes
before it — without re-deriving the bit tricks. The contracts (unchecked
bounds preconditions, `ZeroLanes`' approximate mask, the little-endian
lane order) and runnable examples live in the package documentation.
The package benchmarks its primitives against their stdlib counterparts
the same way the helpers above do, measuring the canonical loops composed
from them: `Load8`/`Store8` vs `encoding/binary`'s little-endian
`Uint64`/`PutUint64`, a `ZeroLanes` first-match scan vs
`strings.IndexByte`, a `MatchByteMask`+`LastLane` reverse scan vs
`bytes.LastIndexByte`, a `MatchRangeMask` digit scan vs
`strings.IndexAny`, and an in-place `ToLowerWord` loop vs
`bytes.ToLower`. The composed loops are pinned to the stdlib results by a
dedicated test, and the numbers are tracked per commit on the
[benchmark charts](https://gofiber.github.io/utils/benchmarks/). Note
that `strings.IndexByte` is hand-written SIMD assembly and overtakes the
portable SWAR scan on large inputs; the SWAR primitives earn their keep
on short HTTP-sized inputs and on fused scans the stdlib has no single
function for. The package's remaining benchmark, `Benchmark_Load8_Fusion`,
is an advisory codegen guard rather than an API performance promise, so
it is deliberately not part of the catalog above.
## SIMD-accelerated search (package simd)
The [`simd`](simd/) package is the vector-width counterpart to `swar`: byte
searching and validation whose scan kernels dispatch to AVX2 assembly (four
32-byte vectors per iteration) on amd64 CPUs for inputs of `simd.MinLen`
(32) bytes or more, and fall back to portable loops built on the `swar`
primitives everywhere else, so it builds and behaves identically on every
platform.
`simd.Accelerated()` reports which mode is active. CPU capability detection
uses [`golang.org/x/sys/cpu`](https://pkg.go.dev/golang.org/x/sys/cpu),
which also verifies OS support for saving the vector register state.
The AVX2-backed kernels are the multi-needle scans (`Memchr2`, `Memchr3`),
the paired-byte scan (`MemchrPair`), the class scans
(`MemchrDigit`/`MemchrDigitAt`, `MemchrWord`/`MemchrNotWord`), the ASCII
scans (`IsASCII`, `FirstNonASCII`, `CountNonASCII`), and the substring
search (`Memmem`), which
prefilters on the needle's rarest bytes (`SelectRareBytes`, `ByteRank`)
before verifying candidates — 2-6 byte needles containing two distinct
values are scanned for their two rarest bytes at the exact relative
distance, longer or single-valued needles for the single rarest byte.
Each kernel classifies four 32-byte vectors per iteration. Where the
result is a position or a yes/no, the four masks are combined, so a
128-byte block costs a single `VPMOVMSKB` and a single branch, and the
scans that report a position re-extract the four masks in address order on
the (rare) hit path. `CountNonASCII` is the exception — a count cannot be
recovered from a combined mask, so its block loop accumulates per-lane
counts in vector byte lanes (a signed compare against zero and a byte
subtract per vector) and reduces them once at the end, while the
remaining whole vectors are extracted and population-counted; it is the
one kernel gated on `POPCNT` in addition to AVX2.
One tier is documented explicitly as unaccelerated:
`MemchrInTable`/`MemchrNotInTable` are plain
scalar loops, since an arbitrary 256-entry membership test has no cheap
vector form. There is deliberately no single-needle `Memchr`:
`bytes.IndexByte` is already vector-accelerated by the Go runtime. `Memmem`
delegates to `bytes.Index` for haystacks of up to 64 bytes, where the
stdlib's brute-force vector kernel is level with the paired prefilter
(`Benchmark_Memmem_Prefilter` forces the prefilter helpers at every size
to keep that measurable); from 65 bytes `bytes.Index` switches to a loop
anchored on the needle's first byte, and the paired scan takes over.
Needles that take the single rare-byte scan keep a 128-byte routing point,
since that scan is less selective. Both prefilters bail to `bytes.Index`
after a bounded number of failed candidate verifications, so even
adversarial inputs — a rare byte everywhere plus a long almost-matching
needle — stay within a constant of the stdlib's O(n+m) (see
`Benchmark_Memmem_Adversarial`). The
package operates on `[]byte` only; the generic top-level helpers `IsASCII`,
`IndexAny2`, and `IndexAny3` dispatch into it automatically for inputs of
`simd.MinLen`+ bytes on amd64, which is where the AVX2 kernels overtake the
SWAR word loops (-35% to -88% ns/op at 32-512B in `benchstat -count=10`
runs; shorter inputs keep the existing SWAR paths).
The kernels are adapted from the [coregex](https://github.com/coregx/coregex)
project's `simd` package (MIT License, Copyright (c) 2025 Andrey Kolkov and
contributors; see [`simd/LICENSE`](simd/LICENSE)), with the legacy-SSE
register moves in the kernels replaced by VEX-encoded ones to avoid AVX-SSE
transition stalls, the scalar tail loops replaced by overlapping vector
rescans at the buffer end (a 63-byte scan previously cost ~3.7x a 64-byte
one), the 32-byte main loops replaced by 4x unrolled 128-byte blocks whose
bound is tested once at the bottom against a precomputed limit pointer, the
`\w` classifier rewritten from three `VPMINUB`/`VPMAXUB` clamp-and-compare
range tests into two `VPSHUFB` nibble-table lookups (with the block test
reduced to one compare over the four raw class values), the digit range
test reduced from two signed compares and a `VPANDN` to one biased
`VPADDB` and one compare, `FirstNonASCII` and `CountNonASCII` given
kernels of their own (they were SWAR-only, and the count kernel's block
loop accumulates in vector byte lanes rather than extracting and
population-counting every vector's mask), the 128-byte block loops
placed at fixed offsets inside a 32-byte code window so their throughput
no longer depends on where the linker places each kernel, and the
fallbacks reworked around the stdlib and the `swar` package as described
above.
Against the pre-unrolling kernels, `benchstat -count=10` on the machine
below reports -26.6%/-49.7% ns/op for `Memchr2` at 512B/4096B,
-17.6%/-34.3% for `Memchr3`, -13.4%/-24.6% for `MemchrPair`,
-39.2%/-50.5% for `MemchrDigit`, -53.5%/-63.7% for `MemchrNotWord`,
-42.2%/-65.7% for `IsASCII`, and -13.7%/-27.1% for `Memmem`, which rides
the paired scan. Those percentages come from `benchstat` over ten runs of
each side; the single-run table below is a catalog, not a base-vs-head
comparison, so subtracting its rows from an older copy of it will not
reproduce them.
Two bands see no benefit and are worth stating plainly. Inputs below
`simd.MinLen` never reach the kernels at all. Inputs of 32-127 bytes do
reach them but skip the 128-byte block loop, so they pay its setup with
nothing to amortize it against: across that band `benchstat` reports the
class scans clearly ahead (`MemchrNotWord` -8.6% at 32B, -18.4% at 64B;
`IsASCII` -5.0%/-4.3%), most rows statistically unchanged, and two small
regressions — `MemchrDigit` +5.6% at 32B and `Memchr3` +3.8% at 64B. Read
those small-input figures against the run's own noise floor: the `default`
legs call unchanged stdlib code, so their movement bounds what a delta of
that size means. They held within 1% in the run quoted here, but a later
run on the same machine drifted up to 17% on those same rows, so anything
under ~10% at 32-64B should be taken as "no measured change" unless its
control legs are quiet.
On the portable side, pinning each unrolled group of words with a reslice
before loading at constant offsets inside it removes the per-load bounds
check that `swar.Load8`'s own reslice otherwise repeats. Measured with
`benchstat -count=10` against the same fallbacks, at 32B/512B/4KiB:
`IsASCII` -28%/-60%/-63%, `CountNonASCII` -24%/-44%/-44%,
`FirstNonASCII` -23%/-37%/-43%, `Memchr2` -19%/-23%/-25%,
`MemchrDigit` -7%/-12%/-17%, `Memchr3` -8%/-13%/-18%,
`MemchrWord` -11%/-8%/-11%, `MemchrNotWord` -5%/-7%/-6%. The tier a group
adds costs one compare on inputs too short to use it, which shows up as
+3% to +10% on some of the 8B fallback rows — a few tenths of a
nanosecond, and only below the length where the group pays for itself.
`utils.IsASCII` carries the same rework, so the two copies of that scan
stay in step.
Making the counting kernel finish its own sub-vector remainder (rather
than splitting the input in Go and calling the SWAR loop for the tail)
also removed a second non-inlinable call from every whole-vector input:
`CountNonASCII` at 32B went from 11.3ns — behind its own fallback — to
6.8ns, level with it, and it leads from 64B up.
A later audit pass reworked the kernels and fallbacks once more;
`benchstat -count=10` on the machine below, base vs. head, reports:
- `MemchrDigit` -20% at 512B and -27% at 4KiB from the one-add,
one-compare range test.
- `MemchrWord` -13%/-11% and `MemchrNotWord` -4%/-10% at 512B/4KiB from
comparing the reduced block once instead of every vector, and their
SWAR fallbacks -36%/-41% at 32B, -40%/-43% at 64B and -43%/-45% at
512B: 15 ALU operations per word instead of 26, from case-folding the
two letter ranges into one test, a one-add underscore test, and a
single shared ASCII gate.
- `CountNonASCII` -15% at 512B and -41% at 4KiB, with 32B and 64B
unchanged: the block loop counts in vector byte lanes (a signed compare
against zero and a byte subtract per vector, flushed through `VPSADBW`
every 127 blocks) instead of four port-0 `VPMOVMSKB` extractions per
block. The remaining whole vectors are still extracted and
population-counted, because the vector reduction is a fixed ten-cycle
chain that one to three vectors cannot amortize — a first version that
used the accumulators for those too was 20% slower at 32-64B.
- `MemchrPair`'s SWAR fallback -33% at 32B, -41% at 64B, -51% at 512B and
-52% at 4KiB, and `MemchrPair` itself -30% at 32B, where the dispatch
routes to that fallback: it now scans two words per branch through
pinned three-index windows (no per-load capacity check or pointer
clamp) and finishes with one overlapping word instead of a scalar
tail. Before, at 32B, it ran no faster than a plain scalar loop.
- `Memmem` -62% at 96B: needles that take the paired prefilter are routed
through it from 65-byte haystacks, where `bytes.Index` leaves its
brute-force vector kernel for a first-byte-anchored loop; 64B and
128B+ are unchanged.
The same pinned-window rework applied to the case-conversion loops in
`internal/caseconv`, which the `strings` and `bytes` packages' `ToLower`
and `ToUpper` build on, gives on the same machine -27% to -37% ns/op for
the in-place `UnsafeToLower`/`UnsafeToUpper` at 39-64B, -14% to -19% for
the scan-only path that finds nothing to convert, and -5% to -17% for the
allocating conversions, where the allocation dominates. The arm64 catalog
rows above were not regenerated for that change.
Comparing the base and head test binaries also showed the untouched
`MemchrPair` kernel ~10% slower at 4KiB, purely because the linker had
moved its entry by 32 bytes: on Skylake-derived cores the JCC erratum
mitigation keeps a macro-fused compare-and-branch that crosses or ends on
a 32-byte boundary out of the decoded-uop cache, so the block loop ran
from the legacy decoder. Every block loop is now placed by a `BLOCKALIGN`
macro at a window offset where all of its fused pairs fit (a few
once-per-call NOPs, visible as +5% on `Memchr2` at 512B and nothing at
4KiB), and an amd64 test reads each kernel's code and fails if a later
edit lets a pair straddle a boundary again.
Because the AVX2 kernels only engage on amd64, their benchmark numbers are
recorded separately from the arm64 catalog above:
Environment:
goos: linux
goarch: amd64
pkg: github.com/gofiber/utils/v2/simd
cpu: Intel(R) Xeon(R) Processor @ 2.80GHz (AVX2)
```text
// go test ./simd/ -benchmem -run=^$ -bench=Benchmark_ -count=1
Benchmark_Memchr2/8B/simd-4 190047766 6.344 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr2/8B/scalar-4 216903783 5.516 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr2/8B/default-4 37047232 34.54 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr2/32B/simd-4 230568829 5.549 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr2/32B/scalar-4 137118788 9.346 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr2/32B/default-4 37159426 34.23 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr2/64B/simd-4 202942682 5.969 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr2/64B/scalar-4 87153786 13.77 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr2/64B/default-4 23353054 54.76 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr2/512B/simd-4 85724174 13.67 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr2/512B/scalar-4 13201143 89.39 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr2/512B/default-4 3530156 348.3 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr2/4096B/simd-4 18950438 63.19 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr2/4096B/scalar-4 1703708 698.6 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr2/4096B/default-4 451885 2773 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/8B/simd-4 161230975 7.399 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/8B/scalar-4 195079063 6.568 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/8B/default-4 39049345 31.96 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/32B/simd-4 209563508 5.767 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/32B/scalar-4 100000000 11.80 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/32B/default-4 36763602 33.60 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/64B/simd-4 186953884 6.553 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/64B/scalar-4 59549791 20.13 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/64B/default-4 22672693 54.92 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/512B/simd-4 75757986 16.84 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/512B/scalar-4 9159388 128.2 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/512B/default-4 3351171 348.3 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/4096B/simd-4 12609099 93.35 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/4096B/scalar-4 1000000 1064 ns/op 0 B/op 0 allocs/op
Benchmark_Memchr3/4096B/default-4 470744 2615 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/8B/simd-4 100000000 10.56 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/8B/swar-4 152141828 7.801 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/8B/scalar-4 201085015 6.059 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/32B/simd-4 88059698 13.00 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/32B/swar-4 100000000 10.63 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/32B/scalar-4 68842016 16.81 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/64B/simd-4 156794418 7.975 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/64B/swar-4 75119947 16.98 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/64B/scalar-4 33130292 32.27 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/512B/simd-4 63940441 18.19 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/512B/swar-4 11641740 103.3 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/512B/scalar-4 4559438 269.0 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/4096B/simd-4 17142175 70.75 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/4096B/swar-4 1548690 776.4 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrPair/4096B/scalar-4 563876 2072 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrDigit/8B/simd-4 195955126 5.458 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrDigit/8B/scalar-4 267192732 4.378 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrDigit/32B/simd-4 248331692 4.985 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrDigit/32B/scalar-4 134102625 8.622 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrDigit/64B/simd-4 212405679 5.785 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrDigit/64B/scalar-4 72030652 15.22 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrDigit/512B/simd-4 124923620 9.429 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrDigit/512B/scalar-4 11478067 103.1 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrDigit/4096B/simd-4 24760083 47.52 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrDigit/4096B/scalar-4 1490264 800.2 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrWord/8B/simd-4 153120554 8.104 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrWord/8B/scalar-4 186279788 6.460 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrWord/32B/simd-4 205711502 5.958 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrWord/32B/scalar-4 86716185 14.24 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrWord/64B/simd-4 185673494 6.833 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrWord/64B/scalar-4 48932490 25.11 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrWord/512B/simd-4 61637564 16.98 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrWord/512B/scalar-4 6845524 174.5 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrWord/4096B/simd-4 12697916 92.19 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrWord/4096B/scalar-4 881439 1442 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrNotWord/8B/simd-4 167067980 7.307 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrNotWord/8B/scalar-4 189991910 6.302 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrNotWord/32B/simd-4 205724659 5.578 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrNotWord/32B/scalar-4 79661326 13.15 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrNotWord/64B/simd-4 185518209 6.497 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrNotWord/64B/scalar-4 47755200 24.15 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrNotWord/512B/simd-4 70365358 16.62 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrNotWord/512B/scalar-4 6722820 172.3 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrNotWord/4096B/simd-4 13096357 93.62 ns/op 0 B/op 0 allocs/op
Benchmark_MemchrNotWord/4096B/scalar-4 892350 1366 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/8B/simd-4 100000000 10.19 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/8B/default-4 148054586 7.966 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/32B/simd-4 98693811 12.81 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/32B/default-4 100000000 10.89 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/64B/simd-4 75442142 15.92 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/64B/default-4 81081360 13.98 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/96B/simd-4 56509897 19.39 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/96B/default-4 25670028 47.21 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/128B/simd-4 62137202 20.18 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/128B/default-4 21325711 57.92 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/192B/simd-4 57145284 21.37 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/192B/default-4 12855652 92.65 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/512B/simd-4 45782227 26.28 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/512B/default-4 4696874 258.5 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/4096B/simd-4 15384080 80.64 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem/4096B/default-4 566840 2110 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/8B/paired-4 100722044 12.11 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/8B/paired-stdlib-4 156602451 7.970 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/32B/paired-4 63617959 16.69 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/32B/paired-stdlib-4 100000000 11.05 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/32B/single-4 83176831 14.12 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/32B/single-stdlib-4 80788734 15.91 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/64B/paired-4 91946842 12.97 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/64B/paired-stdlib-4 86483179 13.90 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/64B/single-4 35353610 32.88 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/64B/single-stdlib-4 33454047 35.61 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/96B/paired-4 90596826 13.71 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/96B/paired-stdlib-4 26030700 45.55 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/96B/single-4 26503994 44.73 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/96B/single-stdlib-4 36078775 33.98 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/128B/paired-4 81232996 14.57 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/128B/paired-stdlib-4 21295238 56.58 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/128B/single-4 19797116 61.11 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/128B/single-stdlib-4 25664023 46.42 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/192B/paired-4 78041734 15.73 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/192B/paired-stdlib-4 13159070 91.53 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/192B/single-4 12339504 99.01 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/192B/single-stdlib-4 14733991 81.86 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/512B/paired-4 55724107 21.69 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/512B/paired-stdlib-4 4627340 261.9 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/512B/single-4 4143304 285.8 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/512B/single-stdlib-4 4889746 246.2 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/4096B/paired-4 15190396 76.16 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/4096B/paired-stdlib-4 571941 2135 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/4096B/single-4 558564 2160 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Prefilter/4096B/single-stdlib-4 539943 2120 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Adversarial/simd-4 721 1676433 ns/op 0 B/op 0 allocs/op
Benchmark_Memmem_Adversarial/default-4 729 1660342 ns/op 0 B/op 0 allocs/op
Benchmark_IsASCII/8B/simd-4 287283123 4.187 ns/op 0 B/op 0 allocs/op
Benchmark_IsASCII/8B/swar-4 469731259 2.536 ns/op 0 B/op 0 allocs/op
Benchmark_IsASCII/32B/simd-4 295464411 4.118 ns/op 0 B/op 0 allocs/op
Benchmark_IsASCII/32B/swar-4 292665852 4.148 ns/op 0 B/op 0 allocs/op
Benchmark_IsASCII/64B/simd-4 240708138 4.706 ns/op 0 B/op 0 allocs/op
Benchmark_IsASCII/64B/swar-4 220235487 5.569 ns/op 0 B/op 0 allocs/op
Benchmark_IsASCII/512B/simd-4 192368624 6.454 ns/op 0 B/op 0 allocs/op
Benchmark_IsASCII/512B/swar-4 54892551 21.45 ns/op 0 B/op 0 allocs/op
Benchmark_IsASCII/4096B/simd-4 43729008 27.50 ns/op 0 B/op 0 allocs/op
Benchmark_IsASCII/4096B/swar-4 7511167 157.0 ns/op 0 B/op 0 allocs/op
Benchmark_FirstNonASCII/8B/simd-4 260435899 4.724 ns/op 0 B/op 0 allocs/op
Benchmark_FirstNonASCII/8B/swar-4 341475208 3.574 ns/op 0 B/op 0 allocs/op
Benchmark_FirstNonASCII/32B/simd-4 297709566 4.219 ns/op 0 B/op 0 allocs/op
Benchmark_FirstNonASCII/32B/swar-4 227647696 5.171 ns/op 0 B/op 0 allocs/op
Benchmark_FirstNonASCII/64B/simd-4 267531430 4.636 ns/op 0 B/op 0 allocs/op
Benchmark_FirstNonASCII/64B/swar-4 160438296 7.334 ns/op 0 B/op 0 allocs/op
Benchmark_FirstNonASCII/512B/simd-4 170822334 7.301 ns/op 0 B/op 0 allocs/op
Benchmark_FirstNonASCII/512B/swar-4 34065859 34.89 ns/op 0 B/op 0 allocs/op
Benchmark_FirstNonASCII/4096B/simd-4 43481222 27.70 ns/op 0 B/op 0 allocs/op
Benchmark_FirstNonASCII/4096B/swar-4 4615596 254.2 ns/op 0 B/op 0 allocs/op
Benchmark_CountNonASCII/8B/simd-4 205752014 5.746 ns/op 0 B/op 0 allocs/op
Benchmark_CountNonASCII/8B/swar-4 281060181 4.143 ns/op 0 B/op 0 allocs/op
Benchmark_CountNonASCII/32B/simd-4 274114710 4.472 ns/op 0 B/op 0 allocs/op
Benchmark_CountNonASCII/32B/swar-4 206395050 5.781 ns/op 0 B/op 0 allocs/op
Benchmark_CountNonASCII/64B/simd-4 242445574 4.774 ns/op 0 B/op 0 allocs/op
Benchmark_CountNonASCII/64B/swar-4 139845796 8.224 ns/op 0 B/op 0 allocs/op
Benchmark_CountNonASCII/512B/simd-4 143031885 8.239 ns/op 0 B/op 0 allocs/op
Benchmark_CountNonASCII/512B/swar-4 27194380 43.84 ns/op 0 B/op 0 allocs/op
Benchmark_CountNonASCII/4096B/simd-4 33436537 35.32 ns/op 0 B/op 0 allocs/op
Benchmark_CountNonASCII/4096B/swar-4 3573552 334.1 ns/op 0 B/op 0 allocs/op
```
## ☕ Supporters
Fiber is an open-source project that runs on donations to pay the bills, e.g., our domain name, hosting, and serverless infrastructure. If you want to support Fiber, please become a [GitHub Sponsor](https://github.com/sponsors/gofiber).
Tool Sponsors - supporting Fiber with free IDE licenses and AI credits
### 📅 Monthly Sponsors
| 🔥 Fiber Guardian |  |
| ☕ Fiber Supporter |  |
| 🪴 Fiber Friend |  |
### 🎁 One-time Sponsors
| 🚀 Fiber Hero |  |
| 🪴 Fiber Friend |  |