-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
GH-32832: [Go] support building with tinygo #35723
Conversation
|
@zeroshade we're still testing this on our end, but it does work. I'm curious what your thoughts are. |
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.
In general this LGTM, just a few nit picks
go/arrow/array/string.go
Outdated
beg := a.array.data.offset | ||
end := beg + a.array.data.length | ||
data := a.values[a.offsets[beg]:a.offsets[end]] | ||
|
||
s := (*reflect.SliceHeader)(unsafe.Pointer(&ret)) | ||
s.Data = (*reflect.StringHeader)(unsafe.Pointer(&data)).Data | ||
s.Len = len(data) | ||
s.Cap = len(data) | ||
return | ||
return []byte(data) |
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.
same comment as above
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.
This still needs to get updated to no longer be copying the string (like the equivalent function for (*String)
5f41f87
to
66cacfb
Compare
@zeroshade thanks for the review, I think I addressed everything. What are you thoughts on building with tinygo in CI? The CI setup on this repo seems complex so I'm not sure what that would entail, but it would be nice to avoid new code being introduced that does not build. |
go/internal/types/extension_types.go
Outdated
"github.com/goccy/go-json" | ||
"github.com/apache/arrow/go/v13/internal/json" | ||
|
||
"github.com/apache/arrow/go/v13/arrow" | ||
"github.com/apache/arrow/go/v13/arrow/array" |
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.
the failed dev scripts test is because when we run the auto update scripts this gets updated as a separate block. Can you remove the empty space below the updated import and just group all the arrow imports together (alphabetically)?
i.e.:
...
"strings"
"github.com/apache/arrow/go/v13/arrow"
"github.com/apache/arrow/go/v13/arrow/array"
"github.com/apache/arrow/go/v13/internal/json"
"github.com/google/uuid"
"golang.org/x/xerrors"
thanks.
@chriscasola Do you think it's sufficient to just have a single x86-64/linux CI run with tinygo? Or do you think we'd need for arm and other cases too? |
I think a single architecture is fine. |
remove parquet import in hashing cleanup type check fix uintptr usage exclude goccy/go-json for tinygo builds last uintptr problem
d066919
to
b2fb989
Compare
name: TinyGo | ||
runs-on: ubuntu-latest | ||
if: ${{ !contains(github.event.pull_request.title, 'WIP') }} | ||
env: | ||
TINYGO_VERSION: 0.27.0 |
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.
i would suggest adding an image to the docker-compose.yml and a dockerfile to ci/docker/
which is an image with tinygo installed and then use archery docker run
like other examples.
cd ~ | ||
pushd /src | ||
tinygo build -tags noasm -o ~/example_tinygo arrow/_examples/helloworld/main.go | ||
popd | ||
|
||
./example_tinygo |
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.
any reason to not just have it run the unit tests?
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.
Unfortunately tinygo can't compile/run unit tests right now. At least it can't handle the ones in this project. See this issue.
|
||
cd ~ | ||
pushd /src | ||
tinygo build -tags noasm -o ~/example_tinygo arrow/_examples/helloworld/main.go |
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.
should we update all of the go build constraints for noasm
to be noasm || tinygo
or whatever the equivalent is?
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.
@zeroshade I attempted to do this, but it seems like package outside arrow might also have a noasm
flag. Even after adding the tinygo
condition everywhere there was a noasm
condition, I still couldn't build with out the noasm
tag. Are you okay omitting this for now?
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.
yea that's fine for now. We should probably figure out which package it is that has the noasm
condition etc.
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.
Unfortunately tinygo is just erroring without enough context to find the file at fault. I'm not sure if there's a way to find it with the standard go toolchain.
@zeroshade this is ready for review and has been fully tested to work with tinygo in our app's environment. |
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.
Just one request: can you add to the go/arrow/doc.go
file's package comment documentation the info about building with tinygo like needing the noasm
tag, etc.?
Otherwise this looks good to me.
Benchmark runs are scheduled for baseline = b642707 and contender = 245404e. 245404e is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Cool to see this got in. I wonder if anybody looked into what it would take to get the Parquet packages working as well. I may give it another try at some point. |
I believe the current blocker on the parquet packages is that something in the Thrift dependency is not compatible with tinygo |
Rationale for this change
To support compiling with tinygo which enables use of arrow in environments where binary size is important, like web assembly.
What changes are included in this PR?
Using an internal JSON package that uses
goccy/go-json
for regular builds as it does currently, but uses the nativeencoding/json
for tinygo builds. This is necessary because go-json has a lot of code that is incompatible with tinygo.Remove dependency on
parquet
package from non-parquet code since it is also incompatible with tinygo.Other minor tweaks for compatibility with tinygo.
Are these changes tested?
Should we add a build step that compiles the example with tinygo?
Are there any user-facing changes?
None.