Skip to content

perf: Optimize protobuf parsing in Redis online store#6023

Open
abhijeet-dhumal wants to merge 2 commits intofeast-dev:masterfrom
abhijeet-dhumal:perf/optimize-redis-protobuf-parsing
Open

perf: Optimize protobuf parsing in Redis online store#6023
abhijeet-dhumal wants to merge 2 commits intofeast-dev:masterfrom
abhijeet-dhumal:perf/optimize-redis-protobuf-parsing

Conversation

@abhijeet-dhumal
Copy link
Contributor

@abhijeet-dhumal abhijeet-dhumal commented Feb 25, 2026

Summary

Optimize protobuf deserialization in the Redis online store to reduce latency in the feature retrieval hot path.

Changes

  • Avoid redundant bytes() conversion when data is already bytes type (Redis returns bytes)
  • Use list comprehension for more efficient batch conversion in _convert_redis_values_to_protobuf
  • Add return type annotation for better code clarity
  • Remove unnecessary else clause for cleaner control flow

Expected Behavior

Protobuf deserialization should skip unnecessary type conversions when data is already in the correct format.

Current Behavior

The code unconditionally calls bytes() on every value, even when the data is already bytes. For 50 entities × 200 features = 10,000 unnecessary conversion checks per request.

Performance Impact

  • Estimated savings: 2-5ms per request for typical workloads
  • Validated via: cProfile analysis of ParseFromString cumulative time

Steps to Reproduce

  1. Set up a Redis online store with a feature view containing 200 features
  2. Run get_online_features for 50 entities
  3. Profile with cProfile and observe ParseFromString overhead

Specifications

  • Version: 0.47.0+
  • Platform: All
  • Subsystem: sdk/python/feast/infra/online_stores/redis.py

Related

  • RHOAIENG-46061 (60ms p99 SLA target for online feature serving)

Open with Devin

@abhijeet-dhumal abhijeet-dhumal requested a review from a team as a code owner February 25, 2026 14:40
@abhijeet-dhumal abhijeet-dhumal changed the title perf: optimize protobuf parsing in Redis online store perf: Optimize protobuf parsing in Redis online store Feb 25, 2026
Signed-off-by: abhijeet-dhumal <abhijeetdhumal652@gmail.com>
@abhijeet-dhumal abhijeet-dhumal force-pushed the perf/optimize-redis-protobuf-parsing branch from 0f5fc75 to b6d8f45 Compare February 25, 2026 14:43
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Signed-off-by: abhijeet-dhumal <abhijeetdhumal652@gmail.com>
if ts_val:
res_ts.ParseFromString(bytes(ts_val))
res_ts.ParseFromString(
ts_val if isinstance(ts_val, bytes) else bytes(ts_val)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so 2-5ms per request savings from avoiding bytes() on already bytes value ?

if val_bin:
val.ParseFromString(bytes(val_bin))
val.ParseFromString(
val_bin if isinstance(val_bin, bytes) else bytes(val_bin)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isinstance seems unnecessary, Redis always returns bytes and also ParseFromString already accepts bytes natively, so no conversion needed. It can be simply:

val.ParseFromString(val_bin)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants