Repository navigation
perf(room,ws): 降低房间页重渲与广场广播开销 - #14
Merged
Merged
Conversation
前端: - QrCard 加 memo,父级消息流每秒 tick 不再整列重渲(倒计时仍各自 tick) - 设置抽屉改为逐字段订阅 store,消息流/签到回执变化不再连带重渲 - 自动签到只处理消息尾部增量,不再每次事件重建全量 Set - 相机 BarcodeDetector 原生路径按 300ms 节流(原先 rAF 每帧都 detect) - 房间消息 store 入队时惰性裁剪过期项,数组有界 后端: - 连接进房后退订 lobby 广播、回广场重新订阅,plaza_update 只发广场页连接 - broadcast_plaza 无 lobby 订阅者时提前返回 - share_qr 内容分配由 3 次降为 2 次(返回值不再携带广播内容拷贝) 校验:cargo fmt/clippy/136 test;tsc/lint/63 test/build 全绿
9 tasks done
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.
变更说明
一轮性能自查后落地的优化(不改变对外行为):
前端
QrCard加memo(父级每秒 tick 不再整列重渲,倒计时仍由各卡片自身 tick)Set)BarcodeDetector原生路径按FRAME_INTERVAL_MS(300ms) 节流(原先requestAnimationFrame每帧都detect)VecDeque惰性淘汰)后端
plaza_update只发给广场页连接(原先广播代价 = 房间数 × 在线连接数)broadcast_plaza无 lobby 订阅者时提前返回,不再构建全量列表share_qr内容分配由 3 次降为 2 次(返回值不再携带广播拷贝)未改动(附实测依据):登录扫码轮询保持"每约 30s 换一次二维码"。实测上游
/api/v3/user/login为 30s 长轮询、token JWTexp = iat + 60s,即现状约 2 次建码/分钟;改为复用单个码至 55s 会把用户扫码后的剩余确认时间压到几秒,反而降低成功率。变更类型
chore构建/依赖/杂项(性能优化,不改行为)目标分支
dev(feature/fix 常规合并)自查清单
chore/perf-optimize),基于最新dev创建cargo fmt --check/cargo clippy -D warnings/cargo test(136 passed)通过oxlint/tsc/ 测试(63 passed)/ 构建 通过docs/CHANGELOG.md已补记性能优化条目)unwrap()(测试代码除外)、无unsafe、无any关联 issue / 备注
plaza_update;Plaza页挂载即 REST 拉取,离开房间回广场不会漏数据Hub::register的同账号旧连接查找(仅建连时一次,加索引需三处同步维护,收益不抵复杂度)