Skip to content
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

feat: expose engine FFI API to a Dart consumer (prototype 2) #850

Closed
wants to merge 1 commit into from

Conversation

bassosimone
Copy link
Member

@bassosimone bassosimone commented Aug 5, 2022

This diff is a variation of #849
where we use protobuf instead of a custom JSON message format
managed by us. Therefore, this diff allows us to evaluate which
is the cost of inventing a custom JSON data format.

At the FFI level, the most relevant change is that we are not
passing along UTF-8 strings anymore, rather we're now using
binary buffers. I spent some (but not too much) trying to see
whether we could actually avoid unnecessary copies. I could
do that for events but could not do that for messages. I think
it's fair enough since events are more frequent and we're not
exchanging super large messages anyway.

Also, the whole Dart codebase is a bit leaner because in the
meanwhile I leveled up a bit :^).

Reference issue ooni/probe#2197

This diff is a variation of #849
where we use protobuf instead of a custom JSON message format
managed by us. Therefore, this diff allows us to evaluate which
is the cost of inventing a custom JSON data format.

At the FFI level, the most relevant change is that we are not
passing along UTF-8 strings anymore, rather we're now using
binary buffers. I spent some (but not too much) trying to see
whether we could actually avoid unnecessary copies. I could
do that for events but could not do that for messages. I think
it's fair enough since events are more frequent and we're not
exchanging super large messages anyway.

Also, the whole Dart codebase is a bit leaner because in the
meanwhile I leveled up a bit :^).
@bassosimone
Copy link
Member Author

(For the records, I also experimented with cgo.Handle, but I feel safer with a more forgiving solution such as the table that we're currently using, as opposed to an implementation that panics more frequently.)

bassosimone added a commit that referenced this pull request Aug 5, 2022
The general idea here is to avoid returning -1, having a more
uniform API, and allowing for sync calls.

It's a bit more work on both sides but it's more regular, so maybe
this change is for the greater good?

This will be a third pull request because it varies from
#850 mostly in
the way in which we interface at the FFI level.
@bassosimone bassosimone changed the title feat: expose engine FFI API to a Dart consumer feat: expose engine FFI API to a Dart consumer (prototype 2) Aug 5, 2022
@bassosimone
Copy link
Member Author

Closing in favour of #851.

@bassosimone bassosimone deleted the dart-protobuf branch August 17, 2022 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant