Title: feat: Batch Postgres online reads across feature views by DKilkenny · Pull Request #6832 · feast-dev/feast · GitHub
Open Graph Title: feat: Batch Postgres online reads across feature views by DKilkenny · Pull Request #6832 · feast-dev/feast
X Title: feat: Batch Postgres online reads across feature views by DKilkenny · Pull Request #6832 · feast-dev/feast
Description: What this PR does / why we need it: The generic OnlineStore._read_features_per_fv loop issues one online_read per feature view, so a request spanning N feature views costs N round trips. Redis already overrides that seam to batch; Postgres now does too, which is the follow-up described in #3259. Postgres keeps each feature view in its own table, so the per-view reads can go out as one UNION ALL. Each branch carries a constant tag column and the combined result is split back apart by it. The tag is doing real work here: the table name is not in the result set, and two feature views can return both the same entity key and the same feature name. Both the sync and async seams are overridden. When this helps, and when it does not. Batching trades round trips for holding more rows at once, so it only pays where round trips dominate. Measured against Postgres 16 with a 2 ms delay injected per execute to stand in for a remote database: shape batched generic speedup 10 views, 1 entity 6.1 ms, 1 query 34.3 ms, 10 queries 5.6x 10 views, 10 entities 13.4 ms, 1 query 41.1 ms, 10 queries 3.1x 25 views, 10 entities 27.6 ms, 1 query 108.7 ms, 25 queries 3.9x 10 views, 5000 entities 4417 ms 4357 ms 0.99x At 5000 entities there is no saving left, and holding every view's rows before emitting any of them took peak memory to 85 MB against a flat 9.6 MB for the generic path. That is the wrong trade for a concurrent feature server, so requests above MAX_BATCHED_READ_KEYS entity keys fall through to the generic path, which processes and releases one view at a time. Memory at that size is now identical to before. The check reads the request shape before any keys are serialized, so declining to batch costs nothing. That 2048 threshold is my number from the measurements above, taken on a laptop against a container. Happy to move it, make it configurable, or drop it entirely if you would rather this always batch. Two things worth flagging. Postgres does not advertise async_supported, so _read_features_per_fv_async is not reachable from the feature server today; it is implemented and verified against a real database so that it behaves whenever that changes. And the docs diff is slightly wider than the feature, because four lines described Redis and Postgres as overriding get_online_features when both override _read_features_per_fv. Three of those were already there, and correcting them seemed better than adding a fifth alongside. No changes to online_store.py, so the base class contract is untouched. Which issue(s) this PR fixes: Refs #3259 Checks I've made sure the tests are passing. My commits are signed off (git commit -s) My PR title follows conventional commits format Testing Strategy Unit tests Integration tests Manual tests Testing is not required for this change 10 unit tests and 6 integration tests. The integration tests run the same request through the batched path and through OnlineStore._read_features_per_fv and assert the protobuf responses are identical, including the case where an entity exists in one view but not another. I mutation tested these rather than trusting a green run. Ignoring the tag, executing the query twice, cross wiring one view's entity index mapping onto another, and disabling the size guard each fail exactly the tests meant to catch them. Two of those slipped past an earlier version of the tests, which is why the demux tests give both feature views the same feature name: with different names a crossed bucket still resolves the right value and the test proves nothing. The tests/unit/infra suite is unchanged at 41 failed / 279 passed before and 41 failed / 289 passed after, same pre-existing failures plus the new tests. Those failures and the 27 collection errors are missing optional extras in my environment, not related to this change. ruff and mypy are clean. The numbers in the table above come from a manual benchmark against a Postgres 16 testcontainer, counting executes and tracemalloc peak across view and entity counts with and without an injected per-execute delay. It is a throwaway script rather than part of the suite; happy to clean it up into sdk/python/tests/benchmarks/ if that is useful to keep. One caveat on coverage: I ran all of this on Python 3.11. There is no py3.13 requirements file and the pinned pytest-timeout does not import on 3.12 or later, so 3.10 and 3.12 are unverified on my side and CI will be the first run against them. Misc Release note: PostgreSQL online store now reads all feature views in a single query, reducing round trips for requests that span multiple feature views.
Open Graph Description: What this PR does / why we need it: The generic OnlineStore._read_features_per_fv loop issues one online_read per feature view, so a request spanning N feature views costs N round trips. Redis alre...
X Description: What this PR does / why we need it: The generic OnlineStore._read_features_per_fv loop issues one online_read per feature view, so a request spanning N feature views costs N round trips. Redis alre...
Opengraph URL: https://github.com/feast-dev/feast/pull/6832
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:223914a5-f630-0f18-3265-0d350668f819 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B48C:172ED:2AD559:3BAB00:6AFE9837 |
| html-safe-nonce | e21a5dea07ba4d559ed095d9233d967440309d42507404c93d766e836b2432d3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDhDOjE3MkVEOjJBRDU1OTozQkFCMDA6NkFGRTk4MzciLCJ2aXNpdG9yX2lkIjoiNTg4OTE2MTgwNDA0NjU3MTU3NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 22abdd07ef624f0f77734eddfb2efea098fac35e303a89a7b4f24818f637145e |
| hovercard-subject-tag | pull_request:4511487173 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/feast-dev/feast/pull/6832/files |
| twitter:image | https://avatars.githubusercontent.com/u/20937088?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/20937088?s=400&v=4 |
| og:image:alt | What this PR does / why we need it: The generic OnlineStore._read_features_per_fv loop issues one online_read per feature view, so a request spanning N feature views costs N round trips. Redis alre... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/feast-dev/feast git https://github.com/feast-dev/feast.git |
| octolytics-dimension-user_id | 57027613 |
| octolytics-dimension-user_login | feast-dev |
| octolytics-dimension-repository_id | 161133770 |
| octolytics-dimension-repository_nwo | feast-dev/feast |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 161133770 |
| octolytics-dimension-repository_network_root_nwo | feast-dev/feast |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4a10310af51a1bfffbedc4fd81cb582acf0cb0ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width