Skip to content

replace host regex filtering with host prefix filtering

Vgutierrez requested to merge hostname-validation-performance-boost into main

The current approach of using the regex [um][pa][lp][os] is both hard to read and inefficient. Given that this is check is performed per request, its performance is quite important.

Replacing the current regex with a simple strings.HasPrefix() makes hostname 23x faster in the upload cluster (Current VS HasPrefix) and a NOOP for the text cluster (NothingToCheck benchmarks)

BenchmarkCurrent-16                     1783156               668.8 ns/op
BenchmarkHasPrefix-16                   42269040              28.76 ns/op
BenchmarkCurrentNothingToCheck-16       1000000000            0.1582 ns/op
BenchmarkNewNothingToCheck-16           1000000000            0.1558 ns/op

benchmark source code is available here

Merge request reports