preproc/symtable (preproc:symtable-complete): Do not re-process imported symbols

It's embarrassing how much time this saved on builds.

This apparently has always been doing a linear scan on the entire symbol
table for _every single param in the symbol table_, including those that
were imported.  This is not only unnecessary, but has no effect on the end
result of the system.

This cut build times almost in half, due to the number of symbols in some of
our packages.  All for unnecessary work.

Like most things that have quadratic (or polynomial) time complexity, they
don't show up during initial development, and are hard to even profile for,
because their effects are so small.  Now that our system has grown
substantially, it had a massive effect.

DEV-15114
main
Mike Gerwitz 2023-10-16 11:34:46 -04:00
parent c1770d39ff
commit b82294b1bd
3 changed files with 13 additions and 2 deletions

View File

@ -843,7 +843,8 @@
</template>
<template match="preproc:sym[ @type='param' ]" mode="preproc:symtable-complete" priority="5">
<template mode="preproc:symtable-complete" priority="5"
match="preproc:sym[ @need-resolve-dtype='true' ]">
<param name="syms" as="element( preproc:sym )*" />
<!-- attempt to derive type information from a typedef -->
@ -863,7 +864,7 @@
<!-- complete datatype with primitive -->
<copy>
<sequence select="@*" />
<sequence select="@*[ not( local-name() = 'need-resolve-dtype' ) ]" />
<attribute name="dtype" select="$typedef/@dtype" />
</copy>
</template>

View File

@ -345,11 +345,16 @@
<variable name="dim" as="xs:integer"
select="_symtable:str-to-dim( @set )" />
<!-- @need-resolve-dtype flags this symbol as needing further processing
to resolve @dtype, which we cannot do until we know we have a full
symbol table that includes the necessary typedef referenced by the
current value of @dtype -->
<preproc:sym type="param"
name="{@name}"
dim="{$dim}"
desc="{@desc}"
dtype="{@type}"
need-resolve-dtype="true"
default="{@default}"
tex="{@sym}" />
</template>

View File

@ -63,6 +63,7 @@
dim="1"
desc="Vector param"
dtype="footype"
need-resolve-dtype="true"
default=""
tex="" />
@ -71,6 +72,7 @@
dim="2"
desc="Matrix param with TeX"
dtype="tex"
need-resolve-dtype="true"
default=""
tex="\tex" />
@ -79,6 +81,7 @@
dim="0"
desc="Scalar param (implicit)"
dtype="bar"
need-resolve-dtype="true"
default=""
tex="" />
@ -87,6 +90,7 @@
dim="0"
desc="Scalar param (explicit)"
dtype="bar"
need-resolve-dtype="true"
default=""
tex="" />
@ -95,6 +99,7 @@
dim="-1"
desc="Unknown dimension"
dtype="wtf"
need-resolve-dtype="true"
default=""
tex="" />
</expect>