GeezerVison is showing github.com — [perf] Replace MessageToDict with optimized custom dict builder - 4x faster JSON serialization · Issue #6013 · feast-dev/feast
[perf] Replace MessageToDict with optimized custom dict builder - 4x faster JSON serialization #6013
Description
Current Behavior
The feature server's /get-online-features endpoint uses google.protobuf.json_format.MessageToDict to convert protobuf responses to JSON. MessageToDict is a generic converter designed for any protobuf type, but for the known GetOnlineFeaturesResponse structure, a type-specific converter is 4x faster.
Steps to reproduce
- Deploy Feast feature server to Kubernetes
- Call /get-online-features with 100 entities and 50 features
- Profile the endpoint and isolate MessageToDict time
- Observe ~12ms spent in MessageToDict (98% of serialization time)
- Compare with proto binary serialization which takes only 0.1ms
- Implement custom dict builder and observe 2.9ms (4x improvement)
Specifications
- Feast version: 0.60.0
- Python version: 3.11
- Tested on: OpenShift/Kubernetes with Redis, PostgreSQL, DynamoDB
Benchmark Results
Tested with 100 entities, 50 features in-cluster:
Current (MessageToDict + orjson): 12.0ms
- MessageToDict only: 11.8ms (98% of time!)
- orjson (dict→JSON): 0.2ms
Custom dict builder + orjson: 2.9ms
- Custom builder: 2.7ms
- orjson (dict→JSON): 0.2ms
Proto binary (for comparison): 0.1ms
Why MessageToDict is Slow
- Reflection-based field discovery for ANY protobuf message
- Dynamic type checking for each field
- Generic handling of all value types (oneofs, repeated, maps)
- CamelCase/snake_case conversion logic
- For GetOnlineFeaturesResponse, we know the exact schema, so all this reflection is unnecessary.
Possible Solution
Add sdk/python/feast/feature_server_utils.py with a custom dict builder
| Metric |
Before |
After |
Improvement |
| Serialization (100 entities) |
12.0ms |
2.9ms |
4.1x faster |
| Serialization (500 entities) |
~55ms |
~13ms |
4.2x faster |
Activity
abhijeet-dhumal commented on Feb 24, 2026
ContributorAuthor
More actions
added 7 commits that reference this issue
on Feb 24, 2026This issue will close once commit 8254e03 is merged into the 'master' branch.8254e03 This issue will close once commit ec333c4 is merged into the 'master' branch.ec333c4 This issue will close once commit ddf4f97 is merged into the 'master' branch.ddf4f97 This issue will close once commit 865313e is merged into the 'master' branch.865313e This issue will close once commit 6e4b59a is merged into the 'master' branch.6e4b59a This issue will close once commit 6a38f3c is merged into the 'master' branch.6a38f3c This issue will close once commit 2b81774 is merged into the 'master' branch.2b81774 added a commit that references this issue
on Feb 25, 2026This issue will close once commit d3c512d is merged into the 'master' branch.d3c512d
Metadata
Metadata
Development
No branches or pull requestsIssue actions