perf: skip Who's Online payload when room state is unchanged - #288
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
▶ Preview in WordPress PlaygroundBoots a fresh WordPress with this PR's presence-api build, seeds 5 demo users, and drops you on the dashboard. Stress-test variant: 40 demo users · Built from |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #288 +/- ##
============================================
+ Coverage 75.87% 77.82% +1.95%
- Complexity 176 190 +14
============================================
Files 14 14
Lines 1832 1998 +166
============================================
+ Hits 1390 1555 +165
- Misses 442 443 +1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Description
Closes #268.
Server hashes the room's meaningful state; the client echoes its last hash. On a match the response carries last-seen timestamps instead of the payload, skipping
cache_users(), per-userget_userdata()/get_avatar_url(), label building, and most of the JSON.Review notes
user_id → last-seenmap, not a bare flag: the hash excludesdate_gmt(it would flip every tick), so a flag alone breaks the idle dot for backgrounded tabs. Verified the dot still greys at 30s and clears at 60s, matchingmain.Testing
admin-ajax(presence rides WordPress's Heartbeat; it has no endpoint of its own). After the first tick, responses should carrypresence-online-unchangedwith auser_id → last-seenmap instead of the fullpresence-onlinearray, and drop noticeably in size.main- while the admin's responses keep coming back aspresence-online-unchanged.Out of scope
heartbeat_received()runs on every admin screen but only the Dashboard consumes the data - off-Dashboard ticks still build an unread payload and can't be hash-suppressed. Will be raising a issue for this.Measurement
To follow
Screenshots
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5
Used for: Implementation and tests