Nanoseconds support #624
Comments
I could just supply nanoseconds (w/o dividing them by 1000), and in fact the visualization is much better this way, all visual glitches go away. But UI says 1000 seconds trace, when I actually have 1 second trace. So what would work as well -- is an ability to set timestamps units to nanoseconds. |
The math of the viewer requires that we use microseconds internally or else you end up with numeric precision issues. Nanoseconds simply won't work. So we must internally stay with milliseconds on the model. Therefore, I can see two routes forward here: (1) make the importer convert from ns to ms internally, or (2) make the analysis system display using ns when appropriate (or always, based on a setting). For 1, you'd add a field to the container object saying tsUnit: "ns", then modify traceEventImporter to use that and internally have it convert everything to ms. For 2, you'd modify the core/analysis folder to display data using ns when it was small enough, or possibly based on a global setting. You'd probably make pretty good headway by searching for tsRound() in the code, which is the general code we use to go from ms to a rounded string. I'm not up for writing these patches, but would review a pr to either effect. |
Btw, I'd vote for 1 and 2 :) |
I've created a quick patch for the second approach Of course I'm really concerned about the patch - it seems like it could start causing issues to multiplying with 1e6, although I didn't notice a case where it happens. Regarding the special case in unit.html - I'm not sure whether it's a good idea or not. It seems if the tracer is mostly in ms mode then outputting "0 ms" is better than "0 ns". Of course it's trivial to remove it. PS. I have really no good understanding nor overview how the tool works internally and the patch was created by fixing the bugs I saw. Basically, I have no idea whether this may cause additional problems elsewehere. |
Thanks, Egon! Nat, does this approach look right to you? |
Its good that you're finding some of the places that need to be touched. But, we want to break this apart into many little patches, each of which has tests and is individually tested. I'd start with making the ruler show ns when very zoomed in. I have to ask that this is contributed via codereview. It should be pretty straightforward to make depot_tools work on windows --- you just download it and put it in your path. |
Currently I pass nanoseconds as if they are microseconds. Will I need to pass fractional microseconds with this patch? That is, currently I pass 1 assuming that it is 1ns but the viewer assumes it is 1us; with this patch I will need to pass 0.001 when I assume 1ns. Is it correct? |
@natduca I will split it tomorrow and get depot_tools running + learn the tooling tomorrow. @dvyukov I didn't change the meaning of timestamps, so it uses microseconds. Somehow I managed to mix up microseconds and nanoseconds so yes, it should be "us". Probably needs some other fixes as well. I will fix it tomorrow. |
I've created the CLs:
|
@egonelbre I've tried to test your changes. My repo is on 2014e39 (current tip). Without your changes vulcanize_trace_viewer passes. With your changes it fails as:
|
The failure happens when I apply both of separately: |
I'm guessing it doesn't like that I'm using |
Hello, Mr. Python, it is second decade of XXI century. Have you heard about unicode? :) |
@dvyukov PTAL |
@egonelbre works now! One issue that I noticed is that when I use Select tool (arrow), trace-viewer show duration of the current selection rounded down to 0.01ms (10us). This precision is not enough for Go, as some goroutines run for less (e.g. 5us), and the duration is shown as just 0ms. |
ping |
@dvyukov the review process takes some time due to, me not being familiar with the code, coding style & patches, review feedback comes with a day delay (time-zone difference) and, I guess, both are not working on this full time. But, it should be cleaned up soon enough. |
Ah, sorry, @egonelbre. I wasn't subscribed on the code reviews, so I missed all activity there and thought that nothing happens at all. If the reviews are progressing, then it is great. |
You can see all the reviews here, https://codereview.appspot.com/user/egon I think you missed some. |
…g and visualizing different kinds of united data. Size, times are the two current strong units but a few more are likely. BUG=#624 TBR=nduca Review URL: https://codereview.appspot.com/236580044
Now, regarding integrating this into model/UI. From Go users perspective an UI option wouldn't be useful as all the files will be in nanoseconds. It seems that most likely you want the precision that the model was recorded, but with option to go back to a larger time-scale, e.g. if you recorded a long time-span then viewing it in ms. might make sense. Thoughts? |
Either a meta element in input json file or a config file setting will do for Go.
Before the changes UI autotuned units. That is, even if input data is in microseconds, when you look at a long span, UI shows it in seconds. Does it still work? If yes, then we don't need to do anything on top of that I think. |
How about for starters we modify trace event forat document [linked off Once we have that patch done, we can figure out how we want to connect the Lets do the patch work for the stuff we're certain about and then we can On Thu, Jun 4, 2015 at 4:29 AM Dmitry Vyukov notifications@github.com
|
Regarding the UI binding, I started thinking whether it's necessary at all, if everything is showing correctly already. If there's a separate request, I guess then we could start thinking about it. Anyways, I started implementing the importing and I hit one issue; the defaultTimeUnit for events is microseconds not milliseconds, but it is showing it in milliseconds. I'm not sure what is the correct handling is? It seems weird to have defaultTimeUnit:"ns", but the value imported is microseconds, or have defaultTimeUnit:"ns" import from nanoseconds, but defaultTimeUnit:"ms" import from microseconds. I can see two ways out of this... either make the defaultTimeUnit:"us" and when deriving the displayUnit, use defaultTimeUnit:"ms" for "us"... alternatively rename "defaultTimeUnit" -> "displayTimeUnit" to make clear that it's only being used for displaying not the values in the model itself. Currently I'm going with the first approach, as it looks more right to me. |
displayTimeUnit makes sense. I think we want the model to always be in ms. On Sun, Jun 14, 2015 at 4:50 AM Egon Elbre notifications@github.com wrote:
|
@natduca Sorry for confusion, I think I have used the wrong terminology. And as a response to:
Correction, the model is still in ms... Currently "trace event format" by default is in microseconds, and "model" timestamps are always in milliseconds. However, since the trace-event-format is in microseconds the model.intrinsicTimeUnit had to default to microseconds, i.e. in my patches "intrinsicTimeUnit" == "the precision unit that the data was recorded at". I might have misinterpreted the meaning of converting in your previous suggestion. I thought it was about converting the trace event format values based on the "defaultTimeUnit" vallue. I went with that approach at that moment because modifying CLs from "defaultTimeUnit" -> "displayTimeUnit" is easier than "displayTimeUnit" -> "defaultTimeUnit". Also, as a confirmation to the adjustments I'm going to make: we want the JSON object format to always be in microseconds and the format only specifies 'displayTimeUnit'? |
BUG=#624 R=nduca@chromium.org Review URL: https://codereview.appspot.com/248870043 Change-Id: I9ad83391f01d3abd74c08cea67a13c848eccffa3
BUG=#624 R=nduca@chromium.org Review URL: https://codereview.appspot.com/246980043 Change-Id: Id6e1849c0c5367878caa43d99bc44b3304eb746f
BUG=#624 R=nduca@chromium.org Review URL: https://codereview.appspot.com/246010044 Change-Id: I2abd4f0304241d07fa7836069cc8012999a05329
Now regarding attaching displayTimeUnit to the UI. I'm guessing the UI interface for changing the time-unit won't be necessary, since it is most likely to be the one set in the model; of course if it is necessary some will likely ask for it. Regarding binding the model.displayTimeUnit -> Time.currentDisplayTimeUnit - I have no clue where the most appropriate place would be. |
Yeah, this seems racey if we do it wrong. Thinking out loud, a timeline view owns the model, so a timeline view can have a "preferred" time precision, right? So, what if every timeline-view owned an element like this:
TimelineView would set the preferredDisplayUnit on that widget anytime the model changes. And that element has this prototype:
Then base's didPreferred goes through and finds all the display-unit-preference instances using deep_utils. It then asks each one for their preference, using the most precise one if there are multiple. It then sets its mode to that... |
The main question is that when we should show
It's somewhat a problematic case, on one hand you can be recording 1-10s of data and then zoom into nanosecond level details. I.e. it probably needs something more advanced than just switching to ns to make it nice to use. Clearly losing precision when showing small values is bad, showing 0,000ms as the time isn't useful. Then again, showing big values will show irrelevant details. Also, showing ns when the recording precision was microseconds, makes no sense. Maybe it should switch instead based on the zoom-level to the lowest intrinsicTimeUnit available. e.g. when the whole view span is less than 0.1ms it will switch to ns, if there is a model that has displayTimeUnit:ns. |
I think the same architecture I suggested would support that. The timeline
|
I somewhat am confused where to put everything, but here is this https://codereview.appspot.com/252340043. (PS. when creating "idea" CL-s should I mail them for CR or not?). I'll add tests to it once, I know I'm actually on the right track regards structuring things. In didPreferredUnit has to do something better than just min/max over everything. I experimented with it a bit. The best unit seems to be "use the max(ruler-unit, min(model.intrinsicUnit))". Basically, we shouldn't show more precision than we actually have in the model and we shouldn't show details that we cannot see on the view. |
Agreed on the min/max thing. And cl's are fine, if you're uncertain about how good the patch is, then you can always prefix the title with something like [NOT for landing] or similar to warn reviewers that you're not super sure about the approach. |
Wow @egonelbre that patch was excellent. Ship it. :) |
As a general reitveld note, it's better to put [NOT FOR LANDING] in the description then the title. Rietveld never seems to update the email title after sending the first one so it's really confusing to get not for landing in a email subject on a cl that's for landing, heh. |
Migrated to catapult-project/catapult#624 |
Hi,
I want to use the trace viewer and it looks awesome.
But my traces have nanosecond precision. I've tried to divide the timestamps by 1000 and use fractional values, but it does not work. The viewer understands fractional values, but then the visual representation looks completely messed seemingly due to some rounding errors (it seem to assume that min duration of a slice is 1.0). Here is a reproducer:
{"traceEvents": [
{"name": "X1", "ph": "B", "pid": 1, "tid": 1, "ts": 0},
{"name": "X1", "ph": "E", "pid": 1, "tid": 1, "ts": 1.1},
{"name": "X2", "ph": "B", "pid": 1, "tid": 1, "ts": 1.1},
{"name": "X2", "ph": "E", "pid": 1, "tid": 1, "ts": 1.3},
{"name": "X3", "ph": "B", "pid": 1, "tid": 1, "ts": 1.3},
{"name": "X3", "ph": "E", "pid": 1, "tid": 1, "ts": 1.6},
{"name": "X4", "ph": "B", "pid": 1, "tid": 1, "ts": 1.7},
{"name": "X4", "ph": "E", "pid": 1, "tid": 1, "ts": 2.1},
{}]}
I've also noticed that if I have several flow events starting at the same microsecond:
{"name": "unblock", "ph": "s", "pid": 0, "tid": 0, "id": "86", "ts": 45747.68},
{"name": "unblock", "ph": "t", "pid": 0, "tid": 3, "id": "86", "ts": 45799.224},
{"name": "unblock", "ph": "s", "pid": 0, "tid": 0, "id": "87", "ts": 45747.989},
{"name": "unblock", "ph": "t", "pid": 0, "tid": 2, "id": "87", "ts": 45825.085},
Then, they are drawn on several rows. While I would expect them to be draw on the same row, as they start at different times.
I am on revision f306225.
The text was updated successfully, but these errors were encountered: