runtime,cmd/compile: string concatenation specializations for performance #27801
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
CL123256 started a discussion on which strings concatenation specialization we should choose (if any).
String concatenation can be made faster if we specialize concatenation with escaping result and len(args)<=5 (N) arguments. Escaping result means that we can avoid passing
buf
that is alwaysnil
as well as userawstring
instead ofrawstringtmp
. Known N means that we can unroll loops.There are several ways (and these are not all of them):
x+y
. Less code, seems like most frequent, the boost is maximal, but does not improve any other concatenation (likex+y+z
which usesconcatstring3
).I've started from (1) since it's the easiest change that requires less amount of changes and gives significant performance gain. But in order to have decision extra feedback is required.
Here is comparison of (1) against unoptimized concat:
Comparison for (4) implementation against go tip:
Note that these numbers represent overhead savings, not general case strings concatenation performance boost, since length of strings determine these timings significantly.
Benchmarks:
I would like to know:
CC @martisch
The text was updated successfully, but these errors were encountered: