Skip to content

Draft: geoip: store data more efficiently

Alex Xu requested to merge Hello71/tor:geoip-save-ram into main

GeoIP v4+v6 occupy over 10 MB combined, mostly due to the inefficient storage method. Using arrays instead of smartlists reduces malloced amount by about 40%, but actual savings are much larger due to malloc overhead on small allocations.

geoip_get_countries is not very efficient, but geoip_get_request_history is called infrequently so it is probably ok to keep the existing interface.

I know that C Tor is not looking for major changes at this point, but I think this change is justified on the basis that 5-10+ MB savings is quite a lot for embedded clients, and even for relays, 10 MB is a decent chunk shaved off. Additionally, geoip has fairly good test coverage, so I believe the major bugs are ironed out.

Merge request reports