Repository navigation
SwiftQUIC: Change LogPrefixer from a class to a struct - #215
agnosticdev wants to merge 2 commits into
Conversation
|
How does this change the memory allocation? |
LogPrefixer is a class so it gets saved on the heap when used, changing to a struct avoids that. Also, because it’s a class when it’s passed around we previously incurred a swift_retain. This also avoids that. |
|
Regarding #204, this change now makes any copies of the congestion control algorithm that need to be made a lot less CPU intensive. For example on the hot path with this change in When it used to be: |
I was asking how much more memory will this use because now we are copying it around and before we took a reference. |
|
I have tried to make this change before and quickly realized that this wouldn't work: the real log prefix is set after the connection starts and after many of the LogPrefixer instances are created. Since they all reference the same LogPrefixer object, they will all get the correct "[C]" after the connection starts. As is, this PR will break logging. |
rpaulo
left a comment
There was a problem hiding this comment.
I think this breaks logging.
This change moves LogPrefixer from a class to a struct.
Result is fewer allocations and less ARC traffic as its moved around the stack.