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

Expose Quality of Service settings (Priority, Congestion Control, Express) the Sample was published with #730

Merged
merged 14 commits into from
Feb 23, 2024

Conversation

DenisBiryukov91
Copy link
Contributor

Expose Quality of Service settings (Priority, Congestion Control, Express flag) the sample was sent with (closes #694)

commons/zenoh-protocol/src/core/mod.rs Outdated Show resolved Hide resolved
commons/zenoh-protocol/src/network/mod.rs Outdated Show resolved Hide resolved
zenoh/tests/qos.rs Show resolved Hide resolved
zenoh/tests/qos.rs Outdated Show resolved Hide resolved
zenoh/tests/qos.rs Outdated Show resolved Hide resolved
zenoh/tests/qos.rs Outdated Show resolved Hide resolved
zenoh/tests/qos.rs Outdated Show resolved Hide resolved
zenoh/src/publication.rs Outdated Show resolved Hide resolved
zenoh/src/sample.rs Outdated Show resolved Hide resolved
zenoh/src/sample.rs Outdated Show resolved Hide resolved
@Mallets
Copy link
Member

Mallets commented Feb 14, 2024

It LGTM. However, given the recent discussion on Sample and SourceInfo I'd like to have the feedback also from @p-avital and @milyin .

@Mallets
Copy link
Member

Mallets commented Feb 15, 2024

Holding on in merging this PR since it will break the memory layout for zenoh-c and zenoh-cpp at least.
Sister PRs in zenoh-c and zenoh-cpp should be done pointing to this PR.

Copy link
Contributor

@p-avital p-avital left a comment

Choose a reason for hiding this comment

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

I think it might be time (and our last chance) to move Sample to accessors. Public fields make any new field an API break, and over-expose the layout.

Since this is already a breaking change, I'd advocate for taking the chance.

@@ -326,6 +329,8 @@ pub struct Sample {
pub kind: SampleKind,
/// The [`Timestamp`] of this Sample.
pub timestamp: Option<Timestamp>,
/// Quality of service settings this sample was sent with.
pub qos: QoS,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a huge fan of how Sample keeps on getting more public fields. Maybe we can use the API break to make it a bit more private?


/// Structure containing quality of service data
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq)]
pub struct QoS {
Copy link
Contributor

Choose a reason for hiding this comment

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

Using accessors, this could be a bitfield and occupy a single byte instead of 3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is the benefit of reducing 3 bytes to one on the system with word size >= 4 bytes ? As a separate struct it will still tend to occupy 4 bytes at least, no ?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's all about breakpoints and, to be fair, I think this layout just barely fits in Sample's current padding, but that also means the next field is guaranteed to make Sample fatter, which we've shown in previous layout improvements to be rather performances sensitive for us.

API-wise, it's tempting to have only public fields, but that turns any future change to the struct's fields an API break. Builder patterns are just as convenient and give us much more flexibility in the future, both for layout optimization and for field additions.

Copy link
Contributor

@p-avital p-avital left a comment

Choose a reason for hiding this comment

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

@Mallets @OlivierHecart can you consider my proposal above of moving Sample to an accessor pattern?

@Mallets
Copy link
Member

Mallets commented Feb 16, 2024

@Mallets @OlivierHecart can you consider my proposal above of moving Sample to an accessor pattern?

I think the proposal is in principle ok. The question is: should this PR be blocked by the proposal or should we merge it while we rework Sample entirely? I'm more in favour to get it in alongside the sister PRs so as to unblock some work being done in eclipse-uprotocol/up-transport-zenoh-rust#2.

@p-avital
Copy link
Contributor

I'm fine with either, but I'd like at least Qos to come out with the accessor+builder API from the get-go.

Keep in mind that if we unblock them with a first branch, they'll have to deal with the breaking change immediately after.

@Mallets
Copy link
Member

Mallets commented Feb 16, 2024

I'm fine with either, but I'd like at least Qos to come out with the accessor+builder API from the get-go.

Keep in mind that if we unblock them with a first branch, they'll have to deal with the breaking change immediately after.

I'm fine with your proposal for Rust.

Similar PRs are available in:

Copy link
Contributor

@p-avital p-avital left a comment

Choose a reason for hiding this comment

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

Since we've agreed that privatizing Sample's fields can come in the next PR, this is now fine :)

@milyin milyin added the enhancement Existing things could work better label Feb 22, 2024
@milyin milyin merged commit 0440148 into eclipse-zenoh:main Feb 23, 2024
7 of 8 checks passed
@DenisBiryukov91 DenisBiryukov91 deleted the feature/priority-in-sample branch March 13, 2024 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Existing things could work better
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Priority in samples
4 participants