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

Further improve C++ logging for many individual log calls by introducing a component type registry #4296

Merged
merged 9 commits into from Nov 22, 2023

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Nov 21, 2023

What

As expected, not doing the C++ datatype -> C FFI schema -> Rust datatype roundtrip for each log call helps perf quite a bit, especially when we do a lot of smaller log calls.

The registry a single RwLock protected Vec (we never deregister) which is exposed via a single c entry point.
On the C++ side we use the local static variable mechanism for threadsafe lazy registration (slight codegen adjustment).
Indicator components had some special handling before and were refactored to fit in this system - in the process I made their arrow array shared across all instantiations, further cutting down on per-log work.


Benchmark results:

  • large point cloud: 0.15s -> 0.14s
  • many points: 7.52s -> 4.52s
  • large images: 0.57s -> 0.51s

Old values from previous PR. New values are median over three runs, single executable run (this makes more and more of a difference with all these registries!), timings without prepare step, same M1 macbook.

A quick look over the profiler for running log_benchmark points3d_many_individual in isolation tells us that of the actual benchmark running time we spend..

  • 35% of the the time in rr_recording_stream_log (of which in turn 20%, so 7% overall, is still arrow FFI translation of the array!!)
  • 30% in the various to_data_cell methods
  • 10% in exporting arrow arrays to C FFI
  • 6% in setting the time
  • the rest in various allocations along the way

(taken via Instruments on my Mac)
image


Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested demo.rerun.io (if applicable)
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG

@Wumpf Wumpf added 📉 performance Optimization, memory use, etc 🌊 C++ API C or C++ logging API include in changelog labels Nov 21, 2023
@Wumpf Wumpf changed the title Further improve C++ logging (mostly) for many individual log calls by introducing a component type registry Further improve C++ logging for many individual log calls by introducing a component type registry Nov 21, 2023
@jleibs jleibs self-requested a review November 21, 2023 18:16
Copy link
Member

@jleibs jleibs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Nice improvement.

crates/rerun_c/src/component_type_registry.rs Show resolved Hide resolved
@Wumpf Wumpf merged commit 562b919 into main Nov 22, 2023
42 checks passed
@Wumpf Wumpf deleted the andreas/cpp/more-logging-perf branch November 22, 2023 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌊 C++ API C or C++ logging API include in changelog 📉 performance Optimization, memory use, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Speed up C++ logging for many individual log calls
2 participants