diff mbox series

[v2,2/4] kernel-shark: Fix a bug in ksmodel_zoom

Message ID 20190307154316.19194-3-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Headers show
Series Various minor modifications and fixes toward KS 1.0 | expand

Commit Message

Yordan Karadzhov March 7, 2019, 3:43 p.m. UTC
When zooming-in the model is supposed to avoid over-zooming by
recalculation the Scale factor. The new value of the Scale factor is
supposed to be such that the size of the bin cannot be smaller than 5
ns. This patch fixes a naive bug in the way the new scale value is
calculated. The bug was introduced in

f97e31f00 ("kernel-shark-qt: Introduce the visualization model used by the Qt-based KS")

but had no effect until

94efea960 ("kernel-shark-qt: Handle the case when the range of the model is too small")

because the ridiculous value of the Scale factor resulted in a very
small model range and because of this the modification of the model
was always rejected.

Fixes: f97e31f00 ("kernel-shark-qt: Introduce the visualization model used by the Qt-based KS")
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark/src/libkshark-model.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Steven Rostedt March 13, 2019, 1:51 p.m. UTC | #1
On Thu,  7 Mar 2019 17:43:14 +0200
Yordan Karadzhov <ykaradzhov@vmware.com> wrote:

> When zooming-in the model is supposed to avoid over-zooming by
> recalculation the Scale factor. The new value of the Scale factor is
> supposed to be such that the size of the bin cannot be smaller than 5
> ns. This patch fixes a naive bug in the way the new scale value is
> calculated.

BTW, what if the resolution of time stamps isn't in ns, and we can have
more than one event in a 5 unit bin. Does that mean we never display
multiple events in that small of a time scale?

-- Steve
Yordan Karadzhov March 13, 2019, 1:57 p.m. UTC | #2
On 13.03.19 г. 15:51 ч., Steven Rostedt wrote:
> On Thu,  7 Mar 2019 17:43:14 +0200
> Yordan Karadzhov <ykaradzhov@vmware.com> wrote:
> 
>> When zooming-in the model is supposed to avoid over-zooming by
>> recalculation the Scale factor. The new value of the Scale factor is
>> supposed to be such that the size of the bin cannot be smaller than 5
>> ns. This patch fixes a naive bug in the way the new scale value is
>> calculated.
> 
> BTW, what if the resolution of time stamps isn't in ns, and we can have
> more than one event in a 5 unit bin. Does that mean we never display
> multiple events in that small of a time scale?

For the moment Yes.
We have to make this value (5 units /ns) a parameter that can be configured.

Yordan

> 
> -- Steve
>
diff mbox series

Patch

diff --git a/kernel-shark/src/libkshark-model.c b/kernel-shark/src/libkshark-model.c
index 4bd1e2c..af3440b 100644
--- a/kernel-shark/src/libkshark-model.c
+++ b/kernel-shark/src/libkshark-model.c
@@ -648,8 +648,8 @@  static void ksmodel_zoom(struct kshark_trace_histo *histo,
 	 * Avoid overzooming. If needed, adjust the Scale factor to a the value
 	 * which provides bin_size >= 5.
 	 */
-	if (zoom_in && range * (1 - r) < histo->n_bins * 5)
-		r = 1 - (histo->n_bins * 5) / range;
+	if (zoom_in && (int) range * (1. - r) < histo->n_bins * 5)
+		r = 1. - (histo->n_bins * 5.) / range;
 
 	/*
 	 * Now calculate the new range of the histo. Use the bin of the marker