Repository navigation
feat: Add Bigtable online store support for the Go feature server - #7193
timsmallwood wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🔍 Devin Review: 2 flags
Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
Add a read-only Bigtable online store to the Go feature server. It reads the tables Python's `feast materialize` writes, with no data migration, and takes the same `online_store` section of feature_store.yaml. - Table `<project>.<sorted entity names joined by "-">` with Python's md5 shortening, row key hex(murmur3_x64_128(entity key v3)) + "#" + feature view, family `features`, one qualifier per feature plus `event_ts`. - Reads are split into chunks of `keys_per_request` row keys (default 5), up to `max_concurrent_chunks` per read (default 50), each a ReadRows filtered to the requested qualifiers and LatestNFilter(1). `read_timeout_ms` (default 60 s) bounds each read, including retries. - Optional `max_inflight_reads` caps ReadRows calls across the server. A read reserves all the slots it needs before it sends anything, and is rejected (RESOURCE_EXHAUSTED over gRPC, 500 over HTTP) when they are not free within `max_inflight_wait_ms` (default 0, reject at once), so an overloaded server sheds whole reads instead of queueing them until they time out. - Optional `adaptive_chunking` keeps `keys_per_request` as the smallest chunk and grows chunks, up to 100 keys, so a large read goes out in one round. - Optional `disable_metrics` turns off the client's Cloud Monitoring export. A `bigtable.OnlineRead` span and Prometheus series for read duration, chunks sent and rows found. - Add the optional EntityAwareOnlineStore interface: readFromOnlineStore passes each view's entity names from the request's own view snapshot, so stream views keep precedence. OnlineRead returns an error wrapping errors.ErrUnsupported. The OnlineStore interface and the other stores are unchanged. - After the client primes its connections, startup pings the instance once more, so the emulator gets the same check and NotFound (no tables yet, or a mistyped instance) logs a warning; on an emulator, Unimplemented also only warns. An unset project_id falls back to GOOGLE_CLOUD_PROJECT, GCLOUD_PROJECT, then the default credentials' project. - Python: accept the Go settings in BigtableOnlineStoreConfig so one feature_store.yaml serves both; Python online reads use `app_profile`; add `write_app_profile` (keeps writes off the serving profile) and `initial_tablets` (pre-split new tables so a small table is not served by one node), each off unless set. The numeric Go settings are strict ints up to MaxInt32, as the Go server parses them, so `feast apply` rejects what the Go server would. - Parity fixtures are generated from the in-tree Python store, and a Python unit test fails when they drift. An end-to-end Go test has the Python SDK apply and materialize into the Bigtable emulator, then reads it back through GetOnlineFeatures; CI's Go job installs the gcp extra for it. - Docs for the Go reader and the new Python settings, linked from the feature_store.yaml reference. Signed-off-by: Timothy Smallwood <timsmallwood@gmail.com>
4ba890e to
b377218
Compare
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7193 +/- ##
==========================================
+ Coverage 53.63% 54.17% +0.53%
==========================================
Files 462 464 +2
Lines 58537 59094 +557
Branches 8632 8632
==========================================
+ Hits 31397 32014 +617
+ Misses 25005 24907 -98
- Partials 2135 2173 +38
*This pull request uses carry forward flags. Click here to find out more.
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
franciscojavierarceo
left a comment
There was a problem hiding this comment.
we need to make the new Python/Go parity fixture generation independent of the process-wide JSON patch. the current fixture test fails in three unit jobs, so the compatibility guard is not yet reliable.
| "event_ts": cells[b"event_ts"].decode(), | ||
| "want_seconds": (aware - epoch) // timedelta(seconds=1), | ||
| "want_nanos": aware.microsecond * 1000, | ||
| "want_value": json_format.MessageToDict( |
There was a problem hiding this comment.
MessageToDict depends on Feast's process-wide proto_json.patch(), so these expected values change with test execution order. current-head CI generates want_value: -9007199254740993 instead of {'int64_val': '-9007199254740993'}, with the same mismatch on both macOS jobs. this makes the new parity test fail even though the cell bytes agree. we need to generate a stable typed protobuf JSON representation independently of that patch and cover generation both before and after it, while retaining the Go protojson.Unmarshal checks.
What this PR does / why we need it:
Adds a read-only Bigtable online store to the Go feature server. It reads the tables Python's
feast materializewrites, with no data migration, and takes the sameonline_storesection offeature_store.yaml. The defaults and tuning settings are there to keep read latency low at high requestrates; why they are what they are is below. It also adds two optional Python settings on the table side,
initial_tablets(pre-split new tables) andwrite_app_profile(keep materialization off the serving appprofile), described under "Python config".
What it reads:
<project>.<sorted entity names joined by "-">, with Python's md5 shortening and__dummyforentityless views. Row key
hex(murmur3_x64_128(entity key v3, seed 0)) + "#" + feature_view. Familyfeatures, one qualifier per feature, plusevent_ts.ReadRowsper chunk ofkeys_per_requestrow keys, up tomax_concurrent_chunksin flight per read,and optionally at most
max_inflight_readsacross the server, reserved per read before it sends anything.The first failing chunk cancels the rest.
event_ts, eachregexp.QuoteMeta-escaped, chained withLatestNFilter(1), so it returns the newest version Python returns whatevermax_versionsis.NOT_FOUNDwith a zero timestamp. Row present, feature absent:NOT_FOUNDwith the row'stimestamp. A corrupt cell or a missing
event_tsfails the read with an error naming the table, view andqualifier; it is never served as missing data.
Destruct(). Outside the emulator the client library already primes itsconnections with
PingAndWarmwhen it is created (three attempts each), so bad credentials fail startupthere. The store then pings once more, within 10 s: that gives the emulator and pre-dialed connections,
which skip priming, the same check, and it logs a warning for
NotFound, which the library treats as asuccessful prime and logs only at debug level.
NotFoundcomes from an instance with no tables yet butalso from a mistyped instance or app profile, so the warning is the one visible sign of the latter.
Unimplementedfrom an old emulator also only warns. The serving identity needsbigtable.instances.pingand
bigtable.tables.readRows, both inroles/bigtable.reader. An unsetproject_idfalls back toGOOGLE_CLOUD_PROJECT,GCLOUD_PROJECT, then the default credentials' project.read_timeout_msbounds each read, including retries and any wait for slots. Abigtable.OnlineReadspan,like the Redis store's, and three Prometheus series on the existing metrics port: read duration by
status(ok,error,rejected), and chunks sent and rows found bytable. Nothing in the Go servermeasures online store reads today, so they are per store, with a
feast_bigtable_prefix;tableisbounded by the project's entity sets. I can rename them or move them to a shared scheme if you prefer.
Limits, the same as the other Go stores: join keys STRING, BYTES, INT32 or INT64. The HTTP endpoint types
entity values by their JSON form, so BYTES and INT32 keys are found only through gRPC; the docs now say so.
entity_key_serialization_versionmust be 3 (omitted means 3).Why
OnlineReadreturns an errorBigtable tables are named after a feature view's entities, which
OnlineRead's arguments don't carry: entitykeys carry join keys, which can differ from entity names. Rather than change
OnlineReadfor every store,this adds an optional
EntityAwareOnlineStoreinterface.readFromOnlineStoreuses it when a storeimplements it, passing entity names from the request's own feature view snapshot, the one
GroupFeatureRefsbuilt the entity keys from. That keeps stream views' precedence over batch views of the same name, and a
registry refresh mid-request can't mix schemas;
TestStreamViewWinsForEntityAwareStorecovers it.OnlineReadstays only to satisfyOnlineStore. It returns an error wrappingerrors.ErrUnsupported, andthe feature server never calls it for Bigtable. I considered having the store look up entities in the
registry, but no other store depends on the registry, and its view could disagree with the request's.
Widening
OnlineReadfor all stores would also work if maintainers prefer one interface; it is a mechanicalfollow-up. The
OnlineStoreinterface and the other stores are unchanged.Defaults and why
keys_per_requestReadRowsof many keys took longer than the same keys as several small requests in parallel, so small chunks cut latency.max_concurrent_chunksGOMAXPROCS.read_timeout_msmax_inflight_readsReadRowscalls. The docs say how to size it.max_inflight_wait_msadaptive_chunkingThese favor latency on an instance with many nodes. In our load tests, reading a 50-entity or 500-entity
request as small chunks in parallel gave a much lower p99 than sending it as one large
ReadRows. The costis Go CPU: each chunk is a call, so at very high request rates larger chunks carry less load per pod. The
docs say what to change on a small instance: raise
keys_per_request, lowermax_concurrent_chunks, setmax_inflight_reads. I can share the benchmark harness and results if that helps review.adaptive_chunking: truekeepskeys_per_requestas the smallest chunk and grows chunks, up to 100 keys,only when a read would not fit one round of
max_concurrent_chunks. For a single-table read, 500 row keysgo out as 50 calls of 10 rather than 100 calls of 5 in two rounds; each table is cut separately, so a read
over several tables can plan a few more calls, which wait for a slot. It never makes chunks smaller than
configured.
max_inflight_readsis a server-wide weighted semaphore. A read reserves all its slots (the smallest of itschunk count,
max_concurrent_chunksand the cap) before it sends anything, so a full server rejects wholereads rather than cancelling chunks already at Bigtable. A read that cannot get its slots within
max_inflight_wait_msfails withRESOURCE_EXHAUSTEDover gRPC (500 over HTTP, which maps every error to500 today) and counts as
status="rejected". Rejecting early is meant to keep admitted reads inside theirdeadline under overload, instead of every read slowing until
read_timeout_msfails it;read_timeout_msstays the last bound.store use it (
keys_per_request: 1,adaptive_chunkingoff, an app profile set up for the tier); itneeds no code of its own.
disable_metrics: trueturns off the client's Cloud Monitoring export: nomonitoring.timeSeries.createpermission needed, and noticeably less Go CPU in our load tests.
Python config
FeastConfigBaseModelsetsextra="forbid", so every key the Go server reads must exist onBigtableOnlineStoreConfig, orfeast applyrejects the shared file. This adds the Go settings as optionalfields, all
Noneby default and ignored by Python:keys_per_request(1 to 100),max_concurrent_chunks,read_timeout_ms,max_inflight_reads,max_inflight_wait_ms,adaptive_chunkinganddisable_metrics.The numeric ones are strict ints up to 2147483647 and the switches strict bools, as the Go server parses
them, so
feast applyrejects a quoted"25"or a boolean instead of the Go server failing at startup.app_profileis used by both: the Go server's reads and, now, Python's online reads.Two Python settings protect serving latency from the table side, each off unless set, so an existing
feature_store.yamlbehaves as before:initial_tablets(2 to 256):feast applycreates new tables pre-split at even two-hex-digit prefixes. Rowkeys start with a uniform hash, so tablets fill evenly. A new table starts as one tablet, and Bigtable can
keep a small table on one tablet, so every read of it lands on one node. In our load tests, small
unsplit tables left one node far busier than the rest, and pre-splitting them removed that hot spot and
the tail latency it caused. As a rule of thumb, the docs suggest a few tablets per node at the
target node count. Existing tables are untouched; the docs give the
cbtequivalent.write_app_profile: the app profile for materialization and push, so writes can run at low priority andnot compete with serving reads. It does not fall back to
app_profile, so settingapp_profileforserving never moves writes onto the serving profile.
Parity with Python
testdata/bigtable_fixtures.jsoncomes fromgen_bigtable_fixtures.py, which calls the in-tree Pythonstore:
_get_table_name,_compute_row_key, and_write_rows_to_btthrough a table stand-in that recordsthe cells.
test_bigtable_go_fixtures.pyregenerates them and fails if they differ from the committed file,so a change to the Python writer cannot leave the Go tests passing on stale fixtures.
chars), entityless views, every
event_tsformisoformat()writes, and the murmur3 byte order for inputlengths 1 to 100.
github.com/spaolacci/murmur3(tagged v1.1.0, already ingo.modfor the Redis store's 32-bithash). The DynamoDB store computes the same 128-bit hash with
github.com/roberson-io/mmh3, an untagged2019 pseudo-version; I kept to the tagged module, and the 100 fixture vectors pin byte equality with
Python's
mmh3. A shared helper for both stores would be a small follow-up.TestBigtablePythonMaterializeGoRead(go/internal/feast) runs the Python SDK'sfeast applyand
feast materialize-incrementalon the Go test repo against abttestserver, then reads it backthrough
FeatureStore.GetOnlineFeaturesand checks values, event timestamps andNOT_FOUNDagainst theparquet source. It needs the
feastCLI with thegcpextra and skips without it, so theunit-test-gojob now installs
.[gcp](one added step inunit_tests.yml, easy to drop if you'd rather not).go.modOne new direct module,
cloud.google.com/go/bigtablev1.58.0 (needs Go 1.26, Feast's version). Three modulesalready in the graph move from indirect to direct at the same versions:
golang.org/x/oauth2(defaultcredentials project),
google.golang.org/api(client options) andgithub.com/prometheus/client_model(metrics test). New indirect:
longrunning,google/btree,kylelemons/godebug,rsc.io/binaryregexp.No existing dependency changes version.
Also:
.pre-commit-config.yamlexcludes the fixtures JSON from detect-secrets (hex hashes and serializedprotos),
go/README.mdand the architecture skill doc mention the store, and thefeature_store.yamlreference links each online store's options page.
Which issue(s) this PR fixes:
Closes #7192
Checks
git commit -s)Testing Strategy
Unit tests (
bttestin-memory server, no network):onlinestore: parity, missing rows and features, old cell versions, corrupt cells,regex metacharacters in feature names, the read filter chain, duplicate keys, the same feature in two
views, chunk boundaries, adaptive sizing, per-read concurrency, server-wide admission with and without a
wait (mostly channel gates rather than sleeps), cancellation and timeouts, startup ping answers, project
resolution, config parsing and validation, metrics.
featurestore_test.gofor the entity-aware dispatch, including stream-view precedence, and theend-to-end test above in
featurestore_bigtable_test.go.go test -race -count=2passes for the Bigtable tests;go test -shortskips the one heavy concurrencytest.
gofmt,go vetandgo mod tidy -diffare clean.test_bigtable_online_store.pyandtest_bigtable_go_fixtures.py;ruffandmypyclean.Integration tests: not run. The suite needs
ok-to-test(request below).Manual, real cloud: on GKE, Python materialized a 12-feature view to Bigtable and the Python feature
server and this store served it side by side: 2,000 entities x 12 features, 0 value mismatches and 0
event_tsmismatches in 24,000 cells. (That manual test predates later changes to defaults and config;the read encoding is unchanged and the parity fixtures pin it.)
Misc
CI's Go tests run with
-skip "TestGetOnlineFeatures|TestSqliteOnlineRead", which is unanchored, so the newstream-view test is named
TestStreamViewWinsForEntityAwareStoreto keep it running.Could a maintainer add
ok-to-test? This touchesfeaturestore.goand the Python config model, so I'd likethe integration suite green before review. Thanks.