Skip to content

Conversation

@ChALkeR
Copy link
Member

@ChALkeR ChALkeR commented Dec 19, 2025

Tracking: #61041

This builds on top of #61093 and #61118 and gives an additional ~1.4x improvement by using iteration in pairs for this single encoding, as it's commonly used (it's aliased as latin1)

Combined, this is ~114x faster than main on ASCII (due to #61093 + #61118) and ~71x faster than main on non-ASCII

This could be improved further with latin1 checks and by moving ascii checks to prefixes instead, but let #61119 land first

I'm not sure if this even makes sense at this point, it comes at a cost of 128 KiB cache (even though allocated at the first large use)

Perhaps there is some other way or we could ignore this

Warning

Very crude, just a concept demonstration at this point

See #61118 for previous benchmarks

Test Size Throughput Mean Time
Latin lipsum (ASCII) 84.902 KiB 35.45 GiB/s 0.003 ms
Complex 1 79.771 KiB 4.24 GiB/s 0.021 ms

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Dec 19, 2025
@ChALkeR ChALkeR force-pushed the chalker/decoder/single-byte/2 branch from 5b3053e to 7b11e38 Compare December 19, 2025 02:26
Comment on lines +425 to +432
if (!tWindows1252x2) {
tWindows1252x2 = (uint32_t *) malloc(256 * 256 * 4); // 256 KiB
for (uint16_t i = 0; i < 256; i++) {
for (uint16_t j = 0; j < 256; j++) {
tWindows1252x2[(i << 8) + j] = (((uint32_t) table[i]) << 16) + table[j];
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

We’re allocating this table (tWindows1252x2) here for the first time, but we never free it anywhere
This could lead to unnecessary memory usage in long-running processes

I think we should add a cleanup hook right after the allocation, so the table gets freed automatically when the environment shuts down

Copy link
Member Author

@ChALkeR ChALkeR Dec 19, 2025

Choose a reason for hiding this comment

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

this PR is a crude concept demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants