Skip to content

investigate: STL/heap usage reduction for ETL compatibility (#174)#177

Open
vtz wants to merge 2 commits intomainfrom
investigate/174-stl-etl-reduction
Open

investigate: STL/heap usage reduction for ETL compatibility (#174)#177
vtz wants to merge 2 commits intomainfrom
investigate/174-stl-etl-reduction

Conversation

@vtz
Copy link
Copy Markdown
Owner

@vtz vtz commented Mar 28, 2026

Summary

Adds docs/investigations/stl-etl-reduction.md: a quantitative audit of heap-allocating STL usage in include/ and src/ (excluding tests/examples) for #174.

Key findings (high level)

  • std::vector<uint8_t> is central to the message / serialization / SD / TP / RPC / events data path (~202 matching lines across 37 files). Bounded ETL replacement needs an explicit max payload policy (MTU-shaped ~1400, single-buffer TCP-ish up to 64 KiB, TP default 1 MiB in TpConfig, UDP datagram cap ~64 KiB; 32-bit length field allows larger logical sizes only if the stack and product allow it).
  • std::unordered_map appears in 12 files; many maps are already effectively bounded (TP concurrency, session IDs, event IDs). Diagnostic enum→string maps are easy constexpr wins.
  • std::function is used in public callbacks and in RTOS/ThreadX/Zephyr thread_impl via heap-allocated std::function—the platform path is a high-value target for etl::delegate or fn-pointer context.
  • Message pooling on RTOS does not remove vector payload heap on POSIX or in the object model itself.
  • Recommendation: ETL as optional (SOMEIP_USE_ETL-style) plus type aliases / capacity macros; not a required dependency for multi-platform builds.

Deliverable

Full tables, file/line references, categorization (easy / moderate / hard / not recommended), suggested follow-up tickets, and optional-vs-required ETL assessment are in the report.

Made with Cursor

Summary by CodeRabbit

  • Documentation
    • Added an in-depth investigation report analyzing memory allocation patterns and container usage throughout the codebase. The report provides an inventory-based methodology, detailed findings organized by subsystem, identified optimization opportunities with priority classification, documentation of existing configuration constraints, and recommended implementation strategies with prioritized follow-up suggestions.

Audit include/ and src/ for heap-allocating STL (vector, string,
unordered_map, smart pointers, function, queue) with data-path vs
setup classification, bounded-size notes, and prioritized follow-ups
for optional ETL integration.

Made-with: Cursor
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 28, 2026

Warning

Rate limit exceeded

@vtz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 21 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 3 minutes and 21 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 946b8683-0252-4805-bb82-7f9f25ff369a

📥 Commits

Reviewing files that changed from the base of the PR and between 0f8b7a8 and 8f082ab.

📒 Files selected for processing (1)
  • docs/investigations/stl-etl-reduction.md
📝 Walkthrough

Walkthrough

A comprehensive investigative documentation file analyzing STL container usage patterns and heap allocations throughout the codebase, providing an inventory-oriented methodology, categorized findings, and recommendations for potential Embedded Template Library (ETL) optimization.

Changes

Cohort / File(s) Summary
STL/Heap Investigation Documentation
docs/investigations/stl-etl-reduction.md
Added 292-line investigation document cataloging std::vector, std::string, std::unordered_map, smart pointers, std::function, std::queue, and raw heap allocations. Includes methodology, categorized findings by subsystem (core payload, serialization, transport, TP, SD, RPC/events), feasibility assessment ("easy wins," "moderate effort," "hard/not feasible"), and recommended approach with follow-up ticket suggestions.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related issues

Poem

🐰 Whiskers twitching through the code so deep,
We've mapped where vectors dance and heaps do leap!
STL's scattered—time to trim the fat,
A roadmap written, now here's where we're at! 🎯

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: an investigation document on reducing STL/heap usage for ETL compatibility, directly corresponding to the added investigation file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch investigate/174-stl-etl-reduction

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/investigations/stl-etl-reduction.md`:
- Line 1: Remove the trailing whitespace that the pre-commit hook fixed in the
document titled "# Investigation: Reducing heap / STL usage for ETL
compatibility": open that file, strip any trailing spaces at the ends of lines
(or run the project's pre-commit hooks locally), save the file, and commit the
change so CI no longer fails.
- Line 30: Update the phrasing in the markdown: replace "very large" with
"arbitrarily large" or "unbounded" in the sentence that describes the on-wire
Length field, and change "consumers that" to "consumers who" when referring to
developers/organizations; the sentence also references
TpConfig::max_message_size and max_segment_size (in include/tp/tp_types.h) —
keep those symbols unchanged while applying the wording edits for improved
style.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: dfe1378f-f235-440a-afca-06498866291c

📥 Commits

Reviewing files that changed from the base of the PR and between 4b76d18 and 0f8b7a8.

📒 Files selected for processing (1)
  • docs/investigations/stl-etl-reduction.md

**SOME/IP payload sizing (for bounded designs):**

- The header defines **practical caps** used in validation: `DEFAULT_MAX_PAYLOAD_SIZE = 1400`, `MAX_TCP_PAYLOAD_SIZE = 65535` (`include/someip/message.h`).
- The on-wire **Length** field is **32-bit**; in principle very large logical messages are representable, but **UDP datagrams** are bounded (~**65507** bytes payload for IPv4 UDP). Larger payloads rely on **TP** segmentation; this codebase sets **`TpConfig::max_message_size` default to 1_000_000 bytes** (~1 MiB) and **`max_segment_size` ~1392** (`include/tp/tp_types.h`).
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 | 🔵 Trivial

Optional: Consider style refinements.

Static analysis flagged two minor style points:

  • Line 30: "very large" could be replaced with "arbitrarily large" or "unbounded" for variety
  • Line 33: "consumers that" could be "consumers who" when referring to developers/organizations

These are entirely optional readability improvements and do not affect technical content.

Also applies to: 33-33

🧰 Tools
🪛 LanguageTool

[style] ~30-~30: As an alternative to the over-used intensifier ‘very’, consider replacing this phrase.
Context: ...gth** field is 32-bit; in principle very large logical messages are representable, but...

(EN_WEAK_ADJECTIVE)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/investigations/stl-etl-reduction.md` at line 30, Update the phrasing in
the markdown: replace "very large" with "arbitrarily large" or "unbounded" in
the sentence that describes the on-wire Length field, and change "consumers
that" to "consumers who" when referring to developers/organizations; the
sentence also references TpConfig::max_message_size and max_segment_size (in
include/tp/tp_types.h) — keep those symbols unchanged while applying the wording
edits for improved style.

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