GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — perf: Optimize protobuf parsing in Redis online store by abhijeet-dhumal · Pull Request #6023 · feast-dev/feast

perf: Optimize protobuf parsing in Redis online store #6023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
ntkathole merged 3 commits into feast-dev:master from abhijeet-dhumal:perf/optimize-redis-protobuf-parsing
Mar 2, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

perf: Optimize protobuf parsing in Redis online store #6023

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
3 commits
Select commit Hold shift + click to select a range
d37720a
perf: Optimize protobuf parsing in Redis online store
abhijeet-dhumal Feb 25, 2026
710283b
test: add unit tests for Redis protobuf parsing optimization
abhijeet-dhumal Feb 25, 2026
e0503cc
fix: Remove redundant isinstance checks for Redis protobuf parsing
abhijeet-dhumal Mar 2, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

31 changes: 14 additions & 17 deletions 31 sdk/python/feast/infra/online_stores/redis.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,11 @@ def _convert_redis_values_to_protobuf(
redis_values: List[List[ByteString]],
feature_view: str,
requested_features: List[str],
):
result: List[Tuple[Optional[datetime], Optional[Dict[str, ValueProto]]]] = []
for values in redis_values:
features = self._get_features_for_entity(
values, feature_view, requested_features
)
result.append(features)
return result
) -> List[Tuple[Optional[datetime], Optional[Dict[str, ValueProto]]]]:
return [
self._get_features_for_entity(values, feature_view, requested_features)
for values in redis_values
]

def online_read(
self,
Expand Down Expand Up @@ -445,21 +442,21 @@ def _get_features_for_entity(
res_val = dict(zip(requested_features, values))

res_ts = Timestamp()
ts_val = res_val.pop(f"_ts:{feature_view}")
ts_key = f"_ts:{feature_view}"
ts_val = res_val.pop(ts_key)
if ts_val:
res_ts.ParseFromString(bytes(ts_val))
res_ts.ParseFromString(ts_val)

res = {}
res: Dict[str, ValueProto] = {}
for feature_name, val_bin in res_val.items():
val = ValueProto()
if val_bin:
val.ParseFromString(bytes(val_bin))
val.ParseFromString(val_bin)
res[feature_name] = val

if not res:
return None, None
else:
# reconstruct full timestamp including nanos
total_seconds = res_ts.seconds + res_ts.nanos / 1_000_000_000.0
timestamp = datetime.fromtimestamp(total_seconds, tz=timezone.utc)
return timestamp, res

total_seconds = res_ts.seconds + res_ts.nanos / 1_000_000_000.0
timestamp = datetime.fromtimestamp(total_seconds, tz=timezone.utc)
return timestamp, res
124 changes: 124 additions & 0 deletions 124 sdk/python/tests/unit/infra/online_store/test_redis.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,127 @@ def test_get_features_for_entity(redis_online_store: RedisOnlineStore, feature_v
assert "feature_view_1:feature_11" in features
assert features["feature_view_1:feature_10"].int32_val == 1
assert features["feature_view_1:feature_11"].int32_val == 2


def test_get_features_for_entity_with_memoryview(
redis_online_store: RedisOnlineStore, feature_view
):
"""Test that _get_features_for_entity handles memoryview inputs correctly.

Redis may return memoryview objects instead of bytes in some cases.
The optimized code should handle both without unnecessary conversions.
"""
requested_features = [
"feature_view_1:feature_10",
"feature_view_1:feature_11",
"_ts:feature_view_1",
]
# Create memoryview objects to simulate redis returning memoryview
val1_bytes = ValueProto(int32_val=100).SerializeToString()
val2_bytes = ValueProto(int32_val=200).SerializeToString()
ts_bytes = Timestamp(seconds=1234567890, nanos=123456789).SerializeToString()

values = [
memoryview(val1_bytes),
memoryview(val2_bytes),
memoryview(ts_bytes),
]

timestamp, features = redis_online_store._get_features_for_entity(
values=values,
feature_view=feature_view.name,
requested_features=requested_features,
)
assert features["feature_view_1:feature_10"].int32_val == 100
assert features["feature_view_1:feature_11"].int32_val == 200
assert timestamp is not None


def test_get_features_for_entity_with_none_values(
redis_online_store: RedisOnlineStore, feature_view
):
"""Test that _get_features_for_entity handles None values correctly."""
requested_features = [
"feature_view_1:feature_10",
"feature_view_1:feature_11",
"_ts:feature_view_1",
]
values = [
ValueProto(int32_val=1).SerializeToString(),
None, # Missing feature value
Timestamp().SerializeToString(),
]

timestamp, features = redis_online_store._get_features_for_entity(
values=values,
feature_view=feature_view.name,
requested_features=requested_features,
)
assert features["feature_view_1:feature_10"].int32_val == 1
# None value should result in empty ValueProto
assert features["feature_view_1:feature_11"].WhichOneof("val") is None


def test_convert_redis_values_to_protobuf_multiple_entities(
redis_online_store: RedisOnlineStore, feature_view
):
"""Test batch conversion with multiple entities."""
requested_features = [
"feature_view_1:feature_10",
"feature_view_1:feature_11",
"_ts:feature_view_1",
]
# Multiple entity values
values = [
[
ValueProto(int32_val=1).SerializeToString(),
ValueProto(int32_val=2).SerializeToString(),
Timestamp(seconds=1000).SerializeToString(),
],
[
ValueProto(int32_val=10).SerializeToString(),
ValueProto(int32_val=20).SerializeToString(),
Timestamp(seconds=2000).SerializeToString(),
],
[
ValueProto(int32_val=100).SerializeToString(),
ValueProto(int32_val=200).SerializeToString(),
Timestamp(seconds=3000).SerializeToString(),
],
]

results = redis_online_store._convert_redis_values_to_protobuf(
redis_values=values,
feature_view=feature_view.name,
requested_features=requested_features,
)

assert len(results) == 3
assert results[0][1]["feature_view_1:feature_10"].int32_val == 1
assert results[1][1]["feature_view_1:feature_10"].int32_val == 10
assert results[2][1]["feature_view_1:feature_10"].int32_val == 100


def test_get_features_for_entity_with_all_none_values(
redis_online_store: RedisOnlineStore, feature_view
):
"""Test that None feature values result in empty ValueProto objects."""
requested_features = [
"feature_view_1:feature_10",
"_ts:feature_view_1",
]
# All None values except timestamp
values = [
None,
Timestamp().SerializeToString(),
]

timestamp, features = redis_online_store._get_features_for_entity(
values=values,
feature_view=feature_view.name,
requested_features=requested_features,
)
# Even with None value, an empty ValueProto is created
assert features is not None
assert "feature_view_1:feature_10" in features
assert features["feature_view_1:feature_10"].WhichOneof("val") is None
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.