Skip to content

feat: S21.02 tune freertos-cross MAX_MESSAGE_SIZE to 512 + tunable-driven BDD gating#350

Merged
DavidCozens merged 2 commits into
mainfrom
feat/s21-02-freertos-message-size
May 12, 2026
Merged

feat: S21.02 tune freertos-cross MAX_MESSAGE_SIZE to 512 + tunable-driven BDD gating#350
DavidCozens merged 2 commits into
mainfrom
feat/s21-02-freertos-message-size

Conversation

@DavidCozens

@DavidCozens DavidCozens commented May 12, 2026

Copy link
Copy Markdown
Owner

Purpose

First use of the S21.01 build-time tunables mechanism (#347). Points the freertos-cross preset at a FreeRTOS-specific user-config header that redefines SOLIDSYSLOG_MAX_MESSAGE_SIZE from the library default 2048 down to 512 (pre-S12.12 default; comfortably above RFC 5424 §6.1's 480-byte minimum). Empirically reclaims 4.5KB of per-call stack frame on the Cortex-M3 BDD target.

Linux and Windows presets keep 2048 so they still exercise path-MTU clipping (udp_mtu.feature).

Closes #349.

Change Description

  • New Bdd/Targets/FreeRtos/solidsyslog_user_tunables.h with #define SOLIDSYSLOG_MAX_MESSAGE_SIZE 512. Lives alongside FreeRTOSConfig.h / FreeRTOSIPConfig.h so it reads as part of the FreeRTOS port surface, and serves as the worked example for the new "Tuning for your MCU" section in Bdd/Targets/FreeRtos/README.md.
  • CMakePresets.jsonfreertos-cross.cacheVariables adds SOLIDSYSLOG_USER_TUNABLES_FILE pointing at the absolute path of the new header. The S21.01 INTERFACE-target plumbing then propagates -DSOLIDSYSLOG_USER_TUNABLES_FILE="…" to all consumers.
  • Permanent stack high-water-mark print on quit. The FreeRTOS BDD target's InteractiveTask now prints [stack-hwm] interactive=N words service=M words before destroy. Captured into every bdd-freertos-qemu CI run for regression detection on future E21 tuning. Adds INCLUDE_uxTaskGetStackHighWaterMark = 1 to FreeRTOSConfig.h and captures the Service task handle out of xTaskCreate.
  • Tunable-driven BDD tag gating. Replaces the initial static not @requires_message_size_1500 exclusion in ci/docker-compose.bdd.yml with a runtime before_feature / before_scenario hook in Bdd/features/environment.py. The hook parses any @requires_<tunable>_N tag, compares N against the build's value from the generated solidsyslog_tunables.py (the S21.01 Python mirror), and calls node.skip(...) when the gate isn't met.
    • Single source of truth: bump the FreeRTOS MAX back to ≥1500 and udp_mtu.feature re-enables itself with no compose-file edit.
    • Generic shape: future tunable gates (@requires_block_size_N, @requires_buffer_capacity_N) plug in by adding one entry to _TUNABLE_TAG_GATES in environment.py.

Test Evidence

  • Empirical stack savings (single send 1; quit under qemu-system-arm):
    Build Interactive HWM free Service HWM free
    MAX=2048 4929 words 1359 words
    MAX=512 5697 words 1743 words
    Reclaimed +768 w / 3.0 KB +384 w / 1.5 KB
  • cmake --preset freertos-cross in cpputest-freertos-cross:sha-10a14ae configures clean; generated solidsyslog_tunables.py mirrors 512.
  • SolidSyslogBddTarget.elf cross-builds clean; QEMU smoke run completes Sent 1 message + [stack-hwm] print.
  • Gating verified end-to-end via behave dry-runs in ghcr.io/davidcozens/behave:sha-3faff14:
    • MAX=512 → udp_mtu.feature 1 feature skipped, 2 scenarios skipped, 7 steps skipped, no oracle calls
    • MAX=2048 → feature attempts to run (only fails on missing oracle in the bare container)
  • Pre-PR local gates: build-linux-gcc ✓, build-linux-clang ✓, sanitize-linux-gcc ✓ (1106/1106 tests), analyze-tidy ✓, analyze-cppcheck ✓, analyze-format ✓.

Areas Affected

  • Tier 3 (Bdd/Targets/FreeRtos/): new tunables header, INCLUDE_uxTaskGetStackHighWaterMark in FreeRTOSConfig.h, stack-HWM print + task-handle capture in main.c, README "Tuning for your MCU" section.
  • BDD harness (Bdd/features/): environment.py gains the parametric @requires_<tunable>_N skip hook; udp_mtu.feature gains @requires_message_size_1500.
  • CI (ci/docker-compose.bdd.yml): drops the no-longer-needed static not @requires_message_size_1500 clause from behave-freertos.
  • CMakePresets.json: freertos-cross preset only — Linux/Windows/clang/sanitize/coverage/tidy/cppcheck/tunable-override-debug presets untouched.
  • No Tier-1 library code changed.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Interactive exit now reports stack high-water marks for both interactive and service tasks.
  • Documentation

    • Added a FreeRTOS tuning guide showing how to override message-buffer sizing; example reduces default message size to reclaim stack.
  • Tests

    • BDD harness gains runtime gate tags and will skip scenarios when build-time tunables don’t meet required thresholds.

Review Change Stack

…iven BDD gating

Points the freertos-cross preset's SOLIDSYSLOG_USER_TUNABLES_FILE at a
new Bdd/Targets/FreeRtos/solidsyslog_user_tunables.h that redefines
SOLIDSYSLOG_MAX_MESSAGE_SIZE to 512 (pre-S12.12 default). Empirically
reclaims 4.5KB of per-Log/Service stack frame on the Cortex-M3 BDD
target. Linux/Windows stay at 2048 for RFC 5424 SHOULD compliance.

Bakes a permanent [stack-hwm] high-water-mark print into the FreeRTOS
BDD target's InteractiveTask on quit so every bdd-freertos-qemu run
leaves an empirical stack-usage trail in CI for future E21 tuning.

Replaces the static `not @requires_message_size_1500` exclusion in
ci/docker-compose.bdd.yml with a runtime before_feature/before_scenario
hook in Bdd/features/environment.py. The hook parses any
@requires_<tunable>_N tag, compares N to the build's tunable value from
the generated solidsyslog_tunables.py, and skips when the gate isn't
met. Single source of truth for tunable-driven test selection.

Closes #349
@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bb72a5df-d8cc-4543-a9fb-298e2baa28a7

📥 Commits

Reviewing files that changed from the base of the PR and between b330c94 and 550ca72.

📒 Files selected for processing (3)
  • Bdd/Targets/FreeRtos/main.c
  • Bdd/Targets/FreeRtos/solidsyslog_user_tunables.h
  • DEVLOG.md
✅ Files skipped from review due to trivial changes (1)
  • DEVLOG.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • Bdd/Targets/FreeRtos/solidsyslog_user_tunables.h
  • Bdd/Targets/FreeRtos/main.c

📝 Walkthrough

Walkthrough

This PR implements S21.02: it adds a FreeRTOS user-tunables header setting SOLIDSYSLOG_MAX_MESSAGE_SIZE=512, wires it into the freertos-cross CMake preset, enables and reports FreeRTOS task stack high-water marks in the example, and adds runtime Behave hooks that skip scenarios tagged @requires_<tunable>_<N> when build-time tunables are too small.

Changes

FreeRTOS Message Size Tuning and Stack Monitoring

Layer / File(s) Summary
FreeRTOS Configuration and Stack Monitoring
Bdd/Targets/FreeRtos/FreeRTOSConfig.h, Bdd/Targets/FreeRtos/main.c
INCLUDE_uxTaskGetStackHighWaterMark enabled. ServiceTask handle is stored at creation and both interactive and service task high-water marks are printed on interactive task exit.
User Tunables Header and CMake Integration
Bdd/Targets/FreeRtos/solidsyslog_user_tunables.h, CMakePresets.json
New solidsyslog_user_tunables.h defines SOLIDSYSLOG_MAX_MESSAGE_SIZE 512. freertos-cross preset sets SOLIDSYSLOG_USER_TUNABLES_FILE to that header.
BDD Runtime Tunable-Based Test Gating
Bdd/features/environment.py
Environment imports generated tunables and adds before_feature/before_scenario hooks plus _skip_if_tunable_too_small to parse @requires_<tunable>_<N> tags and skip nodes when thresholds are unmet.
Test Tagging, Documentation, and CI Comments
Bdd/features/udp_mtu.feature, Bdd/Targets/FreeRtos/README.md, ci/docker-compose.bdd.yml
udp_mtu.feature tagged @requires_message_size_1500. README documents MCU tuning override pattern. Docker-compose comments updated to explain runtime tunable gating.
Implementation Record
DEVLOG.md
DEVLOG entry documents the 512-byte tuning decision, stack HWM reporting addition, and the shift to runtime Behave tag gating.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • DavidCozens/solid-syslog#349: Implements S21.02 acceptance criteria to set SOLIDSYSLOG_MAX_MESSAGE_SIZE=512 for the freertos-cross preset and related BDD gating and documentation.

Possibly related PRs

Poem

🐰 I nibble tunables down to size,
512 bytes — a tiny prize.
Stacks now whisper high-water marks,
Tests skip when the limit's stark.
A rabbit hops, config in paw, and grins with tiny eyes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: tuning freertos-cross MAX_MESSAGE_SIZE to 512 and implementing tunable-driven BDD gating, directly matching the changeset's primary objectives.
Description check ✅ Passed The description comprehensively covers Purpose, Change Description, Test Evidence, and Areas Affected sections with detailed explanations, decisional context, and empirical measurements—exceeding template requirements.
Linked Issues check ✅ Passed All acceptance criteria from issue #349 are met: solidsyslog_user_tunables.h created [#349], CMakePresets.json configured [#349], tunable-driven BDD gating implemented [#349], udp_mtu.feature tagged [#349], FreeRTOS stack HWM reporting added [#349], and documentation updated [#349].
Out of Scope Changes check ✅ Passed All changes align with issue #349 objectives: new tunables header, CMake preset tuning, BDD environment gating, FreeRTOS config, task handle capture, and documentation. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/s21-02-freertos-message-size

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

☀️   Quality Summary

   🚦   build-linux-gcc: 100% successful (✔️ 1112 passed, 🙈 3 skipped)
   🚦   build-freertos-host-tdd: 100% successful (✔️ 1199 passed, 🙈 3 skipped)
   🚦   build-linux-clang: 100% successful (✔️ 1064 passed, 🙈 3 skipped)
   🚦   sanitize-linux-gcc: 100% successful (✔️ 1064 passed, 🙈 3 skipped)
   🚦   integration-linux-openssl: 100% successful (✔️ 9 passed)
   🚦   integration-windows-openssl: 100% successful (✔️ 9 passed)
   🚦   bdd-linux-syslog-ng: 94% successful (✔️ 46 passed, 🙈 3 skipped)
   🚦   bdd-windows-otel: 90% successful (✔️ 44 passed, 🙈 5 skipped)
   🚦   bdd-freertos-qemu: 57% successful (✔️ 28 passed, 🙈 21 skipped)
   🚦   build-windows-msvc: 100% successful (✔️ 976 passed, 🙈 1 skipped)
   🚦   build-linux-tunable-override: 100% successful (✔️ 1064 passed, 🙈 3 skipped)
   ⚠️   Clang-Tidy: No warnings
   ⚠️   CPPCheck: No warnings


Created by Quality Monitor v1.14.0 (#f3859fd). More details are shown in the GitHub Checks Result.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Bdd/Targets/FreeRtos/main.c`:
- Around line 467-468: The ServiceTask creation result from xTaskCreate is not
being checked causing interactiveTaskCreated to be set to pdTRUE even if
ServiceTask fails; update the code around the xTaskCreate(ServiceTask, ...) call
to check its return value (pdPASS) before setting interactiveTaskCreated to
pdTRUE and before marking startup complete, log or handle the failure (e.g.,
clear/NULL serviceTaskHandle and emit an error) so subsequent code (including
the printf using uxTaskGetStackHighWaterMark(serviceTaskHandle)) doesn't report
misleading values; ensure serviceTaskHandle is only used when the task was
successfully created.

In `@Bdd/Targets/FreeRtos/solidsyslog_user_tunables.h`:
- Around line 11-14: Update the header comment in solidsyslog_user_tunables.h to
reflect that the test exclusion is now performed at runtime in
Bdd/features/environment.py (runtime skip logic), not via the
ci/docker-compose.bdd.yml tag filter; reword the comment to note the
`@requires_message_size_1500` feature is skipped at runtime by environment.py so
readers won't look for a compose-level exclusion and include a brief pointer to
the environment.py runtime skip behavior.

In `@DEVLOG.md`:
- Line 63: The DEVLOG line uses ambiguous notation `INTERACTIVE_TASK_STACK_DEPTH
= *48`; update the text to spell out the actual multiplier expression used in
code so it's unambiguous for readers—e.g., reference the exact expression like
`INTERACTIVE_TASK_STACK_DEPTH = configMINIMAL_STACK_SIZE * 48U` (or whatever
constant is used) and mention the related symbol `BddTargetInteractive` so the
log clearly matches the implementation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3475e683-240c-49ba-bfbf-69c57d20aea7

📥 Commits

Reviewing files that changed from the base of the PR and between 8eb9dbe and b330c94.

📒 Files selected for processing (9)
  • Bdd/Targets/FreeRtos/FreeRTOSConfig.h
  • Bdd/Targets/FreeRtos/README.md
  • Bdd/Targets/FreeRtos/main.c
  • Bdd/Targets/FreeRtos/solidsyslog_user_tunables.h
  • Bdd/features/environment.py
  • Bdd/features/udp_mtu.feature
  • CMakePresets.json
  • DEVLOG.md
  • ci/docker-compose.bdd.yml

Comment thread Bdd/Targets/FreeRtos/main.c Outdated
Comment thread Bdd/Targets/FreeRtos/solidsyslog_user_tunables.h Outdated
Comment thread DEVLOG.md Outdated
- main.c [stack-hwm] print: read serviceTaskHandle into a local guarded
  against NULL so a Service xTaskCreate failure can't make
  uxTaskGetStackHighWaterMark(NULL) silently double-report the
  interactive task's HWM.
- solidsyslog_user_tunables.h: header comment said udp_mtu.feature was
  excluded by the compose tag filter — corrected to point at the
  runtime gate in Bdd/features/environment.py.
- DEVLOG.md: spell out INTERACTIVE_TASK_STACK_DEPTH = configMINIMAL_STACK_SIZE * 48U
  instead of the ambiguous "*48" shorthand.

(Punted out of S21.02: CodeRabbit's broader fix that reorders the two
xTaskCreate calls so an interactive-task failure also tears down the
service task. Pre-existing failure-handling shape, not introduced here.)
@github-actions

Copy link
Copy Markdown
Contributor

☀️   Quality Summary

   🚦   build-linux-gcc: 100% successful (✔️ 1112 passed, 🙈 3 skipped)
   🚦   build-freertos-host-tdd: 100% successful (✔️ 1199 passed, 🙈 3 skipped)
   🚦   build-linux-clang: 100% successful (✔️ 1064 passed, 🙈 3 skipped)
   🚦   sanitize-linux-gcc: 100% successful (✔️ 1064 passed, 🙈 3 skipped)
   🚦   integration-linux-openssl: 100% successful (✔️ 9 passed)
   🚦   integration-windows-openssl: 100% successful (✔️ 9 passed)
   🚦   bdd-linux-syslog-ng: 94% successful (✔️ 46 passed, 🙈 3 skipped)
   🚦   bdd-windows-otel: 90% successful (✔️ 44 passed, 🙈 5 skipped)
   🚦   bdd-freertos-qemu: 57% successful (✔️ 28 passed, 🙈 21 skipped)
   🚦   build-windows-msvc: 100% successful (✔️ 976 passed, 🙈 1 skipped)
   🚦   build-linux-tunable-override: 100% successful (✔️ 1064 passed, 🙈 3 skipped)
   ⚠️   Clang-Tidy: No warnings
   ⚠️   CPPCheck: No warnings


Created by Quality Monitor v1.14.0 (#f3859fd). More details are shown in the GitHub Checks Result.

@DavidCozens DavidCozens merged commit 34f30ce into main May 12, 2026
20 checks passed
@DavidCozens DavidCozens deleted the feat/s21-02-freertos-message-size branch May 12, 2026 12:27
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.

S21.02: Tune SOLIDSYSLOG_MAX_MESSAGE_SIZE to 512 on the freertos-cross preset

1 participant