-
Notifications
You must be signed in to change notification settings - Fork 112
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
Do not create a new TextDecoder for every record #1031
Conversation
@@ -1,9 +1,10 @@ | |||
import { getBigUint64 } from "./getBigUint64"; | |||
|
|||
const textDecoder = new TextDecoder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a comment about why we are using a global decoder.
I'm not aware of any issue with doing this (I've long hated that the API requires a new instance each time) but it could be that the decoder holds onto some internal state for longer than we'd want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a comment. The encoding seems to be the TextDecoder's only internal state
### Public-Facing Changes Do not create a new TextDecoder for every record ### Description Massively improves read performance by avoiding unnecessary creation / cleanups of TextDecoders. Before: ``` [Summary]: ticks total nonlib name 6600 7.2% 46.1% JavaScript 7693 8.4% 53.8% C++ 21411 23.3% 149.6% GC 77489 84.4% Shared libraries 16 0.0% Unaccounted ``` After (Notice the drop in GC time): ``` [Summary]: ticks total nonlib name 3950 10.1% 60.7% JavaScript 2555 6.6% 39.2% C++ 549 1.4% 8.4% GC 32426 83.3% Shared libraries 5 0.0% Unaccounted ```
**User-Facing Changes** Improve performance of reading MCAP files **Description** Includes foxglove/mcap#1031
Public-Facing Changes
Do not create a new TextDecoder for every record
Description
Massively improves read performance by avoiding unnecessary creation / cleanups of TextDecoders.
Before:
After (Notice the drop in GC time):