-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[Swift] Push contiguous bytes #8157
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
…tbuffers into push-ContiguousBytes
@wtholliday Hey, thanks for your contribution. Would love to point out it would be nice to add 1- A benchmark test to show that the code that's written has a better performance than It would be a simple test, where we take in an array of 2- Tests to verify that you can read the code back. In FlatBuffersMonsterWriterTests.swift create a new function that writes a new monster but instead of using the normal create vector use the new one that you created and then try reading it. |
@wtholliday continuation of my thought process, sorry for not including it earlier 3- It would be nice to investigate if it's possible to actually completely migrate the createVector function into similar one to the one you wrote. 4- Instead of using
can you please use
|
Going to wait for a few other fixes to land, then I'll get back to this :) |
Looks great! What is missing is the tests to verify we can write and read properly. Furthermore, optionally, do you still want to add the changes to the other vector function? |
Yep still planning to add tests. I will also see what I can do about converting the existing API |
@wtholliday Perfect! cause we are planning on having a release soon so it would be amazing to have the changes for everyone 😄 |
Since we don't care about endianness, we can simply memcpy the array of scalars
Since we don't care about endianness, a FixedWidthInteger version of createVector isn't needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Add version of push which takes ContiguousBytes * Ensure overloads aren't ambiguous * Add version of createVector * Add version of push which takes ContiguousBytes * Ensure overloads aren't ambiguous * Add version of createVector * Add similar conditional to other use of ContiguousBytes * Attempt CI fix * Use memcpy instead of copyMemory memcpy is faster in tests * Add testContiguousBytes * Add benchmarks * Add version of createVector * Add benchmarks * Update push to copy memory Since we don't care about endianness, we can simply memcpy the array of scalars * Remove function and benchmarks Since we don't care about endianness, a FixedWidthInteger version of createVector isn't needed * Improve naming * Add doc comment
* Add version of push which takes ContiguousBytes * Ensure overloads aren't ambiguous * Add version of createVector * Add version of push which takes ContiguousBytes * Ensure overloads aren't ambiguous * Add version of createVector * Add similar conditional to other use of ContiguousBytes * Attempt CI fix * Use memcpy instead of copyMemory memcpy is faster in tests * Add testContiguousBytes * Add benchmarks * Add version of createVector * Add benchmarks * Update push to copy memory Since we don't care about endianness, we can simply memcpy the array of scalars * Remove function and benchmarks Since we don't care about endianness, a FixedWidthInteger version of createVector isn't needed * Improve naming * Add doc comment
* Add version of push which takes ContiguousBytes * Ensure overloads aren't ambiguous * Add version of createVector * Add version of push which takes ContiguousBytes * Ensure overloads aren't ambiguous * Add version of createVector * Add similar conditional to other use of ContiguousBytes * Attempt CI fix * Use memcpy instead of copyMemory memcpy is faster in tests * Add testContiguousBytes * Add benchmarks * Add version of createVector * Add benchmarks * Update push to copy memory Since we don't care about endianness, we can simply memcpy the array of scalars * Remove function and benchmarks Since we don't care about endianness, a FixedWidthInteger version of createVector isn't needed * Improve naming * Add doc comment
I noticed that saving in my app was quite slow as each individual byte of a byte buffer was treated generically as a
Scalar
:This change uses
ContiguousArray
to optimize that. Runtime went from 1s to 2ms. I'm not sure what the exact API should be.