aboutsummaryrefslogtreecommitdiff
path: root/metrics
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2023-10-31 15:15:30 -0700
committerColin Cross <ccross@android.com>2023-11-01 15:15:15 -0700
commit95bec3331cc42db65c048a475b28022c7a303ec9 (patch)
treec138124ecd1358cf738e97248af77ff06d7d1eee /metrics
parent098c09334fefc9e061d061ec5cb491b4bbc83a4f (diff)
downloadblueprint-95bec3331cc42db65c048a475b28022c7a303ec9.tar.gz
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
Diffstat (limited to 'metrics')
0 files changed, 0 insertions, 0 deletions