Skip to content

hostip: make create_hostcache_id avoid alloc + free - #3544

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/create-hostcache-on-stack
Closed

bagder wants to merge 1 commit into
masterfrom
bagder/create-hostcache-on-stack

Conversation

@bagder

@bagder bagder commented Feb 9, 2019

Copy link
Copy Markdown
Member

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.

@danielgustafsson danielgustafsson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@jay

jay commented Feb 9, 2019

Copy link
Copy Markdown
Member

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

jay commented Feb 9, 2019

Copy link
Copy Markdown
Member

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

@bagder

bagder commented Feb 9, 2019

Copy link
Copy Markdown
Member Author

Indeed, thanks!

@bagder
bagder force-pushed the bagder/create-hostcache-on-stack branch from 099d57f to f7a3d04 Compare February 9, 2019 23:45
@bagder bagder closed this in 81a9fe4 Feb 11, 2019
@bagder
bagder deleted the bagder/create-hostcache-on-stack branch February 11, 2019 07:58
@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.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants