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

Avoid unnecessary copy in actix implementation #6762

Merged
merged 1 commit into from
Oct 4, 2023

Conversation

dgel
Copy link
Contributor

@dgel dgel commented Sep 29, 2023

No description provided.

@dgel dgel requested a review from waghanza as a code owner September 29, 2023 12:05
Copy link
Collaborator

@waghanza waghanza left a comment

Choose a reason for hiding this comment

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

As I understand (not a rust folk) this method unwrap the current path ?

You're point here is valid, but seems to add a little advantage to actix, maybe using inner_.... for other rust frameworks is something that we should do

@dgel
Copy link
Contributor Author

dgel commented Sep 29, 2023

Well I'm not a seasoned Rust programmer either, and not familiar with all these web frameworks. However, the actix framework clearly already made a copy of the string data before passing it into the get_user function (otherwise it would be a &str).

I feel this is comparable to other frameworks which extract the same string using a getter function before returning it as-is, such as viz. Additionally, Poem just moves the received string as well and rocket doesn't even create a String object in the user code, just receiving and returning a str slice

I'm not familiar at all with nim, but happyx for example doesn't seem to make an extra copy either.

I do agree this feels like the program doesn't do much, but there is already variation in what different frameworks do: some parse the id into an int whereas others just output the received string. Perhaps it would be more fair to standardize on what programs have to do with the received id beyond just outputting it, such as demanding that the id is parsed into an int and formatted again. Then again this would make it more of an int parsing / formatting benchmark than a web framework benchmark

@waghanza
Copy link
Collaborator

waghanza commented Oct 4, 2023

Could you give a hand @msrd0 @krishnaTORQUE @sunli829 @chrislearn ?

The argument seems reasonable here

Copy link
Contributor

@msrd0 msrd0 left a comment

Choose a reason for hiding this comment

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

Looking at the code for gotham ... we don't parse the input to an int or anything, and we don't run it through Rust's formatting code (because to_string() uses Display under the hood, and while the formatting code is pretty performant, it is still slower when formatting just one object (format-string {}), especially when we start with a string to begin with). So I'd say it is only fair to give the same treatment to actix - no int parsing and no formatting.

@waghanza waghanza merged commit e4bcf75 into the-benchmarker:master Oct 4, 2023
2 checks passed
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.

3 participants