Skip to content

Skip the first write when a string has more characters than free pool bytes - #1337

Merged
uNetworkingAB merged 1 commit into
uNetworking:masterfrom
nigrosimone:nativestring-skip-long
Sep 30, 2026
Merged

uNetworkingAB merged 1 commit into
uNetworking:masterfrom
nigrosimone:nativestring-skip-long

Conversation

@nigrosimone

Copy link
Copy Markdown
Contributor

When a string has more characters than the free bytes of the pool, it can never fit: the first write from #1335 fills the pool and is thrown away, then the string is measured and written again. Now the first write is skipped. This is the slow path that ValoChet found in #1302.

app.publish('t', message) with no subscribers, Windows, Node 26, min of 9 rounds:

  • ascii 200 KB: from 12.0 to 6.9 us
  • 200 K chars of € (600 KB of utf-8): from 838 to 672 us
  • ascii 1 KB, 100 KB and 1 MB: same

tests/strings.js covers this path with the "past the pool" cases.

@nigrosimone
nigrosimone marked this pull request as ready for review September 30, 2026 03:51
@uNetworkingAB
uNetworkingAB merged commit f4fc521 into uNetworking:master Sep 30, 2026
1 check failed
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.

2 participants