Skip to content

Send BTP acks more frequently; large memory reduction in responder - #554

Merged
ivmarkov merged 3 commits into
project-chip:mainfrom
sysgrok:short-ble-acks
Sep 17, 2026
Merged

ivmarkov merged 3 commits into
project-chip:mainfrom
sysgrok:short-ble-acks

Conversation

@ivmarkov

@ivmarkov ivmarkov commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Subject says it all. Really two unrelated fixes, but since the memory fix in the respond module was a one-liner, I combined it with the BTP timeout fix.

EDIT 1: Also back-ported an mDNS fix from this: sysgrok/edge-net#104
EDIT 2: The memory fix in respond (a port of sysgrok/edge-net#105) might have far-reaching consequences, like completely getting rid of the bump allocator in downstream crates.

Copilot AI 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.

🔵 Needs a closer look

The respond change relies on subtle unsafe Pin invariants for async futures that warrant a human sign-off despite appearing sound.

Pull request overview

This PR bundles two independent fixes for rs-matter. First, it corrects the BTP (Bluetooth Transport Protocol) stand-alone ACK cadence: the responder was scheduling ACKs using the 15s receive-side ACK deadline (BTP_CONN_IDLE_TIMEOUT_SECS / 2), which risks the peer tearing down the session during long-running responses (e.g. ConnectNetwork). It introduces a dedicated, smaller BTP_ACK_SEND_TIMEOUT_SECS (2s) for the send side. Second, it reduces the memory footprint of the respond module by pinning the handlers vector in place instead of via pin!, avoiding a duplicate copy of the (large) handlers array in the generated future.

Changes:

  • Add BTP_ACK_SEND_TIMEOUT_SECS = 2 and use it as the BTP send-side ACK timeout everywhere BTP_ACK_TIMEOUT_SECS was previously used (the old constant is retained for documentation with #[allow(dead_code)]).
  • Replace pin!(handlers) + map_unchecked_mut with Pin::new_unchecked(handlers.as_mut_slice()) to avoid storing the handlers twice in the future.
  • Document both fixes in CHANGELOG.md.
File summaries
File Description
rs-matter/src/transport/network/btp/session.rs Adds the new BTP_ACK_SEND_TIMEOUT_SECS constant and explanatory docs; keeps the old constant for reference.
rs-matter/src/transport/network/btp.rs Switches the default/reset ACK timeout and import to the new send-side constant.
rs-matter/src/respond.rs Pins the handlers slice in place to halve the future's memory usage; imports Pin.
CHANGELOG.md Documents the BTP ACK and respond memory fixes under a new [Unreleased] section.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread CHANGELOG.md Outdated
@github-actions

Copy link
Copy Markdown

PR #554: Size comparison from b6a708f to 9176001

Full report (8 builds for (core), dimmable-light, onoff-light, onoff-light-bt, speaker)
platform target config section b6a708f 9176001 change % change
(core) riscv32imac-unknown-none-elf infodefmt-optz-ltofat FLASH 419706 419782 76 0.0
RAM 72864 72864 0 0.0
thumbv6m-none-eabi infodefmt-optz-ltofat FLASH 341280 341440 160 0.0
RAM 68412 68412 0 0.0
thumbv7em-none-eabi infodefmt-optz-ltofat FLASH 323048 323192 144 0.0
RAM 68180 68180 0 0.0
x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 843059 843387 328 0.0
RAM 73810 73810 0 0.0
dimmable-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 2057968 2058184 216 0.0
RAM 5472 5472 0 0.0
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 2017272 2017496 224 0.0
RAM 5456 5456 0 0.0
onoff-light-bt x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 3461456 3462320 864 0.0
RAM 5740 5740 0 0.0
speaker x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 2020440 2020640 200 0.0
RAM 5456 5456 0 0.0

@ivmarkov
ivmarkov merged commit c92bebf into project-chip:main Sep 17, 2026
20 of 21 checks passed
@ivmarkov
ivmarkov deleted the short-ble-acks branch September 17, 2026 11:47
Copilot AI mentioned this pull request Sep 17, 2026
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.

2 participants