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

Add a test to check issue #1366 and use Debug mode #1368

Closed
wants to merge 8 commits into from
Closed

Conversation

ibc
Copy link
Member

@ibc ibc commented Apr 8, 2024

Temporal PR just to test #1366 in different machines.

CC @jmillan @shaymagsumov

Results using absl::btree_set

SECTION("absl::btree_set")
{
	absl::btree_set<uint16_t, RTC::SeqManager<uint16_t>::SeqLowerThan> recoveredList;

	recoveredList.insert(10000);
	recoveredList.insert(40000);
	recoveredList.insert(60000);

	REQUIRE(recoveredList.size() == 3);
}

Here we can see that, when compiled in debug mode, mediasoup-worker CI fail in all OS and archs and compilers (in all but Windows) due to the transitivity violation, i.e. comp(a,b) && comp(b,c) -> comp(a,c).

All CI fail: https://github.com/versatica/mediasoup/actions/runs/8612477995/

Results using std::set

SECTION("std::set")
{
	std::set<uint16_t, RTC::SeqManager<uint16_t>::SeqLowerThan> recoveredList;

	recoveredList.insert(10000);
	recoveredList.insert(40000);
	recoveredList.insert(60000);

	REQUIRE(recoveredList.size() == 3);
}

Despite C++ containers are supposed to also require transitivity (https://en.cppreference.com/w/cpp/container/set, https://en.cppreference.com/w/cpp/named_req/Compare), the same transitivity violation doesn't affect standard C++ STD containers when compiled in debug mode. Why? No idea, but it doesn't fail in any OS/arch/compiler.

All CI passes: https://github.com/versatica/mediasoup/actions/runs/8612301409/

Conclusion

  • Ok, we use abseil containers to gain more performance.
  • But they are hell.
  • We SHOULD be able to run mediasoup-worker in debug mode without crashes. Otherwise, what do we want the debug mode for? To detect problems? How are we gonna detect problems if we are literally introducing problems when we run mediasoup-worker in debug mode due to the required transitivity in abseil containers? It doesn't make any sense.
  • So IMHO we MUST NOT use abseil conatiners with compare functions that do not honor the transitivity requirement, and this is the task that must be done.

@jmillan
Copy link
Member

jmillan commented Apr 9, 2024

I agree, let's not use abseil containers when the comparison function is needed.

@ibc ibc closed this Apr 9, 2024
@ibc ibc deleted the check-issue-1366 branch April 9, 2024 08:46
@ibc
Copy link
Member Author

ibc commented Apr 9, 2024

So I'm closing this temp PR and will make one with the agreed changes.

ibc added a commit that referenced this pull request Apr 9, 2024
Fixes #1366

### Details

- As demonstrated in temporal PR #1368, standard C++ STD containers do not throw (even in debug mode) when using `Compare` functions in maps/sets that do not honor transitivity, i.e. `comp(a,b) && comp(b,c) -> comp(a,c)`.
- So let's not use abseil containers in those cases.

### Bonus tracks

- Dupicate CI actions in debug mode.
- Make mediasoup Rust building honor `MEDIASOUP_BUILDTYPE` env variable if given.
- Fix an amazing bug in `AudioLevelObserver.cpp` which failed to compile because it uses a `absl::btree_multimap` without including the `absl/container/btree_map.h` header (it didn't fail before due to some absl header included by yet anothe included file, etc).
@ibc
Copy link
Member Author

ibc commented Apr 9, 2024

PR done: #1369

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants