Skip to content

docs(footprint): make the per-TU wrapper table reproducible, and re-measure it - #186

Merged
Andste82 merged 1 commit into
mainfrom
docs/footprint-tu
Oct 2, 2026
Merged

Andste82 merged 1 commit into
mainfrom
docs/footprint-tu

Conversation

@Andste82

@Andste82 Andste82 commented Oct 2, 2026

Copy link
Copy Markdown
Member

Every footprint figure in the README regenerates from tools/footprint.sh — except one. The "C++ wrapper on bare metal" table reported 338 / 834 / 884 / 1034 B of ARMv6-m .text for a consumer translation unit, measured on an ad-hoc TU that was never committed (#162 measured "the same consumer TU" and the file did not survive the commit). That table could not be reproduced, re-derived, or checked for drift.

What this adds

File Role
test/footprint-tu/consumer.c the message through the C API
test/footprint-tu/consumer.cpp the same message through the wrapper
tools/footprint-tu.sh compiles each alone (-c), reports size on the object

Both encode and decode the same message — five scalar fields, a nested sequence holding two scalars, one string — which is what makes the C row and the wrapper rows belong in one table. consumer.cpp reaches only for the heap-free surface, present in both wrapper modes, so the freestanding→hosted delta is what the header gates, not what the TU asked for.

Nothing is linked, so library calls stay external references and only the TU's own code is counted. Flags mirror a real build: the Release flags from the top-level CMakeLists.txt plus the Cortex-M toolchain flags.

Measured (ARMv6-m, -Os)

Consumer translation unit .text over the C API
C API directly 440 B —
C++ wrapper, freestanding 962 B +522 B
C++ wrapper, hosted 1180 B +740 B
C++ wrapper, hosted, RTTI on 1447 B +1007 B

A freestanding MCU consumer pays 962 B per TU, not 1447.

These replace the old figures rather than correct them

The original TU is unrecoverable, so the difference between 834 B and 962 B is a different fixture, not measured drift — the two sets are not comparable and the old ones cannot be validated. What is reproducible from here on is this one. That is stated plainly in the commit message so nobody later reads the change as a regression.

Verification

  • Both fixtures round-trip correctly when linked against the library (checked hosted, both return 0), so the table measures a working consumer and not a compile-only shell.
  • Both compile under -Wall -Wextra -Wpedantic -Werror.
  • The C core is untouched; no library row moves.

One open question for you

Nothing in CI compiles these two fixtures. tools/footprint-tu.sh builds them with -Werror, so running it is the guard — but this repo's own lesson from #162 was "nothing caught it because nothing ever built it", and an uncompiled fixture is how that repeats. test/cpp-freestanding/ is the existing precedent for a compile-only guard target. Say the word and I will wire test/footprint-tu/ up the same way.

🤖 Generated with Claude Code

…easure it

The "C++ wrapper on bare metal" table reported 338 / 834 / 884 / 1034 B of
ARMv6-m .text for a consumer translation unit. Those numbers came from an
ad-hoc TU that was never committed -- #162 measured "the same consumer TU"
and the file did not survive the commit -- so the table could not be
reproduced, re-derived or checked for drift. Every other footprint figure
in the README regenerates from tools/footprint.sh; this one did not
regenerate from anything.

Commit the measured TUs and the script that reads them:

  test/footprint-tu/consumer.c     the message through the C API
  test/footprint-tu/consumer.cpp   the same message through the wrapper
  tools/footprint-tu.sh            compiles each alone, reports `size`

Both encode and decode the same message -- five scalar fields, a nested
sequence holding two scalars, one string -- so the C row and the wrapper
rows are comparable, which is the whole point of putting them in one
table. consumer.cpp reaches only for the heap-free surface, which exists
in both wrapper modes, so the freestanding/hosted delta is what the header
gates rather than what the TU asked for. Both round-trip correctly when
linked against the library (verified hosted), so the table measures a
working consumer and not a compile-only shell.

Measured, ARMv6-m, -Os, with this project's own Release and toolchain flags:

  C API directly                    440 B
  C++ wrapper, freestanding         962 B   (+522 B)
  C++ wrapper, hosted              1180 B   (+740 B)
  C++ wrapper, hosted, RTTI on     1447 B  (+1007 B)

These REPLACE the old figures rather than correct them: the original TU is
unrecoverable, so the difference is a different fixture, not measured
drift, and the two sets are not comparable. What is reproducible from here
on is this one.

The C core is untouched; no library row moves.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Andste82
Andste82 merged commit b1fab37 into main Oct 2, 2026
26 checks passed
@Andste82
Andste82 deleted the docs/footprint-tu branch October 2, 2026 10:06
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.

1 participant