Skip to content

feat: Improve Writing Performance Further#71

Draft
siliconlad wants to merge 3 commits intomainfrom
angus/improve-writing-performance
Draft

feat: Improve Writing Performance Further#71
siliconlad wants to merge 3 commits intomainfrom
angus/improve-writing-performance

Conversation

@siliconlad
Copy link
Owner

No description provided.

@siliconlad siliconlad self-assigned this Oct 3, 2025
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment on lines +53 to +60
key = (message_type, little_endian)
encoder = self._encoders.get(key)
if encoder is None:
encoder = self._message_encoder(little_endian=little_endian) # type: ignore[call-arg]
self._encoders[key] = encoder
# Cache is keyed by endianness, so the header stays valid.
else:
encoder.reset()

Choose a reason for hiding this comment

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

P1 Badge Avoid clearing encoder buffer while SerializedMessage holds memoryview

The encoder cache introduced in serialize_message_view reuses a single CdrEncoder per message type and immediately calls encoder.reset() when the encoder is reused (lines 53‑60). However, CdrEncoder.save() now returns a SerializedMessage containing a memoryview of the encoder’s internal bytearray. When serialize_message_view is called again while the previous SerializedMessage is still alive, BytesWriter.clear() attempts to resize the buffer and Python raises BufferError: Existing exports of data: object cannot be re-sized. Even simple sequential calls like serialize_message_view(msg1); serialize_message_view(msg2) crash, making the zero-copy API unusable. The encoder should not be cleared until the previous view is released or the data should be copied before reset.

Useful? React with 👍 / 👎.

@siliconlad siliconlad marked this pull request as draft November 3, 2025 22:53
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