On 09/02/2014 06:00 PM, Stefan Monnier wrote: > Have you made some preliminary measurements (on microbenchmarks) to try > and see how much speed up we might gain? Given the cost of strlen and > parse_str_as_multibyte, I'd expect that the best-case benefit might turn > out to be rather small. For the moment, I don't have an idea how to benchmark parse_str_as_multibyte in "near-to-real-use" conditions. But I guess that we can have some gain for "simple" (short, especially short unibyte) strings. That guess is based on the following results (note ~3x speedup in strcpy/strcat workload): $ gcc -Wall -O2 -o t-alloca t-alloca.c t-use.c $ $ /usr/bin/time ./t-alloca 100 100 Use malloc for allocation and sprintf for workload 2.23user 0.00system 0:02.23elapsed 100%CPU (0avgtext+0avgdata 1440maxresident)k 0inputs+0outputs (0major+59minor)pagefaults 0swaps $ $ /usr/bin/time ./t-alloca 100 100 x Use alloca for allocation and sprintf for workload 1.85user 0.00system 0:01.85elapsed 99%CPU (0avgtext+0avgdata 1436maxresident)k 0inputs+0outputs (0major+59minor)pagefaults 0swaps $ $ gcc -DFAST -Wall -O2 -o t-alloca t-alloca.c t-use.c $ $ /usr/bin/time ./t-alloca 100 100 Use malloc for allocation and strcpy/strcat for workload 0.56user 0.00system 0:00.56elapsed 99%CPU (0avgtext+0avgdata 1440maxresident)k 0inputs+0outputs (0major+59minor)pagefaults 0swaps $ $ /usr/bin/time ./t-alloca 100 100 x Use alloca for allocation and strcpy/strcat for workload 0.20user 0.00system 0:00.20elapsed 100%CPU (0avgtext+0avgdata 1440maxresident)k 0inputs+0outputs (0major+60minor)pagefaults 0swaps Dmitry