platform_build_blueprint/bootstrap
Colin Cross 95bec3331c Use strings instead of simpleNinjaStrings where possible
Storing every string without ninja variable references through
simpleNinjaString costs 24 bytes and a heap allocation.  16 bytes
is used for the ninjaString.str string, 8 bytes for the
ninjaString.variables *[]variableReference.  An additional 8 bytes
is used for the resulting pointer into the heap.

The vast majority of calls to simpleNinjaString originate in
blueprint.parseBuildParams, which converts all of the parameters
passed to ctx.Build into ninjaStrings.  All together this was
allocating 1.575 GB of *ninjaString objects.

Add a parseNinjaOrSimpleStrings function that converts input strings
into ninjaStrings if they have ninja variable references, but also
returns a slice of plain strings for input strings without any ninja
variable references.  That still results in 1.39 GB of allocations just
for the output string slice, so also add an optimization that reuses
the input string slice as the output slice if all of the strings had
no variable references.

Plumb the resulting strings through everywhere that the []*ninjaStrings
were used.

This reduces the total memory allocations inside
blueprint.parseBuildParams in my AOSP aosp_cf_x86_64_phone-userdebug
build from 3.337 GB to 1.786 GB.

Test: ninja_strings_test.go
Change-Id: I51bc138a2a6b1cc7383c7df0a483ccb067ffa02b
2023-11-01 15:15:15 -07:00
..
bpdoc Change bpdoc to separate entries with the same type 2021-11-02 15:59:48 +00:00
bpglob Remove the -v argument from bpglob. 2021-11-04 11:48:43 +01:00
bootstrap.go Always generate rules for blueprint tests 2023-10-24 11:05:56 -07:00
command.go Use strings instead of simpleNinjaStrings where possible 2023-11-01 15:15:15 -07:00
config.go Add VariableFuncContext argument to VariableFuncs 2022-11-04 18:21:31 +00:00
glob.go Make RunBlueprint() return an error, if need be. 2023-06-20 09:44:50 +00:00
writedocs.go Export goPackage and goBinary from bootstrap package 2023-06-22 23:50:02 +00:00