-
Notifications
You must be signed in to change notification settings - Fork 117
workaround for map declaration limit (ΛEnumTypes) #641
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
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). For more information, open the CLA check for this pull request. |
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 suggestion.
In these really huge generated modules, is the code actually usable - i.e., is the binary size, memory footprint, and IDE features like autocomplete's performance acceptable? Part of me says if you're getting to extremely large generated modules, then these issues will be more of a problem than we've seen with relatively modest sized modules, such that something like the module splits that @wenovus and @DanG100 were looking at before would be advantageous. However, this is a longer term workaround.
In the meantime, I added a comment here about how the split is done. I think it'd be useful to look at this, and then subsequently whether there are performance regressions of doing this that might impact existing users.
ygen/gogen.go
Outdated
@@ -418,6 +418,9 @@ var ( | |||
|
|||
func init() { | |||
var err error | |||
for i:=0; i < len(ΛEnumTypesKeys); i++{ |
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.
Why not just move creating the same type as below into init
? I'm not really a fan of splitting this into keys and data, since there is now some requirement for ordering to be the same between the two, which seems like a hidden assumption.
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.
My take was, that it needed to be slices rather then a map and this was the proposed workaround in the referred thread.
However I've tested adding the map declaration into init(). Works fine so I'll try to change as proposed.
I did now push the ΛEnumTypes population into a function which is being called on init(). |
Well lets be honest a go file of over 100MB that's not going to auto-complete like a charm. But for diffing and validation etc. that code works perfectly fine. |
Finally also fixed all the tests and merged latest master. |
Looks good @steiler, do you have the numbers on how big the binary size increase is (The .a files for |
So it's |
@robshakir Does this look good to you? |
As described in #640, When working with very large yang models like for instance Nokia SROS (https://github.com/nokia/7x50_YangModels/tree/master/latest_sros_22.2) the resulting
ΛEnumTypes
map exceeds certain golang limits.As described in golang/go#33437 (comment) maps of too large size cannot be defined declaratively.
This PR is to implement the workaround mentioned in the above referenced issue. The
ΛEnumTypes
map is split into a Key (ΛEnumTypesKeys
) and a Value (ΛEnumTypesValues
) Slice and composed to theΛEnumTypes
map in theinit()
fuction. Which works around the declerative issue.I am not sure about possible performance constraints or any other impact of this workaround. If that would be a problem, I can think of a more elaborate approach where this workaround is just applied when the map size is too large, otherwise the regular declarative approach is used.