-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
stabilize worker_total_busy_duration #6899
Open
Owen-CH-Leung
wants to merge
16
commits into
tokio-rs:master
Choose a base branch
from
Owen-CH-Leung:stabilize_worker_total_busy_duration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+319
−249
Open
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8f1fcb4
stabilize worker total busy duration, bring WorkerMetrics, MetricsBat…
Owen-CH-Leung 9b47cf9
Fix rustfmt ci job
Owen-CH-Leung e2f4f33
Fix various failing CI jobs by adding cfg(target_has_atomic = "64") t…
Owen-CH-Leung b6974ba
Use cfg_64bit_metrics instead
Owen-CH-Leung 86f019f
Fix formatting and remove brackets
Owen-CH-Leung 64f626d
Creat Mock Histogram, HistogramBatch and HistogramBuilder. Revert cha…
Owen-CH-Leung 489003c
Hide queue_depth and thread_id behind unstable flag
Owen-CH-Leung 8a134a2
Mark most fields of WorkerMetrics as unstable, except for busy_durati…
Owen-CH-Leung 4bc00cf
Merge branch 'master' into stabilize_worker_total_busy_duration
Owen-CH-Leung 7eb6b97
Remove allow dead_code, merge master & fix spellcheck
Owen-CH-Leung 7239af5
Merge branch 'master' into stabilize_worker_total_busy_duration
Owen-CH-Leung 57f6b9b
Add back worker_total_busy_duration test
Owen-CH-Leung c8b2c7d
Remove mock metricBatch, split MetricBatch implementation into stable…
Owen-CH-Leung d7333cf
Merge branch 'master' into stabilize_worker_total_busy_duration
Owen-CH-Leung 14543de
Gate code based on cfg_unstable_metrics and cfg_not_unstable_metrics
Owen-CH-Leung 245d75c
Merge branch 'master' into stabilize_worker_total_busy_duration
Owen-CH-Leung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 this change required for the mean time stabilization or just a coincidental change?
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.
I believe this change is required.
At master we have implemented another
struct WorkerMetrics
attokio/src/runtime/metrics/mock.rs
which didn't usestruct Histogram
defined attokio/src/runtime/metrics/histogram.rs
.In order to stabilize the API, I have to removed this mock WorkerMetrics and instead point to the "real"
WorkerMetrics
attokio/src/runtime/metrics/worker.rs
The "real"
WorkerMetrics
has a fieldpoll_count_histogram
which isOption<Histogram>
, and thus will attempt to parsetokio/src/runtime/metrics/histogram.rs
. From there, you can see Histogram and HistogramBuilder both refers toHistogramScale
which is hidden insidetokio_unstable
. I think this wouldn't compile.(I might be wrong though so feel free to correct me)
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.
I need to read through this PR in more detail so bare with me, but we shouldn't be making this stable and public if it isn't actually needed to to stabilize
worker_total_busy_duration
(and I'm mostly sure that it isn't).In general, all the
#[allow(dead_code)]
that are required for this chnage give me the impression that we're exposing something that is only really used intokio_unstable
and so we should find a way to expose it only unstabletokio_unstable
.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.
Thanks for your comment!
I think the core issue here is that by exposing
worker_total_busy_duration
, we are also exposing the "real"WorkerMetrics
attokio/src/runtime/metrics/worker.rs
, which in turn will attempt to parseHistogramScale
.Currently at master branch, when no
tokio_unstable
flag is passed in, theWorkerMetrics
attokio/src/runtime/metrics/mock.rs
will be parsed (which is just an empty struct). And if the flag is passed in, theWorkerMetrics
attokio/src/runtime/metrics/worker.rs
will be parsedhttps://github.com/tokio-rs/tokio/blob/master/tokio/src/runtime/metrics/mod.rs#L27-L40
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.
it's not actually public, it's still behind config_unstable. (Just verified via the autogenerated docs)
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.
Yeah becoz
HistogramScale
is still behindcfg_unstable_metrics
:https://github.com/tokio-rs/tokio/pull/6899/files#diff-15ebfca6124144b3cffd9845fa3ce5596c342ce94d84dd406ee84f856db4c66cR23-R25
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.
OK, now I believe I understand.
I would suggest that instead of compiling with the entire worker metrics in order to access only the
busy_duration_total
field, we should gate all the fields that we won't be using oncfg_unstable_metrics
. Otherwise users will still be paying the price for metrics which they don't have access to - and that is something that we would really like to avoid.Have a look at the runtime Builder for an example of how we have fields and implementations that touch them gated on a cfg flag:
tokio/tokio/src/runtime/builder.rs
Lines 125 to 126 in 512e9de
As a general rule, if you need
#[allow(dead_code)]
then there is probably something that should be gated on a cfg flag instead.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.
Thanks @hds . I've reverted changes to
histogram.rs
. Also the realHistogram
,HistogramBuilder
andHistogramBatch
are gated behind unstable flag now, and instead I've created a mocked version of these for compilation.For
WorkerMetrics
, as we target to stabilize more metrics, I'd suggest exposing all fields instead of stabilizing onlybusy_duration_total
and putting other fields behind unstable.Let me know what you think
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.
@Owen-CH-Leung the problem with stabilizing all of
WorkerMetrics
is that whentokio_unstable
is not enabled, the runtime will pay the price for all those metrics, but there will be no way to access them. For this reason I think that it would be better to only stabilize what we're exposing.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.
Thanks @hds . I've made changes to hide most of the fields of
WorkerMetrics
behind unstable flag, except forbusy_duration_total
,queue_depth
andthread_id
. The latter 2 fields are needed in order forset_queue_depth
andset_thread_id
to work properly.I've also enriched the mock
MetricsBatch
to have minimal implementation ofbatch::MetricsBatch
so that theworker_total_busy_duration
API can function properly under stable buildLet me know your thoughts!