swift 6.0+ performance tweaks 3x-6x #9067
Conversation
|
1- is there any chance that you also add or investigate the same changes to the flexbuffer implementation? |
|
Sorry for extra ping, I was a bit trigger happy there - missed you were in @mustiikhalil - will let @blindspotbounty respond. |
When do you think it will go in approx? Looks like a great update, 5.10 and older is more or less gone now I think. |
Not sure, I pinged for help to review it let's see though! If it doesn't get reviewed the today or tomorrow then we can merge this and update the other branch |
mustiikhalil
left a comment
There was a problem hiding this comment.
Amazing work! some minor changes! and ofc the CI hasnt passed
|
@blindspotbounty The swift upgrade PR has been merged! Please pull, and update the current Pr with the changes required. We will need to check if the gRPC changes will run with the new code change that you've done. Then it would be interesting to look at the changes for flexbuffers (I use those more than flatbuffers nowadays) |
|
What happened to this pr? any updates? |
@mustiikhalil thank you for pinging me. Sorry, I was busy with other stuff. |
|
@blindspotbounty no worries! And thanks again |
|
@mustiikhalil I pushed addressed feedback. Also added several flex buffers benchmarks as a separate target (let me know if should be the same). Re-measured latest main vs branch locally: |
|
Feels like all CI passes except typescript but that one seems unrelated... |
mustiikhalil
left a comment
There was a problem hiding this comment.
LGTM!
@blindspotbounty thanks for opening the PR and taking it to the finish line!
|
@mustiikhalil let me know if I should do anything about TS CI which is required. |
|
@blindspotbounty Yes, there is a pr that will hopefully fix the TS ci #9140. |
|
@blindspotbounty can you rebase from master? |
|
@mustiikhalil rebased! Waiting CI! |
|
@blindspotbounty thanks for your contribution. Should i merge? |
|
Go ahead! |
We were experimenting with the latest changes for swift flatbuffers runtime and found several tweaks that allow to have significantly faster:
letBlobas@frozenfor library evolution modeBlobas~Copyableto avoid compiler inserted copies (swift 6.0+)BitwiseCopyableannotation for directly read types (swift 6.0+)exclusivity(unchecked)for FlatbuffersBuilder - assuming it is always exclusive anywayfunc duplicateto not crash in debug with default valueBenchmarks give a lot of false negative/positive results in main vs main on my machine (i.e. deviation is >+-5%). I guess mainly due to allocations.
However, there are the main improvements:
For serialization I probably need to add one more test. However the difference is quite noticeable.
Was:

Became:

All improvements are manly due to removing swift runtime calls: exclusivity checks and runtime metadata access.
In practice, all improvements give up to 3x-6x gain on scale.
@mustiikhalil I put all tweaks that we have currently together.
Let me know if I should split them or if something is going to be implemented other way (or if I need to make separate cases for those improvements).