fixes #17387 - SubnetService#find_subnet has constant time lookup
find_subnet is now approximately constant with the number of subnets configured, using hash lookups of possible network prefixes for the given IP address until the most specific prefix is found. Benchmark results:
add_subnet only checks for an identical network prefix instead of overlapping prefixes with #find_subnet, speeding it up considerably. Benchmark results:
add_subnet (1) 41.389k (±17.4%) i/s - 378.638k in 9.792687s add_subnet (5) 10.278k (±11.2%) i/s - 99.588k in 9.931308s add_subnet (50) 1.062k (± 9.3%) i/s - 10.470k in 9.991114s add_subnet (500) 105.161 (± 9.5%) i/s - 1.042k in 10.007969s add_subnet (1000) 53.826 (± 7.4%) i/s - 536.000 in 10.012055s add_subnet (15000) 3.424 (± 0.0%) i/s - 35.000 in 10.241879s
Related issues
Bug #17387: Speed up Proxy::DHCP::SubnetService#find_subnet
fixes #17387 - SubnetService#find_subnet has constant time lookup
find_subnet is now approximately constant with the number of subnets
configured, using hash lookups of possible network prefixes for the
given IP address until the most specific prefix is found. Benchmark
results:
add_subnet only checks for an identical network prefix instead of
overlapping prefixes with #find_subnet, speeding it up considerably.
Benchmark results: