arlolra/check — pull request #10 by Ryman (2013-09-05 04:11:23+00:00)
Title: Performance improvement for checking IsTor

Old behavior

IsTor(ip)
policy = lookup(ip) o(1)
policy.canexit(tor_ip) -- has a cache per ip/port combination per policy
for k rules
convert to ip && checks it isn't nil !
check if rule addr is nil or matches ip
checks if valid port argument !
checks if port is in range

New behaviour is to just precompute all that (via the Dump logic) and just lookup by ip for requests

I think you might want to wait for tests to be in place before merging this just to be sure

The dump logic is still really slow in comparison to the optimal available (pretty sure there's an O(1+k) available for this kind of lookup) but I'll definitely wait for some tests before implementing that