-
Notifications
You must be signed in to change notification settings - Fork 17
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
On-demand feature struct allocation #696
Conversation
LCOV of commit
|
core/feature.go
Outdated
@@ -71,20 +67,14 @@ func (f *Features) Init(properties *config.Properties, list ...interface{}) { | |||
for i, featureName := range properties.FeatureList { | |||
fields[i] = reflect.StructField{ | |||
Name: featurePropertyName(featureName), | |||
Type: reflect.TypeOf(singleFeature{}), | |||
Type: reflect.PointerTo(propsType), |
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.
I guess we need to use PtrTo if we're still supporting go versions before 1.18
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.
Yep - done :)
Bob's conditionals in modules ("features") can use significant amounts of RAM during build.bp parsing - each config option spawns a new struct containing a copy of each build property, resulting in a multiplicative impact on memory consumption. Fortunately, close inspection of Blueprint's "unpack" code reveals that we can instead pass in a nil pointer to the struct, instead of initialising the properties for each conditional feature, which will cause property structs to be allocated only when actually used in the build.bp file. Use this in Bob by making the property struct for each feature a nil pointer to the property struct type, instead of a fully-instantiated interface{} wrapped in a BlueprintEmbed. Signed-off-by: Chris Diamand <chris.diamand@arm.com> Change-Id: I42e432fcaa8f1f5cd48ba01c53cb95ce5109aa07
4065645
to
23dbdf5
Compare
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!
Bob's conditionals in modules ("features") can use significant amounts of RAM during build.bp parsing - each config option spawns a new struct containing a copy of each build property, resulting in a multiplicative impact on memory consumption.
Fortunately, close inspection of Blueprint's "unpack" code reveals that we can instead pass in a nil pointer to the struct, instead of initialising the properties for each conditional feature, which will cause property structs to be allocated only when actually used in the build.bp file.
Use this in Bob by making the property struct for each feature a nil pointer to the property struct type, instead of a fully-instantiated interface{} wrapped in a BlueprintEmbed.
Change-Id: I42e432fcaa8f1f5cd48ba01c53cb95ce5109aa07