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

hostip: make create_hostcache_id avoid alloc + free #3544

Closed
wants to merge 1 commit into from

Conversation

@bagder
Copy link
Member

@bagder bagder commented Feb 9, 2019

The data is short-lived and will be copied anyway. By using a stack buffer and not doing a sprintf + lower case in two separate passes, this should speed this up quite a lot - although presumably not really noticeable...

In my test 8GB HTTP transfer from localhost, this patch reduces the total number of allocations needed from 87 to 83.

Copy link
Member

@danielgustafsson danielgustafsson left a comment

LGTM

@jay
Copy link
Member

@jay jay commented Feb 9, 2019

I can't tap on the individual line in this browser but len-- is going to roll so len-1 is no good you could use 7 instead

@jay
Copy link
Member

@jay jay commented Feb 9, 2019

erm assuming the colon like nix the *ptr++=':'; and then do it like 7, ":%u"

@bagder
Copy link
Member Author

@bagder bagder commented Feb 9, 2019

Indeed, thanks!

@bagder bagder force-pushed the bagder/create-hostcache-on-stack branch from 099d57f to f7a3d04 Feb 9, 2019
@bagder bagder closed this in 81a9fe4 Feb 11, 2019
@bagder bagder deleted the bagder/create-hostcache-on-stack branch Feb 11, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.