Repository navigation
Conversation
Zero::live(&query, &ttl) takes a typed Query or a named query's QueryRequest (through the new typed::TypedQuery trait) and returns a LiveView<T>, the Rust counterpart of the Swift client's LiveQuery: the query's value read as its Rust type and kept current, with its result type, an error (the server's query error, or rows that didn't read, which keep the last value), listeners, update_ttl, and the underlying MaterializedView. It follows the client when the client replaces itself, and dropping it removes its listeners and destroys the view. An update reads only the rows whose entries changed, as Swift's RowCache does (QueryValue::update_from_view, with a default that reads anew), and keeps a copy of the entries rather than sharing the view's, so the view changes its rows in place. In turns, an optimistic update with a view of 1,000, 10,000, and 100,000 rows read as structs went from 82.8, 759, and 13,130 us (reading every row in a listener) to 19.1, 61.6, and 521 us.
zbugs-gpui's Live is now a GPUI adapter over a LiveView that only wakes the view to notify it; its Snapshot and its own reading of the rows are gone, and the app reads live.value(). zbugs-rune's watch makes a LiveView per client on the sync thread and ships its value to the UI, in place of materializing and reading the rows itself; a row that doesn't read is still printed and not applied.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
tmm's decision 3(b): a typed live view, the Rust counterpart of Swift's
LiveQuery(useQuery). GPUI and Rune move onto it and their copies are deleted.Zero::livetakes a typedQuery<R, T>(default build) or aQueryRequest(serdefeature), through a smalltyped::TypedQuery<C>trait.Zeroreplaces its client; a test covers this through the public API.RowCachedoes: an update re-reads only the rows whose entries changed, and an update with no row changes reads nothing.QueryValuegainsupdate_from_view, with a default.Benchmarks (3 rounds, medians): an optimistic update with the view read as structs, by hand vs
LiveView. Making the view costs the same either way, and the existing benchmarks against main are within noise.LiveViewApps:
Liveis nowLiveViewplus itscx.notifywake-up.watchbuilds aLiveViewper client.Slots and error display are unchanged. One difference: rows that fail to decode on the first read now make
livefail, and the app prints the error. That only happens when the generated types don't match the data, which is a bug.Changeset:
zero-rustminor (with 0.3.0).Checked locally:
-D warnings, tests (11 new inlive_view.rs), docs, and conformance (66,384 cases, 0 failures). The default build still has no dependencies.e2e), and zbugs-rune pass fmt, clippy, and tests.