> 2022年9月1日 00:54,Kent Overstreet <kent.overstreet@xxxxxxxxx> 写道: > > On Thu, Sep 01, 2022 at 12:00:17AM +0800, Coly Li wrote: >> >> >>> 2022年8月30日 00:53,Kent Overstreet <kent.overstreet@xxxxxxxxx> 写道: >>> >>> This patch converts bcache to the new generic time_stats code >>> lib/time_stats.c. The new code is from bcachefs, and has some changes >>> from the version in bcache: >>> >>> - we now use ktime_get_ns(), not local_clock(). When the code was >>> originally written multi processor systems that lacked synchronized >>> TSCs were still common, and so local_clock() was much cheaper than >>> sched_clock() (though not necessarily fully accurate, due to TSC >>> drift). ktime_get_ns() should be cheap enough on all common hardware >>> now, and more standard/correct. >>> >>> - time_stats are now exported in a single file in sysfs, which means we >>> can improve the statistics we keep track of without changing all >>> users. This also means we don't have to manually specify which units >>> (ms, us, ns) a given time_stats should be printed in; that's handled >>> dynamically. >>> >>> - There's a lazily-allocated percpu buffer, which now needs to be freed >>> with time_stats_exit(). >>> >>> Signed-off-by: Kent Overstreet <kent.overstreet@xxxxxxxxx> >>> Cc: Coly Li <colyli@xxxxxxx> >> >> Hi Kent, >> >> Overall I am OK with the change to bcache code. You may add >> Acked-by: Coly Li <colyli@xxxxxxx> >> in future version of this patch. >> >> In bcache-tools, they don’t read the changed sysfs files (including bcache-status), IMHO changing the output format won’t be problem for upstream. >> >> My only question is, how to understand the time_stats_to_text() output format, >> count: 3 >> rate: 0/sec >> frequency: 4 sec >> avg duration: 4 sec >> max duration: 4 sec >> quantiles (ns): 0 4288669120 4288669120 5360836048 5360836048 5360836048 5360836048 5360836048 5360836048 5360836048 5360836048 5360836048 5360836048 5360836048 5360836048 >> >> Fro the above output, what are “rate”, “frequence” and “quantiles” for? > > Rate and frequency are inverses - in this example, we're seeing 4 events per > second. > Can I understand that rate = 1/frequency ? Then frequency 4 is around to rate 0. > The quantiles are for the duration, they give you an idea of the statistical > distribution, see https://en.wikipedia.org/wiki/Quantile I wanted to ask how to read the quantiles line. Does it mean that 1 ns is equally divided by 15 segments, and the counter values are for the divided 1/15 ns segments? > > In the near future, the quantiles will be removed and replaced with standard > deviation, true and weighted - the quantiles algorithm isn't super accurate, we > can give more accurate numbers with standard deviation. Quantiles are much humane, standard deviation is scared… Just FYI LOL. Thanks. Coly Li