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

Add new hist command #1922

Open
namhyung opened this issue May 9, 2024 · 2 comments
Open

Add new hist command #1922

namhyung opened this issue May 9, 2024 · 2 comments
Labels

Comments

@namhyung
Copy link
Owner

namhyung commented May 9, 2024

I'm thinking of histogram functionality in the hist sub-command or maybe in a (Python) script. It can show various histogram based on the trace data. This is just to think out loud and get some feedback.

For example, it would show a histogram of execution time of every function by default.

$ uftrace record ...

$ uftrace hist
# execution time  :      count | graph
    0 ns ~  10 ns :          2 |
   10 ns ~ 100 ns :        312 | ******
  100 ns ~   1 us :        249 | *****
    1 us ~  10 us :        158 | ***
   10 us ~ 100 us :        116 | **
  100 us ~   1 ms :          0 |
    1 ms ~  10 ms :         53 | *
   ...

It could show a histogram of execution time of single function if it's given (as an argument)

$ uftrace hist  myfunc
# execution time  :      count | graph
    0 ns ~  10 ns :          0 |
   10 ns ~ 100 ns :         13 | *******
  100 ns ~   1 us :          8 | ****
    1 us ~  10 us :          3 | *
   10 us ~ 100 us :         12 | ******
  100 us ~   1 ms :          0 |
    1 ms ~  10 ms :          5 | **
   ...

And it should be able to show histogram of value from argument or return value (if recorded) like

$ uftrace hist --val arg1 myfunc2
# value range    :        count | graph
     0   ~   1   :            0 |
     1   ~  10   :           13 | *******
    10   ~ 100   :            8 | ****
   100   ~   1 K :            3 | *
     1 K ~  10 K :           12 | ******
    10 K ~ 100 K :            0 |
   100 K ~   1 M :            5 | **
   ...

I think we need an option to specify the range of the values, step or type. It would have a histogram of string values for top-5 most frequent values. For example, it could trace open() function and show which file it accesses mostly (recorded in arg1).

$ uftrace hist --value arg1 --hist-policy range=no,type=string,entries=5,graph-first  open
#       graph |      count :   values
         **** |         21 :   "/dev/null"
          *** |         18 :   "/tmp/qeWor8"
           ** |         10 :   "/proc/self/maps"
            * |          7 :   "/home/user/myfile"
            * |          6 :   "/usr/bin/uftrace"

Thoughts?

@namhyung namhyung added the RFC label May 9, 2024
@paranlee
Copy link
Contributor

paranlee commented May 9, 2024

@namhyung Is there an option to adjust the execution time or value range of the histogram to be constant
or exponentially increasing?

$ uftrace record ...

$ uftrace hist
# execution time  :      count | graph
    0 ns ~  10 ns :          2 |
   10 ns ~ 100 ns :        312 | ******
  100 ns ~   1 us :        249 | *****
    1 us ~  10 us :        158 | ***
   10 us ~ 100 us :        116 | **
  100 us ~   1 ms :          0 |
    1 ms ~  10 ms :         53 | *
   ...

$ uftrace hist --val arg1 myfunc2
# value range    :        count | graph
     0   ~   1   :            0 |
     1   ~  10   :           13 | *******
    10   ~ 100   :            8 | ****
   100   ~   1 K :            3 | *
     1 K ~  10 K :           12 | ******
    10 K ~ 100 K :            0 |
   100 K ~   1 M :            5 | **
   ...

@namhyung
Copy link
Owner Author

Yes, it should have the fine controls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants