Skip to content

perf(embedders): avoid a redundant copy in save_log_message - #11227

Merged
mraszyk merged 1 commit into
masterfrom
mraszyk/debug-print-copy-perf
Aug 20, 2026
Merged

perf(embedders): avoid a redundant copy in save_log_message#11227
mraszyk merged 1 commit into
masterfrom
mraszyk/debug-print-copy-perf

Conversation

@mraszyk

@mraszyk mraszyk commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

save_log_message copied the whole [src, src + size) heap range into an owned Vec before appending it to the canister log. The log then truncates each record to its byte capacity, so all bytes beyond that capacity were copied only to be dropped right away.

Copy just the bytes that are actually retained. The bounds check still covers the full range, so an out-of-bounds range is reported as such rather than being truncated, and the resulting log record is unchanged.

`save_log_message` copied the whole `[src, src + size)` heap range into an
owned `Vec` before appending it to the canister log. The log then truncates
each record to its byte capacity, so all bytes beyond that capacity were
copied only to be dropped right away.

Copy just the bytes that are actually retained. The bounds check still covers
the full range, so an out-of-bounds range is reported as such rather than
being truncated, and the resulting log record is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the perf label Aug 20, 2026
@mraszyk
mraszyk marked this pull request as ready for review August 20, 2026 07:40
@mraszyk
mraszyk requested a review from a team as a code owner August 20, 2026 07:40
@zeropath-ai

zeropath-ai Bot commented Aug 20, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to 4d2c878.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/embedders/src/wasmtime_embedder/system_api.rs
      Modify save_log_message to constrain log content to canister log capacity and handle out-of-bounds memory ranges more explicitly

@mraszyk
mraszyk added this pull request to the merge queue Aug 20, 2026
Merged via the queue into master with commit a607c61 Aug 20, 2026
43 checks passed
@mraszyk
mraszyk deleted the mraszyk/debug-print-copy-perf branch August 20, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants