-
Notifications
You must be signed in to change notification settings - Fork 225
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
Consider using flatbuffers or protobufs to send things over the FFI (Bookmarks, in particular) #612
Comments
I feel like @bbangert will have some useful comments on this one... |
There's some serde options still.... |
We'd need this. That said, I don't think the process for compiling the protobuf to rust in a build.rs would be a problem, that sort of thing is an intended use case for build.rs. |
That’s certainly an option, but I don’t think it would make many of the things we currently have difficulty with any easier, and we do take advantage of sharing an address space/direct calls in several places, which would have to be worked around (doable, but awkward). I also don’t think it would reduce the overhead, which is mostly serialization and string encoding overhead in two directions (something like protobufs, hopefully, would combine encoding snd serialization, but thats true regardless of a socket being involved) |
@st3fan I had discussed something like that with @thomcc a week or so ago as well. And there's been some jokes about effectively doing local gRPC (I've been looking at gRPC for our service API's) as well. One thing that looks like a more ideal solution would be something like Djinni: Which was created by DropBox to ease their cross-platform toolkit in C++ to bind to Java/Objective-C. We would need one that is for Rust of course, so its not a perfect fit, but the solution feels like it fits in the problem-space here. And for bonus points, our ideal version would also tackle ownership issues. ;) Barring a resource investment into getting a solution like that for ourselves, I do think protobuf is a decent choice here. It's not without its pain points, but its probably one of the better supported tools out there. |
Protobuf seems like a good choice. Servo uses Bincode, but AFAIK there aren't any Rust or Swift libraries for it... CBOR looks interesting, too, and has implementations for Swift and Kotlin... |
Did some exploration this afternoon, here's what I found out:
I have a strong preference for Protobuffs version 2 over 3, simply because version 3 doesn't have optional types (you can somewhat emulate them) and instead serializes default values ("", 0, false etc.). Feel free to correct my statement as this is the result of two hours of exploration of the problem space :) Thoughts? |
One of the ideas that came out of the Tofino project was to run a kind of local "user-data agent" in a separate process, that would manage your places db and other things and provide access over a service API. This would have some interesting advantages (remove FFI ownership/safety issues, force asynchronicity, privilege isolation) as well as disadvantages (managing lifecycle of the agent process, round-trip efficiency) but could be worth exploring. But this would also feel like Conway's Law writ large.
Agreed; I feel like our wild-blue-sky-ambition would be wind up with something that looks like a cross between wasm-bindgen and Djinni, using annotations on rust code to generate strongly-typed and fast bindings for our target languages. Moving from JSON to protobuf seems like a good step in that general direction, so 👍 from my perspective. |
Closed by #626 |
Great work!! 👍 |
使用Cap'n proto、FlatBuffers等数据类型作为链接库的函数的参数,达到自动生成代码的,高性能、自动化解决方案。 设计想法 Using Cap'n proto, flatbuffers and other data types as the parameters of the function of the link library to achieve a high-performance and automatic solution for automatically generating code. |
I'm wary of using JSON to send anything big over the FFI for perf reasons. It's also extremely tedious to parse out the JSON on the Java/Swift side.
This would let us generate the code for all three. The downside is that it's less seamless in Rust than using Serde.
The text was updated successfully, but these errors were encountered: