-
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] Add allowReadingUnalignedBuffers to most ByteBuffer init methods #8134
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. |
@abandy was there a case where you needed this specific implementation? If so can you provide an example? |
Hi @mustiikhalil, I hope all is well. In swift arrow we have a method that creates a ByteBuffer from data which can be unaligned. It would be less overhead if I can just create the ByteBuffer from the unaligned Data struct. |
Hey @abandy
Makes sense. We can definitely add this! I guess it would be benefitial for alot of people. However to be completely transparent with you, there is also an overhead reading an unaligned buffer which you can also revisit and see if that's something type of overhead you would be willing to take. Which would lead to either of these three options:
ref: flatbuffers/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersVerifierTests.swift Line 59 in 205285c
As i mentioned above we can merge this. However, since performance is what you need, it would make more sense if we can verify the three options with benchmarks. Reading an unaligned buffer, realigning a buffer and a verified buffer (Personally, i havent used the verifier before so it would be interesting to see its performance in general) |
Hi @mustiikhalil, the unaligned buffer error is fatal so catching it is not an option (AFAIK). I am planning to have the user elect to use the unaligned buffer and will not set it by default, that way the user can decide to take the performance hit or align the buffer if they chose. If we could merge this change that would be great! I have tried the verifier but it doesn't fail for me with the overall buffer but there is a header in the message buffer that fails afterward. When I have sometime I will investigate, as it will allow for a non fatal approach. Also, is it possible to get a new version released? It seems that the last version for the swift flatbuffers was prior to your last changes. |
So catching the error is definitely not an option since swift is actually throwing the fatal error. However with the verifier should've at least verified the buffer before hand.
Yes running the CI now.
Would be perfect if you can provide an example, since we need to have the verifier actually work instead of just failing randomly.
I can ask but no promises for the near future. |
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
@mustiikhalil I have a follow up PR in arrow after this has been merged. Afterward, I will create a fork using the verifier and post the instructions on how to repro an error here. |
If the changes aren't big, just add them within this PR and we can rename it/tag the new issue. |
My follow up PR is in the Apache Arrow repo. |
Awesome, that is great, thank you! This change shouldn't affect the C++ tests. I noticed your PR is failing in on the same C++ test as well. |
@mustiikhalil Is there a way to force the failing test to run again? |
@abandy |
Agreed, strange, all the other C++ versions passed. Is there a flatbuffers dev who manages the C++ versions that can take a look at this? |
@mustiikhalil I hope all is well. The C++ error shouldn't be related to these swift changes. Do you know if there is someone we can reach out to in order to request assistance in resolving the C++ 23 linux issue? |
@CasperN should we just merge since the error is more of a cpp compile error? |
Looks like CI is trying to build |
|
Agreed, it looks like the issue started when CI ran against this PR and is happening for subsequent PRs as well. Maybe something changed in the CI (a change in the docker image)? |
@mustiikhalil @CasperN any chance we can get this issue resolved soon? |
Personally, i dont mind merging this. Since the changes are only related to swift code, However would love to get a second approval to this decision. And the CI issue seems to be the algorithms lib itself, so there is a chance its not an issue we can solve but rather something Github actions should. |
@mustiikhalil How about #8151 for the C++ CI failure? |
@kou unfortunately I'm not responsible for cpp, however I already tagged someone who is! hopefully this would be resolved asap |
@abandy can you rebase so we can get this PR merged |
@abandy all good, should i merged? or do you have any extra changes? |
@mustiikhalil please merge when you get a chance. Thank you! |
### Rationale for this change flatbuffers v24.3.7 includes google/flatbuffers#8134 . The current master has a build error: https://github.com/apache/arrow/actions/runs/11357784776/job/31591213976?pr=44431#step:5:1114 ```text [51/77] Compiling Arrow ArrowType.swift /arrow/swift/Arrow/Sources/Arrow/File_generated.swift:107:206: error: value of type 'Table' has no member 'postion' public var schema: org_apache_arrow_flatbuf_Schema? { let o = _accessor.offset(VTOFFSET.schema.v); return o == 0 ? nil : org_apache_arrow_flatbuf_Schema(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) } ~~~~~~~~~ ^~~~~~~ ``` ### What changes are included in this PR? Use v24.3.7 instead of master. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: #44432 Authored-by: Sutou Kouhei <kou@clear-code.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
This change is for issue #8133. It adds allowReadingUnalignedBuffers to the ByteBuffer init methods that accept the buffers data as an input.