You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use incremental JSON parser and checksum hasher in genesis doc provider #1302
Rework the built-in GenesisDocProvider implementation for streamability: the provider should not need to store the whole file content in RAM to parse the JSON or calculate the checksum.
DoD: The implementation uses an incremental parser (e.g. json.Decoder from the standard library) and an incremental SHA-256 hasher, so that the entire file content is not read into memory at once.
Thank you for this bug report @mzabaluev!
So the fix for this can be performed elegantly only if libs/json had a JSON parser that took in an io.Reader (as requested in the issue) by using io.TeeReader hypothetically like this
The big question though is how much demand and interest is there for the incremental parser? I can help out if there is demand deemed for this issue and I actually built a large part of go-amino JSON parsing some almost 7 years ago https://github.com/tendermint/go-amino/commits?author=odeke-em so am quite familiar. I know for sure a buffered parser will reduce the amount of RAM consumed but if that cost is incurred only one time and if not many resources are dedicated towards this task it might be futile.
@odeke-em The problem that motivated this issue in the first place is that some chains have a very big genesis file (mostly due to hard-forked chains), and that means the whole JSON needs to be held in memory at some point. This may enforce some stringent hardware requirements for nodes that want to sync from genesis (agreed it's not very common ATM, but that may change in the future when we tackle the "allow sync from Genesis" problem).
Polygon folks (Polygon runs an SDK-based chain as part of its architecture) have recently been hitting OOM in their tests related to this.
Activity
odeke-em commentedon Jan 2, 2024
Thank you for this bug report @mzabaluev!
So the fix for this can be performed elegantly only if libs/json had a JSON parser that took in an io.Reader (as requested in the issue) by using io.TeeReader hypothetically like this
Demand
The big question though is how much demand and interest is there for the incremental parser? I can help out if there is demand deemed for this issue and I actually built a large part of go-amino JSON parsing some almost 7 years ago https://github.com/tendermint/go-amino/commits?author=odeke-em so am quite familiar. I know for sure a buffered parser will reduce the amount of RAM consumed but if that cost is incurred only one time and if not many resources are dedicated towards this task it might be futile.
sergio-mena commentedon Jan 9, 2024
@odeke-em The problem that motivated this issue in the first place is that some chains have a very big genesis file (mostly due to hard-forked chains), and that means the whole JSON needs to be held in memory at some point. This may enforce some stringent hardware requirements for nodes that want to sync from genesis (agreed it's not very common ATM, but that may change in the future when we tackle the "allow sync from Genesis" problem).
Polygon folks (Polygon runs an SDK-based chain as part of its architecture) have recently been hitting OOM in their tests related to this.
andynog commentedon Sep 23, 2024
@alesforz can you please take this one over since yo are already working on related logic?