Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use single TextEncoder/-Decoder instance #22

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

achim-k
Copy link
Contributor

@achim-k achim-k commented Dec 29, 2023

Public-Facing Changes

None

Description

Instead of creating a new TextDecoder instance for every CdrReader instance, a single TextDecoder instance is used to reduce unnecessary GC cycles. The same is done for TextEncoder / CdrWriter.

@achim-k achim-k changed the title Use cached TextEncoder/-Decoder instances Use single TextEncoder/-Decoder instance Dec 29, 2023
Copy link

@defunctzombie defunctzombie left a comment

Choose a reason for hiding this comment

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

What kind of measured difference did you experience with this change? I would not think we make a new CdrReader that often, do we?

@achim-k
Copy link
Contributor Author

achim-k commented Dec 29, 2023

A new CdrReader instance is created for every message: https://github.com/foxglove/rosmsg2-serialization/blob/main/src/MessageReader.ts#L43-L46

However, I don't think that this will make a very noticeable performance difference (I didn't measure it)

@achim-k achim-k merged commit 60de1d9 into main Jan 2, 2024
2 checks passed
@achim-k achim-k deleted the achim/cache-text-encoder-decoder branch January 2, 2024 14:43
achim-k added a commit to foxglove/omgidl that referenced this pull request Jan 8, 2024
### Public-Facing Changes

None

### Description
Bumps `@foxglove/cdr` to 3.2.1 to include
foxglove/cdr#22

@snosenzo probably makes sense to add a dependabot configuration file to
this repo?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants