Make ninjaString an interface
There are 8935901 *ninjaString objects generated in an AOSP aosp_blueline-userdebug build, and 7865180 of those are a literal string with no ninja variables. Each of those *ninjaString objects takes a minimum of 48 bytes for 2 slices, plus 8 bytes for the pointer to the ninjaString. For the literal string case, one of those slices has a single element, (costing another 16 bytes for the backing array), and the other slice is empty, for a total of 72 bytes. Replace *ninjaString with a ninjaString interface. This increases the size of the reference from 8 bytes to 16 bytes, but using a type alias of a string for the literal string implementation uses only 16 bytes, saving 40 bytes per literal string or 314 MB. Test: ninja_strings_test Change-Id: Ic5fe16ed1f2a244fe6a8ccdf762919634d825cbe
Loading
Please register or sign in to comment