Skip to content
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

Consider add inline attribute BytesMut::set_len #407

Closed
zzau13 opened this issue Jul 3, 2020 · 1 comment · Fixed by #408
Closed

Consider add inline attribute BytesMut::set_len #407

zzau13 opened this issue Jul 3, 2020 · 1 comment · Fixed by #408

Comments

@zzau13
Copy link
Contributor

zzau13 commented Jul 3, 2020

inline set_len call translates to assembler:

add     qword, ptr, [rsp, +, 8], LEN

It is much less instructions than preparing the registers for the call:

mov     rsi, qword, ptr, [rsp, +, 8]
add     rsi, LEN
mov     rdi, rsp
call    qword, ptr, [rip, +, _ZN5bytes9bytes_mut8BytesMut7set_len17h54d98ffd051013e5E@GOTPCREL]

The assembler generated with the inline attribute is https://github.com/botika/buf-min/blob/master/benches/README.md from https://github.com/botika/buf-min/blob/master/benches/src/main.rs

@zzau13 zzau13 changed the title Consider adding inline attribute BytesMut::set_len Consider add inline attribute BytesMut::set_len Jul 3, 2020
@seanmonstar
Copy link
Member

Sounds good and simple, want to make a PR?

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 a pull request may close this issue.

2 participants