-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Reduce overhead of sync state checking #10842
Conversation
|
The sync state machine is fully synchronous, I don't think it's a good idea to introduce locks. The |
Sorry, maybe the name is not perfect (maybe I should have named it I can change it into a normal (Unless there's even a simpler way of doing this that I'm missing and I'm just having a brainfart; it's late here already.) |
|
There's already a mechanism that prevents excessive examinations of sync state when |
@arkpar That might be better; if you could whip up a PR I could hook it up to the profiler and see whether this PR will still be necessary or not. |
|
See #10843 |
|
#10843 achieves the same effect, so let's go with that one. |
These
any()loops were using 5.4% of CPU; now they don't even show in the profile.I picked this approach since it seemed the simplest and most future-proof, that is: there's no need to manually track and insert a
peer_download_in_progress = falseline everywhere where thepeer.statemight be changed or where thepeermight beremoved altogether (and risk missing some place now and/or in the future after some refactoring); it happens automatically when the state's switched or dropped.I admit that I'm not super familiar with this code, so I'm not sure if this is the best way to fix it; if you want me to do it in a different way please say so and I'll be happy to oblige.