⚡ Optimize game state serialization for broadcasts#15
⚡ Optimize game state serialization for broadcasts#15
Conversation
Avoid redundant calls to `Game.to_schema()` when broadcasting game state to multiple players. Generate the full schema once and pass it to `get_view_for_player` for each player. Benchmark showed ~55% improvement (0.159s -> 0.072s for 100 players). Co-authored-by: WeixuanZ <39925558+WeixuanZ@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What:
Game.get_view_for_playerandGameService.get_player_viewto accept an optionalfull_schemaargument.broadcast_filtered_statesinbackend/app/api/routers/rooms.pyto generate the full game schema once and pass it to the view generation function for each player.🎯 Why:
get_view_for_playercalledself.to_schema()internally every time.📊 Measured Improvement:
get_view_for_player.PR created automatically by Jules for task 15313983742005791179 started by @WeixuanZ