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

Improve memory track visualization with the stacked graph #2422

Merged
merged 5 commits into from Jun 21, 2021

Conversation

vickyliu-go4it
Copy link
Collaborator

@vickyliu-go4it vickyliu-go4it commented Jun 11, 2021

With this change, we change the MemoryTrack to visualize data as a stacked graph.

We also plan to refactor the current graph related tracks according to the following diagram.
Screenshot 2021-06-11 163936

The detailed plan to refactor the current graph related tracks and add / update memory tacks and pagefault tracks is:

  • STEP 1. Rename current GraphTrack as VariableTrack
  • STEP 2. Add the new GraphTrack
  • STEP 3. Add the AnnotationTrack
  • STEP 4. Add the MemoryTrack for system memory usage
  • STEP 5. Add the MemoryTrack for process & cgroup memory usage
  • STEP 6. Add the PagefaultTrack
  • STEP 7. Change the VariableTrack to inherit from the new GraphTrack

And this PR contains the changes from STEP 1 to STEP 4.

Memory track after the change:
Screenshot 2021-06-11 095542

Updated class diagram:
Screen Shot 2021-06-16 at 15 02 40

Bug: http://b/185108718
Test: Run orbit and take a capture with enabling memory tracing.

@vickyliu-go4it vickyliu-go4it force-pushed the vicky-memory/stacked_graph branch 3 times, most recently from a15ed0d to 8079977 Compare June 11, 2021 08:45
@vickyliu-go4it vickyliu-go4it marked this pull request as draft June 11, 2021 11:06
@vickyliu-go4it vickyliu-go4it force-pushed the vicky-memory/stacked_graph branch 3 times, most recently from 132fe46 to 19d84ef Compare June 11, 2021 15:23
@vickyliu-go4it vickyliu-go4it marked this pull request as ready for review June 11, 2021 15:35
Copy link
Collaborator

@beckerhe beckerhe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, Vicky. I added some comments. 🙂

src/OrbitGl/GraphTrack.h Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.h Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.h Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.h Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.h Outdated Show resolved Hide resolved
src/OrbitGl/AnnotationTrack.h Outdated Show resolved Hide resolved
src/OrbitGl/MemoryTrack.h Outdated Show resolved Hide resolved
src/OrbitGl/TrackManager.h Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.h Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.h Outdated Show resolved Hide resolved
Copy link
Contributor

@antonrohr antonrohr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry, this PR takes me forever to review. I am not completely done yet, but here is the first batch of comments. I really like this PR and in addition to beckerhe's comments, I have some more ideas to make it even better.

src/OrbitGl/GraphTrack.h Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.cpp Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.cpp Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.cpp Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.cpp Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.cpp Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.cpp Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.cpp Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.cpp Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@antonrohr antonrohr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am now done with the review :)

src/OrbitGl/AnnotationTrack.cpp Outdated Show resolved Hide resolved
src/OrbitGl/TrackManager.cpp Outdated Show resolved Hide resolved
src/OrbitGl/TrackManager.cpp Outdated Show resolved Hide resolved
src/OrbitGl/TrackManager.cpp Outdated Show resolved Hide resolved
src/OrbitGl/TrackManager.cpp Outdated Show resolved Hide resolved
src/OrbitGl/MemoryTrack.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@beckerhe beckerhe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks even better now. Thanks for all the work Vicky and sorry for being so late with the review. I added some more comments. 🙈

src/OrbitGl/MultivariateTimeSeries.h Outdated Show resolved Hide resolved
src/OrbitGl/MultivariateTimeSeries.h Outdated Show resolved Hide resolved
src/OrbitGl/MultivariateTimeSeries.h Outdated Show resolved Hide resolved
UpdateMinAndMax(value);
}
}
void UpdateMinAndMax(double value) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should probably be private

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out this. This might be called by the MemoryTrack when we set the value upper bound and lower bound.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. In that case I would suggest to not put min_ and max_ into this class. If these values can be changed independently from the time series then they don't share any invariance and shouldn't be in the same class.

src/OrbitGl/MultivariateTimeSeries.h Outdated Show resolved Hide resolved
src/OrbitGl/MultivariateTimeSeries.h Show resolved Hide resolved
src/OrbitGl/GraphTrack.cpp Outdated Show resolved Hide resolved
src/OrbitGl/MultivariateTimeSeries.h Outdated Show resolved Hide resolved
src/OrbitGl/TimeGraphLayout.h Outdated Show resolved Hide resolved
src/OrbitGl/AnnotationTrack.h Outdated Show resolved Hide resolved
@vickyliu-go4it
Copy link
Collaborator Author

Thanks for reviewing this PR! Also sorry for making this so difficult to review 🙈 I should split it into smaller ones!

Also could you give some suggestion on the collapsed version? Should we keep drawing the while label when the graph track is collapsed?

image

src/OrbitGl/GraphTrack.cpp Outdated Show resolved Hide resolved
Comment on lines 143 to 150
absl::StrAppend(&text, delimiter);
absl::StrAppend(&text, series_names[i].empty() ? "" : absl::StrFormat("%s: ", series_names[i]));
absl::StrAppend(&text, value_decimal_digits.has_value()
? absl::StrFormat("%.*f", value_decimal_digits.value(), values[i])
: std::to_string(values[i]));
absl::StrAppend(&text, label_unit);
delimiter = "\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing my earlier comment and please take the following as a personal preference. I did a bad job requesting a split up to increase readability, because I did not go into more detail on what I actually mean.

Beforehand it was this:

absl::StrAppend(&text, delimiter,
                series_names[i].empty() ? "" : absl::StrFormat("%s: ", series_names[i]),
                value_decimal_digits_.has_value()
                    ? absl::StrFormat("%.*f", value_decimal_digits_.value(), values[i])
                    : std::to_string(values[i]),
                label_unit_);

I would argue its easier readable and understandable if it has some extra variable names, so I dont need to keep partial result in my head. I dont know if what Im saying makes sense. This is what I mean:

std::string formatted_value =
    value_decimal_digits.has_value()
        ? absl::StrFormat("%.*f", value_decimal_digits.value(), values[i])
        : std::to_string(values[i]);
std::string formatted_name =
    series_names[i].empty() ? "" : absl::StrFormat("%s: ", series_names[i]);

absl::StrAppend(&text, delimiter, formatted_name, formatted_value, label_unit);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed accordingly! Also sorry for misunderstanding your suggestion previously. I like your idea of adding more variable with readable names here! Thanks!

src/OrbitGl/GraphTrack.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@beckerhe beckerhe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Vicky. I added some more minor comments, but in general I think that's good to go!

Copy link
Contributor

@antonrohr antonrohr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not done with the next review round. I will look at it again on monday

src/OrbitGl/GraphTrack.cpp Outdated Show resolved Hide resolved
src/OrbitGl/GraphTrack.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@antonrohr antonrohr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you a lot for adding my requests :)
Only one more small nit about method name cases.

src/OrbitGl/MultivariateTimeSeries.h Outdated Show resolved Hide resolved
src/OrbitGl/MultivariateTimeSeries.h Show resolved Hide resolved
With this change, we rename the original `GraphTrack` with a single data
series as `VariableTrack`.
With this change, we add the MultivariateTimeSeries class and the unit
tests.
With this change, we add the new `GraphTrack` which can visualize
multiple data series.
With this change, we add the `AnnotationTrack` which provides the
functionality of drawing the value limits and the warning threshold.
With this change, we update the `MemoryTrack` to inherit from the new
`GraphTrack`, and draw data series as a stacked graph.
@vickyliu-go4it vickyliu-go4it merged commit 01e073a into google:main Jun 21, 2021
This was referenced Jul 5, 2021
@vickyliu-go4it vickyliu-go4it deleted the vicky-memory/stacked_graph branch February 24, 2022 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants