Repository navigation
avatar_panel: re-read the avatar catalog only when its revision moves - #968
Merged
Merged
Conversation
avatar_panel::update runs every frame from arigl's step_room and re-read the room's whole avatar catalog each time: every option's nodes, a few hundred lookups and a deep children() walk. That was most of a browser client's room step outside the pump and the view. update() now checks one leaf, the catalog's revision (bumped last by write_avatar_catalog, the idiom room_view::sync_looks already uses), and reads the catalog again only when it or the room changes. Our choice is two leaves, still checked every frame so our own pick shows at once; the look is re-resolved only when the catalog, the choice or the pid changed. The published self.avatar.* model is unchanged. Native Release (static, MSVC), default catalog plus 8 peers: update() 1.43 ms -> 11.3 us per call. What remains is the three leaf lookups (~3.6 us each in findDescendant). Test: RoomAvatar.ThePanelRereadsTheCatalogOnlyWhenItChanges -- the catalog's arrival, our pick and a rewritten catalog each reach the published look on the next frame, equal to a fresh read, while unchanged frames read no catalog.
This was referenced Nov 2, 2026
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.
avatar_panel::updateruns every frame from arigl'sConferenceSession::step_room. Each call re-read the room's whole avatar catalog withread_avatar_catalog, then resolved our look again. That read walks every option's nodes: 11 colours and 7 accessories with their parts, a few hundred lookups plus a deepchildren()walk. In the browser build that was most of the ~3.3 ms of the room step spent outside the pump and the view.Now
updatereads the catalog only when it can have changed:conf.rooms.<room>.avatars.rev. It reads the catalog again only when that revision or the room changes.write_avatar_catalogwrites the revision last, so a new revision means the options it covers are already there.room_view::sync_looksrelies on the same idiom.participants.<pid>.avatar.{color,accessory}) every frame, which costs about the same as a revision check. It resolves the look again only when the catalog, the choice or the pid changed. I left the choice unthrottled: a timer would delay our own pick by up to a second, and achildChangedwatch would add lifetime and threading hazards for no gain I could measure.The published
self.avatar.*model is unchanged. The new test checks the labels against a fresh full read after every change.Measured
This was a native Windows Release build (static, MSVC 14.44) of
room_avatar_test. The setup was the default catalog seeded, 8 peers with choices and pose subtrees, and a physics client holon. I timed 2,000update()calls after a warm-up, using a temporary timing case that is not committed:update()callbafcd78b)That is about 126× less. In the same binary, the old per-frame sequence on its own (
read_avatar_catalog+read_avatar_choice+resolve_avatar_look) still measures ~1.39 ms, so the gain comes from skipping that read.The remaining ~11 µs is almost all three leaf lookups: the revision plus the two choice leaves, ~3.6 µs each in
state::findDescendant. The holon reads take 0.1 µs. The browser build was about 2.3× slower than this native build on the old path (~3.3 ms against 1.43 ms). At that ratio the room step should drop from ~3.8 ms to ~0.5 ms, roughly the cost of the pump plus the view. I have not measured this in the browser.Two follow-ups, not in this PR:
conference_roster.ari'son_tickcallsroom-avatar-optionstwice androom-avataronce per tick. Each call does a fullread_avatar_catalog, which is the same cost in the document lane.findDescendantis ~3.6 µs for a 7-segment path. It normalizes by split, localetrimand join, then splits and trims again. Every state read pays this.Test
RoomAvatar.ThePanelRereadsTheCatalogOnlyWhenItChanges(room_avatar_test). It needs no Jolt, so it runs on every builder. It checks that:After every change, the published labels equal what a fresh
read_avatar_catalogplusresolve_avatar_lookgives, which is whatupdatecomputed every frame before this change.