XPath Cache Optimization via Hardcoded Value Generalization
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Current XPath expression caches are inefficient due to storage limitations, leading to rapid cache exhaustion and increased cache misses when processing XML documents with similar XPath expressions differing only by hardcoded values, resulting in frequent reparsing and recompilation of expressions.
Innovation Solution
Identify and replace hardcoded values in similar XPath expressions with variable identifiers, generating a cache-optimized XPath expression that is stored in a cache-optimized function, reducing the number of compiled expressions needed in the cache and increasing storage efficiency.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If XPath expressions with hardcoded values are stored individually in the cache, then each expression can be compiled and executed correctly, but the cache is exhausted rapidly and cache misses increase due to storage limitations
Solution Approach 1:
The patent creates a universal template XPath expression that can represent multiple specific expressions with different hardcoded values. The template uses parameters (e.g., @id=$id, @name=$name) instead of fixed values, allowing a single cached expression to serve multiple query patterns. When a query arrives, the system substitutes the appropriate values into the template parameters, enabling one cached expression to handle many variations without requiring separate cache entries for each specific expression.
2Productivity
If multiple similar XPath expressions are stored in the cache, then each can be optimized for its specific hardcoded values, but the cache memory is consumed quickly leading to frequent evictions and cache thrashing
Solution Approach 1:
By storing a universal template expression with parameters instead of multiple specific expressions, the system extends the effective retention time of cached items. The single template expression remains valid and useful for many different queries over time, whereas multiple specific expressions would each have limited utility and be evicted quickly. This approach maintains high execution efficiency by keeping the optimized template structure in cache while adapting it to different value combinations.
3Quantity of substance
If hardcoded values are replaced with variable identifiers to create a cache-optimized expression, then storage efficiency improves and cache capacity increases, but additional processing is required to substitute values at runtime
Solution Approach 1:
The system performs preliminary analysis during expression creation or first use to identify which values are hardcoded and can be generalized into parameters. This preliminary action transforms specific expressions into universal templates with parameter placeholders. The substitution of actual values into these parameters happens automatically at runtime through a straightforward parameter binding mechanism, rather than requiring complex analysis each time. This preliminary generalization reduces the overall complexity by establishing a reusable pattern.
Data Source
AI summary
Approaches presented herein enable optimization of a cache of compiled XML Path Language (XPath) expressions by removing variability from XPath expressions. More specifically, XPath expressions are identified that are the same but for one or more hardcoded values. These hardcoded values are identified and replaced in an identified XPath expression with an identifier to form a cache optimized XPath expression that lacks the hardcoded value variability of the identified XPath expressions. This cache optimized XPath expression is inserted into a cache optimized function that receives the hardcoded value as arguments and assigns the received hardcoded value to the identifier in the cache optimized XPath expression. The identified XPath expressions are then rewritten as calls to the cache optimized function or to another function wrapping the cache optimized function. Therefore, only the cache optimized XPath expression, instead of several of the identified XPath expressions, is stored in the XPath expression cache.


