Repository navigation
Improve perfromance in some hotspots - #868
Open
tkaitchuck wants to merge 1 commit into
Open
tkaitchuck wants to merge 1 commit into
tkaitchuck wants to merge 1 commit into
Conversation
Signed-off-by: Tom Kaitchuck <[email protected]>
GlenDC
reviewed
Nov 9, 2026
GlenDC
left a comment
Member
There was a problem hiding this comment.
~30% on serde_json -> BytesMut here too, few nits inline.
| } | ||
|
|
||
| #[inline] | ||
| fn write_all(&mut self, src: &[u8]) -> io::Result<()> { |
Member
There was a problem hiding this comment.
no tests for Writer at all, maybe add one for write_all incl. partial write + WriteZero (&mut [u8] / .limit(n))?
| self.buf.put_slice(src); | ||
| Ok(()) | ||
| } else { | ||
| let n = self.buf.remaining_mut(); |
Member
There was a problem hiding this comment.
nit: could read remaining_mut() once up front
| } else { | ||
| let n = self.buf.remaining_mut(); | ||
| self.buf.put_slice(&src[..n]); | ||
| Err(io::ErrorKind::WriteZero.into()) |
Member
There was a problem hiding this comment.
msg differs from std's default ("write zero" vs "failed to write whole buffer"), maybe io::Error::new(WriteZero, "failed to write whole buffer")?
| unsafe { | ||
| self.advance_mut(cnt); | ||
| // Reserved above | ||
| self.set_len(self.len() + cnt); |
Member
There was a problem hiding this comment.
put_bytes does the same advance_mut after reserve, same change works there
Member
|
@tkaitchuck can you also rebase this once again on top of master? It fixes the current loom CI issue. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This creates a slightly simpler implementation of two 'hot' methods. These implementations should be equivalent to the prior ones, but with better performance. I would consider both of these changes small and maintainable.
In my testing these improve the serialization performance of
serde_jsonby28%