Tiling with Intermediate Representations
Overview
Tiling is an optimization technique for streaming time-windowed aggregations that enables massively efficient feature computation by pre-aggregating data into smaller time intervals (tiles) and storing Intermediate Representations (IRs) for correct merging.
Primary Use Case: Streaming
Tiling provides speedup for streaming scenarios where features are updated frequently (every few minutes) from sources like Kafka, Kinesis, or PushSource.
Key Benefits (Streaming):
Faster: Reuse 90%+ of tiles between updates instead of recomputing from scratch
Correct results: IRs ensure mathematically accurate merging for all aggregation types
Memory efficient: Only process new events, reuse previous tiles in memory
Real-time capable: Handle high-throughput streaming with low latency
Incremental updates: Compute 1 new tile instead of rescanning entire window
The Problem: Why Intermediate Representations?
Traditional approaches to time-windowed aggregations either:
Recompute from raw data every time → Slow, expensive
Store final aggregated values per tile → Fast but often incorrect when merging
The Merging Problem
You cannot correctly merge many common aggregations:
The same problem exists for:
Standard deviation (
std)Variance (
var)Median and percentiles
Any "holistic" aggregation that requires knowledge of all values
The Solution: Intermediate Representations (IRs)
Instead of storing final aggregated values, store intermediate data that preserves the mathematical properties needed for correct merging.
Example: Average
Traditional (Incorrect):
With IRs (Correct):
Aggregation Categories
Algebraic Aggregations
These can be merged by applying the same aggregation function to tiles:
sum
sum
sum(tile_sums)
1 column
count
count
sum(tile_counts)
1 column
max
max
max(tile_maxes)
1 column
min
min
min(tile_mins)
1 column
No IRs needed - the final value is the IR!
Holistic Aggregations
These require storing multiple intermediate values:
Average (avg, mean)
Stored IRs: sum, count
Final computation: avg = sum / count
Merge strategy: Sum the sums and counts, then divide
Storage: 3 columns (final + 2 IRs)
Standard Deviation (std, stddev)
Stored IRs: count, sum, sum_of_squares
Final computation:
Merge strategy: Sum all three IRs, then apply formula
Storage: 4 columns (final + 3 IRs)
Variance (var, variance)
Stored IRs: count, sum, sum_of_squares
Final computation: Same as std but without sqrt()
Storage: 4 columns (final + 3 IRs)
How Tiling Works
Tiling is optimized for streaming scenarios with frequent updates (e.g., every few minutes).
1. Continuous Tile Updates
Why It's Fast:
Without tiling: Scan entire 1-hour window (1000+ events) every 5 minutes
With tiling: Only process 5 minutes of new events, reuse previous tiles
Speedup: Faster for streaming updates!
2. Streaming Update Efficiency
T=00:00
Compute 1hr
Compute 12 tiles
0% reuse (initial)
T=00:05
Compute 1hr (1000+ events)
Compute 1 tile + reuse 11
92% reuse
T=00:10
Compute 1hr (1000+ events)
Compute 1 tile + reuse 11
92% reuse
T=00:15
Compute 1hr (1000+ events)
Compute 1 tile + reuse 11
92% reuse
Key Benefit: Tiles stay in memory during the streaming session, enabling massive reuse.
Tiling Algorithm
Sawtooth Window Tiling
Partition events into hop-sized intervals (e.g., 5 minutes)
Compute cumulative tail aggregations for each hop from the start of the materialization window
Subtract tiles to form windowed aggregations (current_tile - previous_tile)
Store IRs for correct merging of holistic aggregations
At materialization, store windowed aggregations in online store
Benefits:
Efficient query-time performance (pre-computed windows)
Minimal storage overhead (only hop-sized tiles)
Mathematically correct for all aggregation types
Configuration
Recommended: StreamFeatureView (Streaming Scenarios)
Tiling provides maximum benefit for streaming scenarios with frequent updates:
When to Enable:
Streaming data sources (Kafka, Kinesis, PushSource)
Frequent updates (every few minutes)
Real-time feature serving
High-throughput event processing
Key Parameters
aggregations: List of time-windowed aggregations to compute. EachAggregationaccepts:column: source column to aggregatefunction: aggregation function (sum,avg,mean,min,max,count,std)time_window: duration of the aggregation windowslide_interval: hop/slide size (defaults totime_window)name(optional): output feature name. Defaults to{function}_{column}(e.g.,sum_amount). Set this to use a custom name (e.g.,name="sum_amount_1h").
timestamp_field: Column name for timestamps (required when aggregations are specified)enable_tiling: Enable tiling optimization (default:False)Set to
Truefor streaming scenarios
tiling_hop_size: Time interval between tiles (default: 5 minutes)Smaller = more granular tiles, potentially higher memory during processing window
Larger = less granular tiles, potentially lower memory during processing window
Compute Engine Requirements
Spark Compute Engine: Fully supported for streaming and batch
Ray Compute Engine: Fully supported for streaming and batch
Local Compute Engine: Does NOT support time-windowed aggregations
Architecture
Tiling in Feast uses a simple, pure pandas architecture that works with any compute engine:
How It Works
Summary
Tiling with Intermediate Representations provides a powerful optimization for streaming time-windowed aggregations in Feast.
Last updated
Was this helpful?