Skip to content

perf: optimize buffer handling and fragment gecoding#128

Open
ppmpreetham wants to merge 2 commits intodenoland:mainfrom
ppmpreetham:main
Open

perf: optimize buffer handling and fragment gecoding#128
ppmpreetham wants to merge 2 commits intodenoland:mainfrom
ppmpreetham:main

Conversation

@ppmpreetham
Copy link
Copy Markdown

Improves memory efficiency and reduces CPU overhead in the WebSocket writing and fragment processing logic. Shifted to ownership transfers and in-place mutations and reduced the number of heap allocations and eliminate unnecessary buffer zero-initializations.

Operation Before this PR After this PR
Write Header Allocation + Zero-init + Copy Allocation + Copy
Decode Text $O(n)$ Copy to new Vec $O(1)$ Ownership transfer / Truncate

avoids zero-filling the vec when resizing and simplifies the write logic.
@ppmpreetham
Copy link
Copy Markdown
Author

@littledivy , could you please check this?

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