-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Streaming Genesis #6936
Comments
I'm not sure how I feel about the proposal yet...I need to think on it more. But it just doesn't feel quite right with me. How are the files constructed? Is there a tool that breaks them up? In general, I would rather opt for a more idiomatic approach where we can construct a clean API for retrieving app data, say by module name and fields within a module's app data by key, where the actual streaming happens via a JSON scanner either via stdlib ( |
Okay if it were just a single file but with a similar API where items are retrieved via a path (i.e. I just want to note that the proposal of multiple files avoids needing to write custom JSON scanners. I couldn't figure out how to do that sort of random access with the current JSON APIs. The APIs that exist support streaming on the array level but not object level and so the whole JSON file would need to be loaded into memory if we don't split arrays out into separate files. |
Have we looked into things like https://github.com/lloyd/goj or https://github.com/mailru/easyjson (which looks very promising). Otherwise, we might have to write something custom? Edit: Also, https://github.com/buger/jsonparser which claims we can load only the keys we need. |
I tried looking for streaming JSON parsers, the challenge is integrated with proto JSON. Maybe we can make it work. Just not quite sure how. |
Replacing this with #11601 which has a concrete solution. |
Streaming genesis is useful when app state is large. Projects such as Terra have expressed concern around memory usage. It was not tackled in #5917 due to time constraints.
/cc @YunSuk-Yeo @dokwon
Here is my previous proposal from #5917 :
Also I've thought about how to approach streaming JSON based on some things @alpe has shared and just want to document the approach I have in mind. (I don't think we need to get to this quite yet.)
Here are the constraints I see:
I think we can solve this with the following approach:
genesis.json
file as now, or agenesis/
folderstaking.delegations
could live ingenesis/staking/delegations.json
root.json
in thegenesis/
folder contains all definitions that are not in the separate files. Anything which is in a separate file should be omitted fromroot.json
The API for this might look something like:
Using gogo jsonpb, there is already an
UnmarshalNext
method we can leverage: https://godoc.org/github.com/gogo/protobuf/jsonpb#Unmarshaler.UnmarshalNextThe text was updated successfully, but these errors were encountered: