-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Supports to strip leading zero on print_log2_hist function #1226
Conversation
[buildbot, ok to test] |
tools/biolatency.py
Outdated
@@ -36,6 +37,8 @@ | |||
help="millisecond histogram") | |||
parser.add_argument("-D", "--disks", action="store_true", | |||
help="print a histogram per disk device") | |||
parser.add_argument("-s", "--strip", action="store_true", | |||
help="strip leading zero on output") |
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 don't think this makes a lot of sense as an additional option for any tool. This is a decision the tool author should make. And in fact, I don't see why we wouldn't want this behavior by default -- so probably in most cases, the choice should be to strip leading zeros. @brendangregg
Yes, I think it should be up to the tool author. Some tools may want this as the default, some not. Adding an -s option should be an exception, only if really needed, and not on everything as it would clutter up their usage. This was discussed briefly once before on #1109, as I'd suggested dropping the zeros by default, but someone pointed out that it can be a good visual clue. Maybe... if the metric is latency, the zeros could be kept for that visual clue: as higher is bad. But for other metrics, like size, I'm not sure printing zeros matter. Hence, again, the tool author can pick the default that makes sense. |
I really agree that the default value is up to the tool author. Keeping zeros is currently the default option on both Actually, I'm not a initial tool author of Is there anything I need to correct or impove before |
Yes - I think Brendan (the author of these tools) and I are saying that we don't need the |
Thanks to reply. Because I'm not good at English, I'm confused something. As you and Brendan discussed the default value, isn't it necessary to add If we don't need |
We are saying that the tool should decide whether to use the new stripping behavior or not. It should not be exposed to the user as a Also, why close the PR? You can push a new commit that makes the changes you want and the PR will be updated automatically. |
Thanks to reply again. It's hard to understand contribution processes because I'm not familiar with code contribution. But I'm being able to get a great experience in this time. Also, I'm learning how to communicate with contributors and how can my code be applied on open source project. As a result, I'm really sorry to bother you, but I'm curious about something. We already decided that |
What makes this PR "about #1109"? You can edit the description and the commits to whatever you want. I think at this point we should make funclatency and biolatency strip zeros, and have the library function as is. No need for |
Due to your advices, I was able to understand what you and he said. And I realized that the tool author should decide to strip leading zeros or not. So I removed the python code and fixed the description for
I really hope that I understood properly what you mean. Could you give me any other advice or comment? |
Your latest patchset doesn't do this. You added the |
Because of my English skill, I completely misunderstood something. I'm so sorry. I think that Eng comprehension is harder than code comprehension T_T..... |
@thnam91 It's not your English, it's actually me who misunderstood Brendan's original comment. That's what happens when you triage pull requests while jetlagged. What Brendan was saying is that the latency-related tools should not strip the leading zeros from the histogram. So the library change (in table.py) is fine, but we should revert to the version that doesn't change funclatency and biolatency -- they should not strip zeros. Sorry for all the back and forth, it really is my fault. |
Thank you so much :D. Finally I understood this issue clearly. I hope that this PR will be my final pull request. |
tools/biolatency.py
Outdated
@@ -131,7 +132,7 @@ | |||
if args.timestamp: | |||
print("%-8s\n" % strftime("%H:%M:%S"), end="") | |||
|
|||
dist.print_log2_hist(label, "disk") | |||
dist.print_log2_hist(label, "disk", strip_leading_zero=None) |
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 don't think this is needed because None
is the default value.
tools/funclatency.py
Outdated
@@ -237,9 +238,9 @@ def print_section(key): | |||
|
|||
if need_key: | |||
dist.print_log2_hist(label, "Function", section_print_fn=print_section, | |||
bucket_fn=lambda k: (k.ip, k.pid)) | |||
bucket_fn=lambda k: (k.ip, k.pid), strip_leading_zero=None) |
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.
Same here and below.
tools/biolatency.py
Outdated
@@ -10,6 +10,7 @@ | |||
# Licensed under the Apache License, Version 2.0 (the "License") | |||
# | |||
# 20-Sep-2015 Brendan Gregg Created this. | |||
# 28-Jun-2017 Taekho Nam Not stripped leading zero. |
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'm sorry, but there are no changes in biolatency and funclatency any more, so these comments also seem unnecessary.
You are right. It is not unnecessary any more. Thank you. I missed it. |
Thanks, merged. |
I found #1109 issue about
print_log2_hist
function and read its comments.I implemented a option that doesn't show the leading zeros.
I added argument
strip_leading_zero
toprint_log2_hist
function and its default value isNone
.And I applied it to
funclatency.py
,funclatency_example.txt
,biolatency.py
, andbiolatency_example.txt
.Instead of this:
Print this using -s option:
And Instead of this:
Print this using -s option:
Please review my code and comments about it. :D
If it can cause any other problems, please let me know how can I fix it.
Thank you.