Skip to content

Use rerun::Collection almost everywhere we'd use std::vector before#4247

Merged
Wumpf merged 24 commits intomainfrom
andreas/cpp/rerun-collection-fields
Nov 17, 2023
Merged

Use rerun::Collection almost everywhere we'd use std::vector before#4247
Wumpf merged 24 commits intomainfrom
andreas/cpp/rerun-collection-fields

Conversation

@Wumpf
Copy link
Copy Markdown
Member

@Wumpf Wumpf commented Nov 16, 2023

What

... and various improvements to rerun::Collection in general to be up for the task. Added copy assignment/construction, added vector conversion, removed serialization method (handled at callsites now)

Also, I overhauled and generalized our builtin rerun::CollectionAdapters further. They give now more exact guarantees on when they copy & move data.
To support the considerably increased significance and abilitites of this data structure I added a lot more tests, in particular checking on the aforementioned move/copy guarantees.

Huge thanks to @AnkeAnke for pointing out to me how we can support std compatible contains generically in a trivial way (rerun::type_traits::value_type_t!). This made it possible that this PR requires almost no changes in user/test/example code since most types just snap in the same as before.

As expected this change improves the performance on the image logging benchmark (which logs 4 16k rgba images).
Timing on M1 Max went from ~2.9s to ~2.4s and on the AMD windows box I use from ~3.0s to ~2.5s
(did a bunch of runs, values are excluding prepare and process setup, AMD fluctuates a lot)

DRAFT until I'm sure this works on more compilers.

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 enhancement New feature or request sdk-cpp C/C++ API specific include in changelog labels Nov 16, 2023
@Wumpf Wumpf marked this pull request as ready for review November 16, 2023 14:47
and namespace some macros while we're touching that
@emilk emilk self-requested a review November 16, 2023 18:08
Copy link
Copy Markdown
Member

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Whoa, that's a lot of complex C++ 😓
Looks good though!

namespace archetypes {

#ifdef EDIT_EXTENSION
#if 0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

#if 0 looks wrong, though I know it is right. Perhaps add a comment, or standardize how we do this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmmm. Need to do a pass over these. Slowly switched to the simpler if 0 variant because the other thing got implemented incorrectly too often

return data();
}

/// TODO(andreas): Return proper iterator
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why? A raw pointer has the benefit of being simple and much, much faster in debug builds

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct, but it will break down soon once we have strides

@Wumpf Wumpf merged commit 907d006 into main Nov 17, 2023
@Wumpf Wumpf deleted the andreas/cpp/rerun-collection-fields branch November 17, 2023 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request include in changelog sdk-cpp C/C++ API specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants