Skip to content

Increment = index when parsing set-cookie#280

Merged
blakeembrey merged 4 commits into
masterfrom
be/increment-eq-index
Jun 30, 2026
Merged

Increment = index when parsing set-cookie#280
blakeembrey merged 4 commits into
masterfrom
be/increment-eq-index

Conversation

@blakeembrey

@blakeembrey blakeembrey commented Jun 29, 2026

Copy link
Copy Markdown
Member

Better performance when parsing set-cookie with many parameters and no = within them.

Before:

 ✓ src/parse-set-cookie.bench.ts > parse top-sites 17277ms
     name                                 hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · parse apple.com            5,786,691.21  0.0000  2.6515  0.0002  0.0002  0.0002  0.0003  0.0012  ±1.25%  2893346
   · parse cloudflare.com         348,297.33  0.0026  0.2212  0.0029  0.0029  0.0034  0.0037  0.0211  ±0.36%   174149
   · parse docs.google.com      1,893,491.25  0.0004  3.9001  0.0005  0.0005  0.0006  0.0007  0.0026  ±1.74%   946746
   · parse en.wikipedia.org       375,289.58  0.0024  4.9893  0.0027  0.0026  0.0033  0.0071  0.0262  ±1.98%   187645
   · parse linkedin.com         1,697,462.88  0.0005  0.2036  0.0006  0.0006  0.0007  0.0007  0.0012  ±0.33%   848732
   · parse microsoft.com          906,743.03  0.0010  0.2070  0.0011  0.0011  0.0012  0.0013  0.0037  ±0.31%   453372
   · parse play.google.com      2,042,916.78  0.0004  2.2218  0.0005  0.0005  0.0006  0.0006  0.0010  ±0.91%  1021459
   · parse policies.google.com  2,065,324.01  0.0004  0.1789  0.0005  0.0005  0.0005  0.0006  0.0010  ±0.30%  1032663
   · parse support.google.com   1,027,358.12  0.0008  0.1546  0.0010  0.0010  0.0011  0.0012  0.0016  ±0.26%   513680
   · parse t.me                 1,657,462.31  0.0004  3.9306  0.0006  0.0005  0.0008  0.0015  0.0112  ±1.74%   828732
   · parse tiktok.com             572,158.71  0.0016  1.8228  0.0017  0.0018  0.0020  0.0022  0.0040  ±0.75%   286080
   · parse wa.me                1,607,501.22  0.0005  1.5157  0.0006  0.0006  0.0007  0.0008  0.0011  ±0.88%   803751
   · parse whatsapp.com           576,792.30  0.0015  0.1886  0.0017  0.0017  0.0019  0.0021  0.0257  ±0.29%   288397
   · parse www.google.com         590,383.50  0.0015  0.2378  0.0017  0.0017  0.0019  0.0020  0.0260  ±0.31%   295192
   · parse x.com                  223,105.43  0.0041  0.4303  0.0045  0.0044  0.0061  0.0085  0.0304  ±0.36%   111553
   · parse youtu.be               228,680.16  0.0041  0.2073  0.0044  0.0043  0.0047  0.0049  0.0292  ±0.29%   114341
   · parse youtube.com            230,847.11  0.0041  0.1640  0.0043  0.0043  0.0048  0.0049  0.0090  ±0.23%   115424
   · 100k semicolons                  4.3820  224.23  232.05  228.21  230.91  232.05  232.05  232.05  ±0.82%       10

After:

 ✓ src/parse-set-cookie.bench.ts > parse top-sites 14013ms
     name                                 hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · parse apple.com            5,795,959.87  0.0000  6.7030  0.0002  0.0002  0.0002  0.0003  0.0010  ±2.74%  2897980
   · parse cloudflare.com         361,453.47  0.0025  0.2203  0.0028  0.0027  0.0032  0.0035  0.0152  ±0.33%   180727
   · parse docs.google.com      2,017,995.73  0.0004  3.4419  0.0005  0.0005  0.0006  0.0006  0.0010  ±1.37%  1008998
   · parse en.wikipedia.org       396,007.30  0.0023  1.6713  0.0025  0.0025  0.0029  0.0033  0.0107  ±0.71%   198004
   · parse linkedin.com         1,723,331.17  0.0005  0.1601  0.0006  0.0006  0.0007  0.0008  0.0029  ±0.27%   861666
   · parse microsoft.com          898,687.05  0.0009  3.7118  0.0011  0.0011  0.0013  0.0015  0.0083  ±1.48%   449344
   · parse play.google.com      2,056,782.97  0.0004  0.2088  0.0005  0.0005  0.0006  0.0006  0.0045  ±0.28%  1028392
   · parse policies.google.com  2,063,004.28  0.0004  0.1874  0.0005  0.0005  0.0006  0.0006  0.0010  ±0.29%  1031503
   · parse support.google.com   1,017,708.76  0.0008  0.1855  0.0010  0.0010  0.0011  0.0012  0.0031  ±0.31%   508855
   · parse t.me                 1,908,612.99  0.0004  0.1916  0.0005  0.0005  0.0006  0.0007  0.0010  ±0.32%   954307
   · parse tiktok.com             563,532.72  0.0015  7.9198  0.0018  0.0017  0.0022  0.0032  0.0258  ±3.48%   281767
   · parse wa.me                1,629,260.49  0.0005  0.1502  0.0006  0.0006  0.0007  0.0007  0.0012  ±0.30%   814631
   · parse whatsapp.com           589,975.03  0.0015  0.1756  0.0017  0.0017  0.0018  0.0020  0.0261  ±0.31%   294988
   · parse www.google.com         573,624.39  0.0015  5.6973  0.0017  0.0017  0.0021  0.0025  0.0262  ±2.25%   286813
   · parse x.com                  222,605.55  0.0041  3.7246  0.0045  0.0042  0.0064  0.0127  0.0335  ±1.49%   111303
   · parse youtu.be               231,565.26  0.0040  0.1785  0.0043  0.0043  0.0048  0.0051  0.0335  ±0.30%   115783
   · parse youtube.com            234,840.62  0.0040  0.2076  0.0043  0.0042  0.0046  0.0048  0.0336  ±0.31%   117421
   · 100k semicolons                  394.69  2.4592  2.7219  2.5336  2.5539  2.7155  2.7219  2.7219  ±0.30%      198

No real change except for the unrealistic semicolon only edge case added.

@blakeembrey blakeembrey requested review from a team and UlisesGascon June 29, 2026 22:53
Comment thread src/index.ts
eqIdx === -1
? { name: "", value: dec(valueSlice(str, 0, endIdx)) }
: {
eqIdx < endIdx

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these are mostly reversing the conditions instead of using >= purely to shave 4 bytes in the compressed output 😅

@blakeembrey blakeembrey merged commit 84068f8 into master Jun 30, 2026
9 checks passed
@blakeembrey blakeembrey deleted the be/increment-eq-index branch June 30, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants