Expression Tree Interning for Query Memory Optimization

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing data retrieval systems face inefficiencies in processing large numbers of queries with shared semantics, leading to increased memory usage and resource consumption due to the lack of mechanisms for sharing expression tree nodes and subtrees.

Innovation Solution

The implementation of expression tree internment and hashing allows for the sharing of nodes and subtrees with shared semantics, reducing memory needs and resource consumption by storing and reusing interned nodes and hash codes in a cache, and utilizing a lazy evaluation strategy to delay computation until necessary.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If expression trees are processed without interning mechanisms, then each query is processed independently with full expression tree creation, but memory usage and resource consumption increase significantly when processing large numbers of queries with shared semantics

Engineering Contradiction:
Improvequery processing efficiencyVSAvoidmemory usage
Core Design Contradiction:
ProductivityVSQuantity of substance

Solution Approach 1:

The patent merges identical expression tree nodes from different queries into a shared intern pool. When the same expression pattern is detected across multiple queries, only one instance is created and stored in the intern pool, while subsequent queries reference the shared instance. This combining of identical nodes eliminates redundant memory allocations and reduces overall memory consumption while maintaining query processing capabilities.

Inventive Principle:
Principle #5Merging (Combining)

Solution Approach 2:

The intern pool serves as a universal storage mechanism that can hold and share expression tree nodes across multiple queries. A single interned node can be referenced by numerous different queries that share the same expression semantics, making the node universally applicable. This multi-functionality allows the same node instance to serve multiple queries simultaneously, reducing the total number of nodes needed in memory.

Inventive Principle:
Principle #6Universality (Multi-functionality)

2Quantity of substance

If expression tree nodes are stored and shared in a cache, then memory requirements are reduced and processing efficiency improves, but additional overhead is introduced for hash code computation and cache lookup

Engineering Contradiction:
Improvememory requirementsVSAvoidprocessing overhead
Core Design Contradiction:
Quantity of substanceVSDevice complexity

Solution Approach 1:

The patent computes hash codes for expression tree nodes during the initial creation and internment process, storing the hash code alongside the node in the intern pool. This preliminary computation avoids the need to recompute hash codes during subsequent lookup operations. When a query needs to check for existing nodes, the system can quickly compute a hash and perform a direct cache lookup rather than performing complex tree comparisons, thereby reducing the overhead of the interning mechanism.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent creates simplified copy representations of expression trees with associated hash codes for storage in the intern pool. These copied representations maintain the essential structural and semantic information needed for identification and matching, while being more compact and efficient for storage and comparison purposes. The copy includes a hash code that enables rapid lookup without requiring full tree traversal and comparison.

Inventive Principle:
Principle #26Copying

3Loss of energy

If lazy evaluation strategy is used to delay computation until necessary, then unnecessary computations are avoided and resources are conserved, but computation timing becomes more complex to manage

Engineering Contradiction:
Improveresource consumptionVSAvoidcomputation timing management
Core Design Contradiction:
Loss of energyVSDevice complexity

Solution Approach 1:

The patent implements dynamic computation timing where expression tree nodes are only fully created and processed when actually needed by a query. During query compilation, the system checks the intern pool first and only creates new nodes if no matching node exists. This dynamic approach allows the system to adapt computation timing based on actual usage patterns, avoiding the creation of nodes that may never be used, while maintaining simple management through straightforward lookup-before-creation logic.

Inventive Principle:
Principle #15Dynamics

Data Source

PatentUS10318511B2Expression tree interning
Publication Date: 2019.06.11 MICROSOFT TECHNOLOGY LICENSING LLC
  • US10318511B2 patent drawing
  • US10318511B2 patent drawing
  • US10318511B2 patent drawing

AI summary

In non-limiting examples of the present disclosure, systems and methods for interning expression trees are provided. Hash code for a plurality of expression tree nodes is recursively computed and a determination is made as to whether hash code for each of a plurality of expression tree nodes is stored in a cached intern pool. Upon determining that at least one of a plurality of expression tree nodes is not stored in a cached intern pool, one or more functions may be run on at least one of a plurality of expression tree nodes for determining whether at least one of a plurality of expression tree nodes should be stored in a cached intern pool. Normalization of expression trees may also be employed to effectuate effective sharing of expression tree nodes.