microsoft / Power-Fx

Power Fx low-code programming language
MIT License
3.19k stars 321 forks source link

Optimization for function sets #2484

Closed MikeStall closed 3 months ago

MikeStall commented 3 months ago

Optimize the pattern where:

This PR is an optimization and there shouldn't be any functional changes. However - we should review some of the behavior around TexlFunctionSet to enable us to pursue more comprehensive optimizations.

Today, every call to Check() will compute the function set - which involves merging the function set from builtin functions plus the extra ones that were enabled. This is expensive because TexlFunctionSet will "flatten" and copy all the functions into a single list. (Contrast to how we compose SymbolTables - which is entirely deferred).

The optimization is to allow composing that once and caching it. But also to be sure we have correct invalidation strategy if anything changes. Added lots more tests as I discovered interesting corner cases.

This makes the benchmark use 1/10 the working set and run 3x faster.