Skip to content

ci: Integrate membrowse. - #18558

Open
michael-membrowse wants to merge 1 commit into
micropython:masterfrom
michael-membrowse:master
Open

michael-membrowse wants to merge 1 commit into
micropython:masterfrom
michael-membrowse:master

Conversation

@michael-membrowse

@michael-membrowse michael-membrowse commented Dec 12, 2025 •

Copy link
Copy Markdown

Summary

MicroPython has a code-size workflow but no automated way to track how PRs affect memory footprint over time or compare against previous commits.

This PR adds MemBrowse CI integration for automated memory footprint analysis on pull requests.
It creates a PR comment with the size changes on region and section level with links to the full build comparison page.

It was discussed with @AJMansfield on Discord, who suggested opening a PR.
Here is an example of the dashboard and its features: https://membrowse.com/public/membrowse/micropython

This includes:

  • membrowse-targets.json - contains the configuration of the targets to be analyzed
  • membrowse-pr.yml — runs on PRs + pushes to master, builds firmware and uploads reports to MemBrowse
  • membrowse-comment.yml — posts consolidated memory results as PR comments (runs after membrowse-pr.yml)
  • membrowse-onboard.yml — one-off workflow for building the last N commits (N is an input to the workflow) to have historical data on day one
  • README badge linking to the MemBrowse MicroPython dashboard
  • Currently the integration supports 8 targets. Same ones used by the code-size workflow.

Setup for maintainers:

  • Create account at https://membrowse.com
  • Create a project and link it to this repo
  • Set the project as publicly available.
  • Add MEMBROWSE_API_KEY as a GitHub action secret

Run the onboard workflow to populate the dashboard with historical data.

Testing

End-to-end validation performed on a personal fork

Trade-offs and Alternatives

External dependency.

Maintenance

As the author of MemBrowse, I'm committed to maintaining this integration and ensuring it continues to work correctly.
If issues arise, feel free to ping me on Micropython's discord or or at [email protected].
Happy to adjust boards, scope, naming, or workflow triggers based on feedback.

@michael-membrowse michael-membrowse changed the title ci: add membrowse to micropython ci: Add membrowse to micropython. Dec 12, 2025
@michael-membrowse michael-membrowse changed the title ci: Add membrowse to micropython. ci: Integrate membrowse. Dec 12, 2025
@michael-membrowse
michael-membrowse force-pushed the master branch 2 times, most recently from 292f6d0 to ab19725 Compare December 12, 2025 20:21
@github-actions

github-actions Bot commented Dec 12, 2025 •

Copy link
Copy Markdown

Code size report:

Reference:  extmod/moductypes: Be more defensive with uctypes_struct_agg_size args. [8a56be6]
Comparison: ci: Integrate Membrowse. [merge of 7476de4]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@codecov

codecov Bot commented Dec 12, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.46%. Comparing base (8a56be6) to head (7476de4).
⚠️ Report is 554 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #18558   +/-   ##
=======================================
  Coverage   98.46%   98.46%           
=======================================
  Files         176      176           
  Lines       22811    22811           
=======================================
  Hits        22460    22460           
  Misses        351      351           

☔ View full report in Codecov by Harness.
📢 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.

@AJMansfield AJMansfield left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a very useful thing to add to MicroPython's CI.

To test, I've merged this set of changes into my own fork:

Then performed the other steps described to set up and link to a membrowse project; then ran the Membrowse onboard action to analyze (for expediency) the 10 most recent commits.

To look at what the steady-state behavior then is, I created a PR against my fork for a particular set of changes I've been working on but struggling to attribute size changes on:

Once the CI jobs completed, this generated the following comment:
image

Note, that the examined targets are not identical between code-size vs membrowse, e.g. pybv10 vs pybv11, and the missing unix, minimal-arm, and mpy-cross targets. If the two were to disagree though, I'd actually already be more inclined to believe membrowse: the file-size-based estimate used by code-size could be fooled even just by padding changes to the firmware's ELF/UF2/etc container.

Following through to the symbol analysis tab for stm32-pybv11 shows a change I'd think reasonable to expect for the commits in question:
image

Following through to the symbol analysis tab for qemu-virt-rv32 shows a different change, possibly a bookkeeping or inlining change associated with the realloc calls in the lists implementation:
image

MicroPython's current home-grown code-size tool has been a useful part of keeping MicroPython slim, but it doesn't provide granular information nearly this useful; this also fixes many of the frustrations I've had at times trying to hunt down linker padding feng-shui ghosts.

If it's possible to add in membrowse targets for unix, minimal-arm, and mpy-cross (as covered by code-size), I could even see eventually superceding and removing code-size once this project has gained enough familiarity with membrowse.

For now, though, and even if those targets can be added, it feels wise to also continue to run code-size alongside membrowse, since there's other cases for code-size (like all the offline runs everyone does via their own custom scripts). Either way, though, this feels like a substantial upgrade for the main CI use-case.

@dpgeorge dpgeorge added the github-actions Pull requests that update GitHub Actions code label Jan 4, 2026
@michael-membrowse
michael-membrowse force-pushed the master branch 4 times, most recently from fd64bc2 to cfb15a5 Compare January 24, 2026 16:40
@michael-membrowse

Copy link
Copy Markdown
Author

As @AJMansfield requested i've added the unix, minimal-arm, and mpy-cross targets and changed pybv11 to pybv10.
Here you can see an example:
https://membrowse.com/public/membrowse/micropython

Comment thread .github/membrowse-targets.json Outdated
"ld": "ports/minimal/stm32f405.ld"
},
{
"target_name": "unix-x64",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the name should be unix-standard to keep to the - notation

"linker_vars": "flash_start=0x60000000 flash_size=0x200000 vfs_start=0x60100000 vfs_size=0x100000 reserved_size=0"
},
{
"target_name": "rp2-pico-w",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick : 'rpi_pico_w'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think rp2-pico-w is actually correct here - rp2 matches the port directory (ports/rp2) and follows the same {port}-{board} pattern as the other targets.

@Josverl

Josverl commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

I have been using membrowse in my own fork to track the impact of changes across ports, and I have found it very insightful and simple to use, especially though the portal.
It would be nice to have anonymous access to the portal, but I assume anyone with a valid interest into such details has a GH account anyway.

@projectgus
projectgus self-requested a review January 28, 2026 00:25
@michael-membrowse

Copy link
Copy Markdown
Author

@Josverl Thanks for your comment. You can set your projects to be accessed without authentication. You need to go to the project settings in the MemBrowse portal and set the project as publicly available.

@projectgus projectgus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @membrowse,

Thanks for submitting this PR, and for offering membrowse for free to open source projects! This is a really nice interface for looking at size changes.

It looks like we could replace our current code_size job with this one and gain a bunch of nice features, the only downside I see from our perspective would be if Membrowse goes away (hopefully not) - but we can always bring back the old code_size in this case.

From clicking around the sample I do have one feature request (not a dealbreaker for this PR) - when comparing two commits then it'd be really nice to be able to switch targets without losing context (i.e. make the "target" in the top left a dropdown instead of a label). IIUC currently to look at the same diff for a different target I have to click on Project, click on the new target, and then I have to manually select the same commit(s) again. This is often the most time-intensive part of analysing diffs with our current systems (where the same code diff yields quite different code size changes on different targets, and you're trying to drill down into what exactly is different between the targets).

Thanks again!

@projectgus
projectgus requested a review from dpgeorge February 3, 2026 22:57
@michael-membrowse

Copy link
Copy Markdown
Author

@projectgus Thank you for your feedback and the feature suggestion.
Switching easily between targets comparisons is a great idea,
I will add it to the MemBrowse portal.
It won't require any changes to this PR.

@michael-membrowse

Copy link
Copy Markdown
Author

@projectgus I've implemented your feature suggestion.
Now there is a dropdown menu to choose a target to easily switch between targets.

@projectgus

Copy link
Copy Markdown
Contributor

@michael-membrowse That's really handy, thank you!

Signed-off-by: Michael Rogov Papernov <[email protected]>
@michael-membrowse

Copy link
Copy Markdown
Author

Updated the pull request with simplification of the PR comment workflow
and map file parsing to provide library level breakdown in symbol analysis page in MemBrowse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github-actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants