Skip to content

Reduce number of expression tree traversals in funcletization and caching #16492

@roji

Description

@roji

Note: the following are some perf observations/ideas as a result of looking at the code - no profiling was done to ensure that this is a perf-critical area in the grand scheme of things. We should profile carefully before doing anything.


Following is a list of full tree traversal that we do for each query we execute (before compilation):

Parameter extraction:

Query caching:

  • One pass to calculate the hash code of the query
  • One pass per query in the cache with the same hash code, for Equals

So we're traversing the query tree at least four times for a cached query. We may be able to improve this by:

  • Use a trie structure instead of the current dictionary (IMemoryCache), similar to trie-based string lookups.
  • Merge parameter extraction with the trie traversal. As we're traversing the tree to find a cached entry, we also perform parameter extraction.

We should keep possible optimizations like this in mind when determining what is public and what isn't, to avoid breaking changes.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions