Skip to content

feat: update DotBotsMapPoint to not update when props doesn't change#214

Merged
aabadie merged 4 commits intoDotBots:mainfrom
WilliamTakeshi:improve-sim-scalability2
Feb 27, 2026
Merged

feat: update DotBotsMapPoint to not update when props doesn't change#214
aabadie merged 4 commits intoDotBots:mainfrom
WilliamTakeshi:improve-sim-scalability2

Conversation

@WilliamTakeshi
Copy link
Contributor

Update DotBotsMapPoint to use React.memo.

Previously, on every WebSocket update, a new dotbot object was created and replaced the existing one — even when none of its values had actually changed. Because the object reference changed, React treated it as an update and re-rendered all N bots.

As the number of bots increased, the number of updates and unnecessary re-renders also increased, which negatively impacted performance.

The fix ensures that:

  • Only the fields that actually change are updated.
  • The original object reference is preserved when no values change.
  • Unaffected bots keep the same reference.

Here is some screenshots before:

screenshot_2026-02-26-105537

After:

screenshot_2026-02-26-105433

@WilliamTakeshi WilliamTakeshi force-pushed the improve-sim-scalability2 branch from 5080a1f to 7c31ea0 Compare February 26, 2026 10:25
@codecov
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.84%. Comparing base (24f313d) to head (c53b1e4).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #214   +/-   ##
=======================================
  Coverage   68.84%   68.84%           
=======================================
  Files          40       40           
  Lines        3739     3739           
=======================================
  Hits         2574     2574           
  Misses       1165     1165           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@WilliamTakeshi WilliamTakeshi force-pushed the improve-sim-scalability2 branch from 7c31ea0 to 2a87fdc Compare February 26, 2026 10:33
@geonnave
Copy link
Contributor

Amazing!!

@aabadie
Copy link
Contributor

aabadie commented Feb 27, 2026

The UI crashes when setting waypoints manually. I had to apply the following diff to make it work again fully:

diff --git a/dotbot/frontend/src/DotBotsMap.js b/dotbot/frontend/src/DotBotsMap.js
index aa6697b..e601eb1 100644
--- a/dotbot/frontend/src/DotBotsMap.js
+++ b/dotbot/frontend/src/DotBotsMap.js
@@ -122,6 +122,8 @@ const DotBotsMapPoint = React.memo((props) => {
           opacity={waypointOpacity}
           waypoints={props.dotbot.waypoints}
           threshold={props.dotbot.waypoints_threshold}
+          areaSize={props.areaSize}
+          mapSize={props.mapSize}
           />
       ))
     )}
@@ -203,6 +205,7 @@ export const DotBotsMap = (props) => {
                     mapSize={props.mapSize}
                     showHistory={props.showHistory}
                     updateActive={props.updateActive}
+                    mapClicked={mapClicked}
                     active={props.active}
                     historySize={props.historySize}
                   />)

@aabadie
Copy link
Contributor

aabadie commented Feb 27, 2026

Otherwise I was able to test a locally modified blinky script (see the diff below) with 500 robots. It's not super fluid but it's much better than before!

diff --git a/dotbot/examples/blinky.py b/dotbot/examples/blinky.py
index 9cd5eca..858301e 100644
--- a/dotbot/examples/blinky.py
+++ b/dotbot/examples/blinky.py
@@ -53,25 +53,7 @@ async def blinky(
             #         "blue": int(b * 255),
             #     },
             # )
-        waypoints = DotBotWaypoints(
-            threshold=THRESHOLD,
-            waypoints=[
-                DotBotLH2Position(
-                    x=dotbots[0].lh2_position.x, y=dotbots[0].lh2_position.y, z=0
-                )
-            ],
-        )
-
-        await ws.send(
-            WSWaypoints(
-                cmd="waypoints",
-                address=dotbots[0].address,
-                application=ApplicationType.DotBot,
-                data=waypoints.model_dump(),
-            )
-        )
-
-        await asyncio.sleep(0.25)
+            await asyncio.sleep(0.025)
 
 async def main() -> None:
     url = os.getenv("DOTBOT_CONTROLLER_URL", "localhost")
@@ -88,4 +70,4 @@ async def main() -> None:
 
 
 if __name__ == "__main__":
-    asyncio.run(main())
\ No newline at end of file
+    asyncio.run(main())

@aabadie aabadie merged commit e61d5ae into DotBots:main Feb 27, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants