Skip to content

Conversation

@undertheironbridge
Copy link
Contributor

All whitelist lookups are currently performed by a linear search over a std::vector of std::string objects. Since peer IDs are always 20 bytes long, an std::array might be better suited for this, and has the added advantage of always storing the data contiguously, which is not a requirement with std::strings. Storing such std::arrays in an unordered_set gives a clear performance advantage, as illustrated in this benchmark.

Since whitelist lookups need to be made for every announce, I suppose this might have a very positive impact on the overall performance of the tracker.

@undertheironbridge undertheironbridge force-pushed the whitelist-in-unordered-map branch from a4f6866 to 39388d6 Compare May 6, 2020 23:41
@undertheironbridge undertheironbridge force-pushed the whitelist-in-unordered-map branch from 39388d6 to dc33e00 Compare May 6, 2020 23:42
@undertheironbridge
Copy link
Contributor Author

It just occurred to me that the database-stored whitelist entries are actually meant to be used as peer_id prefixes, not literal peer_ids to be matched. In this case, this whole PR can really be scrapped, as it won't work as expected. The only thing that can potentially stay is the test script (with appropriate changes), which might come in handy should anyone like to change the whitelisting implementation or perhaps use it as a starting point for testing the tracker as a whole.

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.

1 participant