-
Notifications
You must be signed in to change notification settings - Fork 134
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
KGW performance #94
Comments
VTC's hash function is a lot more computationally intensive than GRS which is why the sync takes longer. You'll notice Vertcoin Core is still processing the headers. Realistically there's nothing we can do to fix that. |
My guess would be the CPU is waiting on memory reads/writes a decent amount due to cache misses. |
Having a look through the Performance Monitor I'm not sure that's the case. Any other suggestions ? :) |
None, but if you want to investigate further we'd be grateful! |
I added some benchmarking to the header processing code (per header):
So clearly KGW is the bottleneck here, not Lyra2REv3. That's likely to be disk I/O related as it needs to read between 144 and 4032 headers per block. In Lit I added some caching to deal with the problem, but I think doing that would be quite a large structural change to Core. I re-opened the issue in case someone wants to look into it, since changing to Verthash will not affect any solution that's found. |
can someone detail the slow sync issue?other than just that KGW is causing it, maybe with some debug log info |
It's mostly self-explanatory. It seems that the KGW implementation (Which could possibly be fine-tuned / improved?) is less efficient compared with the DGW that Groestlcoin uses. |
The code can be changed to cache the headers used every time a batch of headers are digested. This would mean only 4032 + 2000 reads are required to validate a 2000 header batch, rather than up to 4032*2000 with the current implementation. The change is purely implementation-level, no protocol changes are required. |
I don't think block reading is the problem, since the headers are already kept in memory from what I could derive. I added some additional profiling to understand where the most time is spent in the KGW function, and it seems to be this line. See this and this commit for my profiling code that narrowed it down to that line. Not sure what to do about improving the performance here, but i'm fairly sure that this is where the slowdown comes from. |
Comparing the KGW and the DGW code, the only difference I see is the division of the iteration variable https://github.com/Groestlcoin/groestlcoin/blob/2.16.3/src/groestlcoin.cpp#L128-L279 |
It seems to me that |
I've recently downloaded both the Vertcoin Core as well as Groestlcoin Core. I started the installs with VTC first, then GRS immediately after.
Despite having twice the number of blocks and a slightly larger blockchain size (~1GB more?), the GRS client has synced over half the blockchain before VTC has even finished headers, despite me having started GRS approx 2 minutes afterwards.
It's not a huge issue for most users, as many no doubt opt for Electrum or other SPV wallets, and even Core-wallet users only do the "initial" sync once, but it's worth noting nonetheless, and if there are any protocol-level changes that need to happen it's probably worth looking in to them with the upcoming Verthash release.
The MAX_HEADERS_RESULTS & MAX_BLOCKS_IN_TRANSIT_PER_PEER values in validation.h are the same for GRS as VTC so they must be doing something else clever that might be worth looking in to.
The text was updated successfully, but these errors were encountered: