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

Don't go to arrow IPC and back on C++ -> Rust, use C FFI instead #4255

Closed
Wumpf opened this issue Nov 17, 2023 · 0 comments · Fixed by #4273
Closed

Don't go to arrow IPC and back on C++ -> Rust, use C FFI instead #4255

Wumpf opened this issue Nov 17, 2023 · 0 comments · Fixed by #4273
Assignees
Labels
🌊 C++ API C/C++ API specific 📉 performance Optimization, memory use, etc
Milestone

Comments

@Wumpf
Copy link
Member

Wumpf commented Nov 17, 2023

We're loosing a lot of performance because of an extra IPC roundtrip when going from C++ through C to Rust.

Let's use the Arrow C ffi instead!
https://arrow.apache.org/docs/format/CDataInterface.html#structure-definitions

Further improvement from there is to not send the schema every time, but that's an extra step

@Wumpf Wumpf added 📉 performance Optimization, memory use, etc 🌊 C++ API C/C++ API specific labels Nov 17, 2023
@Wumpf Wumpf added this to the 0.11 C++ polish milestone Nov 17, 2023
@Wumpf Wumpf self-assigned this Nov 17, 2023
Wumpf added a commit that referenced this issue Nov 21, 2023
…of arrow IPC (#4273)

### What

* Fixes #4255 
* Depends on  #4282

So far we've been using the arrow IPC format to hand data from C++ to
C/Rust. It turned out that this incurred a major performance cost on our
api. Instead, using the C FFI interface (which still isn't exactly free)
gives us a major performance boost in all of today's logging benchmarks:

large point cloud: `0.58s -> 0.15s`
many points: `17.10 -> 7.52s`
large images: `2.90s -> 0.57s`
_Execute times without prepare, single sample on before, median of three
on after, all ran in a single process_

for comparison, numbers on main for Rust:

large point clouds: `0.82s`
many points: `3.87s`
large images: `1.00s`
_Execute times without prepare via Puffin, single sample, all ran in a
single process. As always these comparisons are very tricky. Also
there's lots of noise!_

There's still some significant discrepancy on `many points`. One likely
source of this is repeated schema transfer. Need to do some more
profiling before continuing.


This PR also simplifies the serialization pipeline a little bit by
removing `SerializedComponentBatch`, replacing it in favor of the
existing `rerun::DataCell` in a few places. Left a comment in the code
on the next steps towards evolving it towards an interface that's more
similar to how things work in Rust.


### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/4273) (if
applicable)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG

- [PR Build Summary](https://build.rerun.io/pr/4273)
- [Docs
preview](https://rerun.io/preview/cb476d8f4fc9025855a0dd58c12c953c4741cf77/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/cb476d8f4fc9025855a0dd58c12c953c4741cf77/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌊 C++ API C/C++ API specific 📉 performance Optimization, memory use, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant