Repository navigation
room intrinsics: re-read the avatar catalog only when its revision moves - #969
Merged
Merged
Conversation
conference_roster.ari's on_tick calls (room-avatar-options ROOM "color"), (room-avatar-options ROOM "accessory") and (room-avatar HANDLE) on every tick once joined, and each did a full read_avatar_catalog: every option's nodes, a few hundred lookups and a deep children() walk. The document's room_table now keeps each room's catalog with the revision it was read at. The three avatar verbs (and room-set-avatar's check) read one leaf, the catalog's revision, and the catalog again only when that moved -- write_avatar_catalog bumps it last, the idiom room_view::sync_looks uses. The catalog is held by shared_ptr and read outside the table's lock; the revision is read first, so a write landing mid-read leaves a newer revision for the next call. The verbs' results are unchanged. Native Release (static, MSVC), the roster tick's three verbs in an action program: 5.0-7.1 ms -> 38-45 us per tick. Test: RoomAvatar.TheAvatarVerbsRereadTheCatalogOnlyWhenItsRevisionMoves drives the verbs through a Runtime: a new choice and a rewritten catalog reach them on the next call, equal to a fresh read, while a label changed behind the revision's back stays unseen (on master that check fails).
…rbs-catalog-rev # Conflicts: # src/cvc/tests/room_avatar_test.cpp
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.
Once joined,
conference_roster.ari'son_tickcalls three avatar verbs on every tick:(room-avatar-options ROOM "color")(room-avatar-options ROOM "accessory")(room-avatar HANDLE)Each verb called
read_avatar_catalog, which walks every option's nodes: a few hundred lookups plus a deepchildren()walk.Now the document's
room_table, which already owns its room handles, keeps each room's catalog together with the revision it was read at.room-avatar-options,room-avatarandroom-set-avatar's option check go throughroom_table::catalog():conf.rooms.<room>.avatars.rev. It reads the catalog again only when that revision has moved.write_avatar_catalogwrites the revision last, androom_view::sync_looksrelies on it the same way. Only the relay writes the catalog (seed_avatar_catalog), and the room write gate keeps clients out of that subtree.shared_ptrand read outside the table's lock.The verbs' results are unchanged. This is independent of #968, which applies the same idea to
avatar_panel::update, and the two touch different code.Measured
This was a native Windows Release build (static, MSVC 14.44) of
room_avatar_test. A temporary timing case, not committed, ran the roster tick's three verbs in a 200-iteration action program through aRuntime. I subtracted an identical loop with the verbs replaced by trivial calls (11 to 24 µs).a8f2b7c5)That is about 130× less. What's left is the leaf reads that remain: three revisions, our choice, and
room-avatar's policy and reserve. Each costs a few µs infindDescendant. I haven't measured it in the browser build. The wasm client was about 2.3× slower than native on the catalog read.Test
RoomAvatar.TheAvatarVerbsRereadTheCatalogOnlyWhenItsRevisionMoves(room_avatar_test) runs the verbs through aRuntime, as the roster does:room-set-avatar) reachesroom-avataron the next call;room-set-avatarrefuses the withdrawn accessory;The test clears the global action-intrinsics registry when it ends, as the net-intrinsics tests do.