-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Minimal Bundled SVG Agent Icons (refs #2857) #2902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Performance benchmarks:
|
|
Thanks for the PR, especially with the different agent count benchmarks. Could you compare the SVG drawing to the drawing of the default marker? |
|
Sure, I would be happy to do it. |
Comparison: Default Marker vs Rasterized SVG (Pillow composition)Setup:
Results:
Observations:
Next steps:
@EwoutH let me know if you’d like additional sizes (e.g., N=2000) or alternative marker shapes/colors for completeness. |
|
Thanks. Can you give a screenshot how the benchmark looks? |
|
Yes, doing it |
|
Thanks. Can you explain how this integrates with our Solara visualisation and render backends? Or haven't you implemented that yet? |
|
Thanks! I haven’t implemented the Solara integration yet in this PR. Here’s my plan for the follow-up : Integration plan (Solara + render backends)
What do you think about this ? |
Assuming these numbers and observations transfer to our Solara visualization, can we do anything to optimize it? 4-5x overhead sounds like quite a lot. |
|
Yes, for sure. I think we can definitely optimize to guarantee performance, immediate win is caching. We should ensure we only rasterize the SVG to a bitmap once , rather than per frame. |
|
I have optimized it changes :
Benchmark Results (120 frames)
Benchmark Results (60 frames)
Average icon overhead ~0.9–1.5% across test matrix (well below target of <50%). |
|
That’s quite amazing! Thanks for the detailed benchmarks. If you want you can move forward with Solara integration. Try to keep the implementation minimal / code complexity low. You can do that in a new PR if you want. |
|
Thankyou, would be happy to do that |



Minimal Bundled SVG Agent Icons
Summary
This PR introduces a minimal internal SVG agent icon library and helper module. It is intentionally small and focused on packaging + access + baseline performance, with no frontend integration yet. That will follow in a separate PR after reviewer feedback.
Changes
mesa/visualization/icons.py:list_icons()– returns available icon basenames.get_icon_svg(name)– returns raw SVG text (supportsmesa:<name>).mesa/visualization/icons/(usingfill="currentColor"for recoloring). Current icons:neutral_face,smiley,sad_update.mesa/visualization/icons/README.md– brief style/naming rules.tests/test_icons.py– listing and retrieval tests.pyproject.toml– added[tool.hatch.build]include patterns to package SVG assets (Hatch/hatchling is used; no MANIFEST.in).benchmarks/icons_benchmark.py– dev-only Python benchmark script (not included in package builds).No existing visualization behavior is changed.
Rationale
Split the work:
This sequencing allows maintainers to validate packaging + API before adopting icon rendering.
Performance (Python benchmark)
Environment:
Method:
python benchmarks/icons_benchmark.py --icon neutral_face --n N --frames 120Measures cold SVG read, SVG→raster conversion, and per-frame composition time (Pillow alpha compositing).
Results (neutral_face.svg):
Interpretation:
Verification
pytest -qpasses locally.unzip -l dist/Mesa-*.whl | grep visualization/iconspython -c "from mesa.visualization import icons; print(icons.list_icons())"returns expected names.Follow-Up Plan (next PR)
{"icon": "<name>", "color": "#RRGGBB"}.Notes
Refs #2857