-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Make reading json genesis file faster #11868
Make reading json genesis file faster #11868
Conversation
Thanks! Out of interest: How are you creating the forked chain-specs of your network? Do you have own tooling? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Maybe using of the BufReader can be a decent option: with a large buffer it won't be much different from |
Isn't the Anyway, from what I can see the main reason why this was so slow was that the file was read completely unbuffered, which meant that every time However, just doing an I'm fine with leaving it to just use |
The only concern that always bothers me when using |
Yeah, but in this case we're doing this essentially only at startup, and if the file is changed underneath then it'll most likely either result in a read error (because the JSON will be garbage) or in a SIGBUS being sent and the process will be killed (if the file's truncated enough to cross a page boundary). We're already using mmap in e.g. paritydb for indexes, and there any shenanigans could be considerably more catastrophic, so I wouldn't worry about it in this particular case. |
Benchmark: (~5.5GB file, 5950X/64GB, SSD) from_reader (default): ~42:30 min
mmap : ~6:30 min
BufReader (8kB): ~8:00 min
BufReader (2MB): ~7:50 min
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the test!
The CI still needs a format.
Just curious, what buffer size have you tested? I would suggest to use about 1-2Mb. |
I've updated the results to include BufReader with 2Mb capacity. It doesn't change much |
should be good now |
* Make reading json genesis file faster * Formatting * fmt
* Make reading json genesis file faster * Formatting * fmt
Optimize the time to load the genesis from json file. Fixes #11867
I loads a genesis file of 5GB in 5 minutes instead of 1h30.