-
Notifications
You must be signed in to change notification settings - Fork 127
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
Bug 1916673 - Buffered API for memory/timing distributions #2948
Conversation
Usage of it WIP: https://phabricator.services.mozilla.com/D221017 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the work here.
If I understand this pull request correctly, it only adds a buffered API to MemoryDistribution
and TimingDistribution
.
In https://phabricator.services.mozilla.com/D220062 I want to add 4 new metrics:
- http3_udp_datagram_segment_size_sent
- http3_udp_datagram_segment_size_received
- http3_udp_datagram_size_received
- http3_udp_datagram_num_segments_received
(1), (2) and (3) I can model with a MemoryDistribution
. (4) on the other hand counts the number of segments received, where values range between 1
and 128
.
Here is metrics definition draft from the above Phabricator patch.
http3_udp_datagram_num_segments_received:
type: custom_distribution
unit: integer
range_min: 0
# Maximum number of UDP segments per datagram.
#
# See e.g. Linux https://github.com/torvalds/linux/blob/20371ba120635d9ab7fc7670497105af8f33eb08/include/linux/udp.h#L111.
range_max: 128
bucket_count: 100
histogram_type: exponential
description: >
HTTP3 UDP number of segments per datagram received.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1906853
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1906853
data_sensitivity:
- technical
notification_emails:
- necko@mozilla.com
- minden@mozilla.com
expires: never
I assume this is best modeled by the CustomDistribution
. Would a buffered API for CustomDistribution
be included in this patch?
(Note, in case you want to ship a buffered API for one distribution only for now, I assume I could as well model (1), (2) and (3) with a CustomDistribution
instead of a MemoryDistribution
.)
0886642
to
0e29b7e
Compare
71713ac
to
7ea4e2b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As much as I'd like this to be a r+with_followups, I think we need to decide about the FFI and Kotlin interfaces for certain before we ship this, as subsequent changes will be breaking.
/** | ||
* Record data from the histogram buffer into the associated metric. | ||
* | ||
* This instance must not be used after `commit()` is called. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to prevent it from being used after commit()
? I think the Java-like pattern is tothrow new IllegalStateException("Use after commit");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm.
Then we need to track that state.
I'm considering to remove the Kotlin part. The first user is Rust only.
class LocalTimingDistribution( | ||
val metric: TimingDistributionMetricType, | ||
val inner: FfiLocalTimingDistribution, | ||
) : AutoCloseable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want protected fun finalize() { /* TODO: bug 1691073 */ report_some_error(); ffi_abandon_buffer(this);
or whatever to help report misuse and prevent memory leaks.
} | ||
|
||
/// Record data from the histogram buffer into this metric. | ||
pub fn ffi_commit_buffer(&self, buffer: Arc<FfiLocalTimingDistribution>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we clear the buffer to stop folks accidentally committing the same buffer twice? Or is that prevented somewhere/somehow else? For non-FFI we rely on the "called at most once" behaviour of drop, but I don't see us accounting for the lack of that guarantee (or testing that case) here.
7ea4e2b
to
8175fc8
Compare
Ok, I split Kotlin out so we can tackle that separately. |
8175fc8
to
3affca9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+wc
3affca9
to
4d58644
Compare
This is the implementation for what's being designed in bug-1915388
docswill be done separately (bug-1917809)