Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use unordered_set for whitelist lookups #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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
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.

None yet

1 participant