<div dir="auto"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Jan 1, 2017 4:41 AM, "Kenneth Graunke" <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="quoted-text">On Sunday, January 1, 2017 1:34:27 AM PST Marek Olšák wrote:<br>
> From: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>><br>
><br>
> This reduces compile times by 4.5% with the Gallium noop driver and<br>
> gl_constants::<wbr>GLSLOptimizeConservatively == true.<br>
<br>
</div>Compile times of...what exactly? Do you have any statistics for this<br>
by itself?<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">I always use my shader-db with almost 30k shaders and I used the time command.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Assuming we add your helper, this patch looks reasonable.<br>
Reviewed-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
<br>
BTW, I suspect you could get some additional speed up by changing<br>
<br>
parser->output = ralloc_strdup(parser, "");<br>
<br>
to something like:<br>
<br>
parser->output = ralloc_size(parser, strlen(orig_concatenated_src))<wbr>;<br>
parser->output[0] = '\0';<br>
<br>
to try and avoid reallocations. rewrite_tail will realloc just enough<br>
space every time it allocates, which means once you reallocate, you're<br>
going to be calling realloc on every single token. Yuck!<br>
<br>
ralloc/talloc's string libraries were never meant for serious string<br>
processing like the preprocessor does. They're meant for convenience<br>
when constructing debug messages which don't need to be that efficient.<br>
<br>
Perhaps a better approach would be to have the preprocessor do this<br>
itself. Just ralloc_size() output and initialize the null byte.<br>
reralloc to double the size if you need more space. At the end of<br>
preprocessing, reralloc to output_length at the end of free any waste<br>
from doubling.<br>
<br>
I suspect that would be a *lot* more efficient, and is probably what<br>
we should have done in the first place...<br>
</blockquote></div><br></div><div class="gmail_extra" dir="auto">Sure. However, realloc is a no-op when there is free space after the allocation. It's a useless call, but it doesn't look too bad in a profiler.</div><div class="gmail_extra" dir="auto"><br></div><div class="gmail_extra" dir="auto">Marek</div></div></div>