tracy icon indicating copy to clipboard operation
tracy copied to clipboard

Adding Support for Plot Aggregation

Open iamsh4 opened this issue 2 years ago • 3 comments

Hi @wolfpld, I'd like to add support for "plot aggregation" so that a plot can be configured to show an average, sum, or other aggregation of the underlying data points when zooming out. This is very useful since in multiple projects I often want to see the data points at a fine timescale, but also would like to see their sum or average when I zoom out.

I believe I can implement this in a very inexpensive way and would like your thoughts before I implement so I can avoid changes later (assuming you would merge this at all). Cheers!

iamsh4 avatar Aug 18 '23 18:08 iamsh4

Hi, Adding new plot data items is managed in Worker::InsertPlot(). Processing of the data for drawing is performed in the TimelineItemPlot class.

I believe I can implement this in a very inexpensive way and would like your thoughts before I implement so I can avoid changes later

It's hard to comment on this, as you have not provided any details ;)

wolfpld avatar Aug 18 '23 18:08 wolfpld

Apologies for being terse, I'm mostly trying to understand if this feature would be plainly ignored/denied, or if you would have interest in including this kind of "zoom out aggregation".

I can put together a proposal for how the aggregation would be done and reply back here, but basically my plan would be to have, for each plot, something like a binary tree with the aggregate value at each inner node. This way the zoom level can display the correct value on the plot by showing values at the correct depth in the tree based on zoom level and which range of the plot is in the user's view.

I would mostly likely create a new function, e.g. TracyPlotAggregationConfig(name, tracy::PlotAggregationType::Sum) so the user can define aggregation. By default, metrics have no aggregation (so the current behavior is unchanged). Please let me know what other information could be helpful; Again, I mostly want to see if you are interested in this feature and might merge if I do this work. Thanks!

iamsh4 avatar Aug 18 '23 18:08 iamsh4

I'm mostly trying to understand if this feature would be plainly ignored/denied, or if you would have interest in including this kind of "zoom out aggregation".

The feature sounds useful and would be appreciated.

my plan would be to have, for each plot, something like a binary tree with the aggregate value at each inner node. This way the zoom level can display the correct value on the plot by showing values at the correct depth in the tree based on zoom level and which range of the plot is in the user's view.

There are a few constraints you need to consider when designing how this would work:

  • The plot data elements can appear anywhere at any time. The plot data is not append-only. There are currently optimizations to make this reasonably performant, and you need to weigh how this would affect what you want to do.

  • There is very little correlation between the amount of data stored and the amount of data that needs to be drawn at any point in the plot. Spreading the data evenly over time is only one way that things can go. Note that it is equally likely to have all the data in a single pixel column, a bunch of such columns separated by nothing, or some other strange but common configuration.

I would mostly likely create a new function, e.g. TracyPlotAggregationConfig(name, tracy::PlotAggregationType::Sum) so the user can define aggregation. By default, metrics have no aggregation (so the current behavior is unchanged).

I'm not sure such a function would be necessary. I would rather expect to get the sum, average, etc. on hover by default.

wolfpld avatar Aug 18 '23 19:08 wolfpld