-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
CPU usage/efficiency #7894
Comments
Interesting! If I were to improve it, I would try these:
|
I just tried that, and I must've done something wrong, because somehow, my
I also tried this, but the performance gain is negligible.
Regex seems a bit overkill for this. I have, however, been able to speed up I would look into why I could open a PR with this caching, and it would remove the need to speed up Also, is there a reason the nodes in |
After optimizing those, another issue has appeared: ~20% of the remaining total CPU usage is in |
I don't have much to add and I just found this interesting post: https://gms.tf/stdfind-and-memchr-optimizations.html#is-stdfind-faster-as-memchr @bolshoytoster
IMO feel free to submit it. The important bits can be discussed in the PR. |
And I build libtorrent with I've opened a PR with a few more optimizations: #7898 |
I'm a user of qBittorrent, and I've been experiencing high CPU usage (30-50%) recently, mostly from libtorrent's network thread.
I decided to investigate this with callgrind, and I found that ~17% of the total CPU usage was in
parse_url_components
, specifically in the calls tostd::find
, which, it seems aren't being properly inlined/optimized (yes, I'm using-O3
).I modified this to use raw pointers and
memchr
instead of iterators andstd::find
, and I've been able to get a 1.6x speed improvement (according to my crude benchmarking):There are probably faster implementations than this, but it brings down
parse_url_components
to ~6% of the total (still room for improvement).Another thing I noticed is that
parse_url_components
is called hundreds of times per second (mostly byis_i2p_url
), with the same urls, so would it be worth caching the result/optimizingis_i2p_url
, since it doesn't actually require parsing the full url.I'd like to know if this would be welcome as a PR, perhaps along with an optimization to
is_i2p_url
.Another performance issue I'm looking into is comparing
digest32
s in thestd::find_if
indht::routing_table::node_failed
, which looks like it could be fixed ifrouting_table_node::live_nodes
were a hashmap instead of astd::vector
.The text was updated successfully, but these errors were encountered: