Skip to content

Conversation

@Tornhoof
Copy link
Contributor

@Tornhoof Tornhoof commented Jul 9, 2024

Proposed Changes

After ReadOnlyBasicProperties was changed to a class, we can use IReadOnlyBasicProperties without boxing problems to simplify unit testing.

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

  • Bug fix (non-breaking change which fixes issue Testability of HandleBasicDeliver in IAsyncBasicConsumer #1630)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause an observable behavior change in existing systems)
  • Documentation improvements (corrections, new content, etc)
  • Cosmetic change (whitespace, formatting, etc)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask on the
mailing list. We're here to help! This is simply a reminder of what we are
going to look for before merging your code.

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • All tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in related repositories

(not all tests pass on my system, some fail for networking issues).

Further Comments

This is mostly an automated change via ReSharper to replace the individual ReadOnlyBasicProperties with IReadOnlyBasicProperties

@Tornhoof
Copy link
Contributor Author

Tornhoof commented Jul 9, 2024

The test failures of rabbitmq-dotnet-client / call-build-test / integration-ubuntu appear to be a fluke, the windows version of the tests were successful.

michaelklishin
michaelklishin previously approved these changes Jul 9, 2024
Copy link
Contributor

@michaelklishin michaelklishin left a comment

Choose a reason for hiding this comment

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

I cannot think of a reason not to use the interface in the API (and the previous API version hasn't shipped in 7.0 GA yet, I think).

@Tornhoof
Copy link
Contributor Author

Tornhoof commented Jul 9, 2024

Apprarently we missed the type EmptyBasicProperty while converting ReadOnlyBasicProperties to class, the last commit fixes that.

@lukebakken lukebakken self-assigned this Jul 9, 2024
@lukebakken lukebakken added this to the 7.0.0 milestone Jul 9, 2024
Copy link
Collaborator

@lukebakken lukebakken left a comment

Choose a reason for hiding this comment

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

Thanks!

@lukebakken lukebakken merged commit 946b4c2 into rabbitmq:main Jul 9, 2024
@Tornhoof Tornhoof deleted the IReadOnlyBasicProperties branch July 9, 2024 13:26
@bollhals
Copy link
Contributor

bollhals commented Jul 9, 2024

I cannot think of a reason not to use the interface in the API (and the previous API version hasn't shipped in 7.0 GA yet, I think).

Not my decision, but I wouldn't have used the interface here. Why?

  • The source of it the library, so we always know which type it is, and there's unlikely ever going to be more than one. So why hide it when it's always going to be the one.
  • Interface dispatch is more expensive performance wise than classes. (e.g. blocks inlining)
  • The ReadOnlyBasicProperties is basically a data object, it doesn't contain logic that would give big benefits in mocking it away.

I do see the problem raised in #1630 , but that could've been solved with the ReadOnlyBasicProperties(IBasicProperties from) as suggested as well in the issue.

@Tornhoof
Copy link
Contributor Author

Tornhoof commented Jul 9, 2024

The source of it the library, so we always know which type it is, and there's unlikely ever going to be more than one. So why hide it when it's always going to be the one.

There is already a second one, the Empty one, but in general I agree.

Interface dispatch is more expensive performance wise than classes. (e.g. blocks inlining)

This is only really true in Tier 0, as soon as Guarded Devirtualization and PGO hits in Tier 1, that problem mostly disappears. It will fast-path even for interfaces and remove the virtual dispatch for these
see e.g.
https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/jit/GuardedDevirtualization.md#interface-calls-the-two-class-case
and
https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-6/

Performance wise, the difference is very very small with GDV and PGO, see https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-8/ (the part with the list pgo for example, search for "we could possibly reduce overheads").

The ReadOnlyBasicProperties is basically a data object, it doesn't contain logic that would give big benefits in mocking it away.

This is true, without any reservation from my side.

@bollhals
Copy link
Contributor

bollhals commented Jul 9, 2024

The source of it the library, so we always know which type it is, and there's unlikely ever going to be more than one. So why hide it when it's always going to be the one.

There is already a second one, the Empty one, but in general I agree.

Not for the relevant path you modified, which is the receiving of messages. The Empty one is to send messages. (Which is also why the ReadOnly variant does not implement all necessary interfaces to use it when sending messages.)

Interface dispatch is more expensive performance wise than classes. (e.g. blocks inlining)

This is only really true in Tier 0, as soon as Guarded Devirtualization and PGO hits in Tier 1, that problem mostly disappears. It will fast-path even for interfaces and remove the virtual dispatch for these see e.g. https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/jit/GuardedDevirtualization.md#interface-calls-the-two-class-case and https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-6/

Performance wise, the difference is very very small with GDV and PGO, see https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-8/ (the part with the list pgo for example, search for "we could possibly reduce overheads").

It surely could be improved by it, but to be sure we'd have to measure a typical usecase.

In case you didn't get notified, I'll ping you about this @lukebakken

@lukebakken
Copy link
Collaborator

I've read this discussion, and it still seems fine to accept this PR.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants