-
Notifications
You must be signed in to change notification settings - Fork 632
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
Update routing table in a separate thread #3853
Comments
Why not do something like this: #3882 |
before
after
|
After further optimizations thanks to @matklad suggestion to use
|
big 👍 for the general "make it fast first, only then make is complicated". In rust-analyzer, we managed to reduce complexity a lot by just computing things effectively instead of gong for complicated caching/therading setups. zz |
We also reduced memory usage on calculate_distance_10_100 from 16mb to 5mb |
More work needs to be done, I saw at one point a huge pile of scheduled futures to recompute the graph. The code looks incorrect:
|
After some more optimizations:
|
After further tweaking
|
@pmnoxx on mainnet I observed the following:
The neard binary has #3882 |
I saw cases where functions like processing routing table would take a long time, because other threads were busy. I think we should measure cpu time thread in addiction to real time. https://docs.rs/cpu-time/1.0.0/cpu_time/struct.ThreadTime.html |
In #4099 I cleaned up the logic for scheduling routing table precomputation to happen at most once a second. |
How is that related to this issue? The issue is not that we do the computation multiple times, but rather that each computation takes a long time. |
This is just a code cleanup. I noticed we had old code which was limiting how often we should do routing table computation. That code was never working properly, it's functionality was replaced by other check I added. Right now it's just a dead code. |
@bowenwang1996 I added prints and I see that this code takes 3-4s on my local machine:
We call this function once every 2 hours, so it's probably not a high priority to optimize it. |
Sure. Let's open a separate issue for this (if doesn't already exist) |
Updating routing table could take a nontrivial amount of time when the routing table is large. It is better if the computation is done in a separate thread from
PeerManagerActor
so that we don't block it from performing other tasks. Also we can update it less frequently than once every second (once every 5s seems fine as well).The text was updated successfully, but these errors were encountered: