Skip to content

Convert sample_groups into an array since it can contain multiple groups#2287

Merged
canova merged 3 commits intofirefox-devtools:masterfrom
canova:counter-sample-groups
Oct 28, 2019
Merged

Convert sample_groups into an array since it can contain multiple groups#2287
canova merged 3 commits intofirefox-devtools:masterfrom
canova:counter-sample-groups

Conversation

@canova
Copy link
Member

@canova canova commented Oct 21, 2019

This is the front-end changes of Bug 1584190. Because of the bug on gecko side sample_groups was an object instead of an array. This changes it to an array. Malloc counters can have only one sample groups, that's why other items in the array is ignored for memory tracks only.

cc @squelart

@canova canova requested a review from julienw October 21, 2019 19:08
@canova canova force-pushed the counter-sample-groups branch from f1cc685 to 1e0c3ad Compare October 21, 2019 19:10
@codecov
Copy link

codecov bot commented Oct 21, 2019

Codecov Report

Merging #2287 into master will decrease coverage by 0.01%.
The diff coverage is 90.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2287      +/-   ##
==========================================
- Coverage   86.14%   86.13%   -0.02%     
==========================================
  Files         204      204              
  Lines       14974    15005      +31     
  Branches     3759     3763       +4     
==========================================
+ Hits        12900    12924      +24     
- Misses       1902     1909       +7     
  Partials      172      172
Impacted Files Coverage Δ
src/app-logic/constants.js 100% <100%> (ø) ⬆️
src/profile-logic/process-profile.js 93.97% <100%> (-0.02%) ⬇️
src/profile-logic/profile-data.js 93.88% <100%> (+0.03%) ⬆️
src/profile-logic/processed-profile-versioning.js 93.75% <100%> (+0.05%) ⬆️
src/selectors/profile.js 96.77% <100%> (+0.02%) ⬆️
src/test/fixtures/profiles/gecko-profile.js 100% <100%> (ø) ⬆️
src/test/fixtures/profiles/processed-profile.js 97.97% <100%> (ø) ⬆️
src/components/timeline/TrackMemoryGraph.js 91.66% <68.42%> (-5.18%) ⬇️
src/profile-logic/gecko-profile-versioning.js 92.65% <90%> (-0.08%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 527edb8...722f504. Read the comment docs.


const samples = counter.sampleGroups.samples;
const sampleGroups = counter.sampleGroups;
if (sampleGroups.length !== 1) {
Copy link
Member Author

Choose a reason for hiding this comment

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

We are checking this here but it's not possible to fail here actually, checking here just in case. Because we only send one element from gecko, and if we fail to send that element(send an empty array instad), we handle this before coming here and remove that counter all together.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to challenge this assumption: this is the case now, but will it be the case in the future? For example with fission in the future, we could have different sampleGroups for one process. (we don't know :) ).

I'm not saying we should account for this now. But I think that the condition should be sampleGroups.length === 0 instead, and that we should throw because if that shouldn't happen we shouldn't silently ignore the problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

For example with fission in the future, we could have different sampleGroups for one process. (we don't know :) ).

Actually this is still very unlikely(impossible?) with fission. I don't think that should be the case for memory graph. Yes, it can be an assumption for counters in general. But for memory counters, it's impossible to have multiple sample group, even with fission. That one element in that array is hardcoded in Firefox memory counter code. Also in a very unlikely event, if we change that code to have multiple groups, then we'll need to change this file to make it compatible with that, since the assumption for memory graph is that there is only one sample group. And we should think/discuss how to display multiple sample groups.

But I think that the condition should be sampleGroups.length === 0 instead, and that we should throw because if that shouldn't happen we shouldn't silently ignore the problem.

Throwing an error seems too much to me. If Firefox didn't capture any counter samples, that shouldn't make the whole front-end crash. console.error would be better I think. Also I don't think we should change the code to account all the sample groups(which there are no other groups right now and it's very unlikely because of the reason I mentioned earlier). I think it's okay to have an if check for 0 element and then usage of sampleGroups[0]. What do you think?

Copy link
Contributor

@julienw julienw Oct 28, 2019

Choose a reason for hiding this comment

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

Throwing an error seems too much to me. If Firefox didn't capture any counter samples, that shouldn't make the whole front-end crash.

That's not what I suggest :)
I suggest that we throw here because that shouldn't happen here. Indeed we should never add a TrackMemoryGraph if Firefox didn't capture any counter samples, because we should have filtered them out earlier.
That's why I suggest to throw here: because that should never happen. As you said it's not possible to fail here actually :)

Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

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

Thanks for the patch!
I'm pushing the review result about the code now, but I haven't tested it manually and I'd like to do it properly. So I'm keeping the review request so that I do it tomorrow.


const samples = counter.sampleGroups.samples;
const sampleGroups = counter.sampleGroups;
if (sampleGroups.length !== 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to challenge this assumption: this is the case now, but will it be the case in the future? For example with fission in the future, we could have different sampleGroups for one process. (we don't know :) ).

I'm not saying we should account for this now. But I think that the condition should be sampleGroups.length === 0 instead, and that we should throw because if that shouldn't happen we shouldn't silently ignore the problem.

@julienw julienw self-requested a review October 23, 2019 16:44
Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

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

manually tested and this seems to work fine 👍
Please fix the comments and then I think we should be ready :)

Copy link
Member Author

@canova canova left a comment

Choose a reason for hiding this comment

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

Thanks for the review Julien! I addressed most of the reviews and added some comments for the others. Could you please take a look again?


const samples = counter.sampleGroups.samples;
const sampleGroups = counter.sampleGroups;
if (sampleGroups.length !== 1) {
Copy link
Member Author

Choose a reason for hiding this comment

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

For example with fission in the future, we could have different sampleGroups for one process. (we don't know :) ).

Actually this is still very unlikely(impossible?) with fission. I don't think that should be the case for memory graph. Yes, it can be an assumption for counters in general. But for memory counters, it's impossible to have multiple sample group, even with fission. That one element in that array is hardcoded in Firefox memory counter code. Also in a very unlikely event, if we change that code to have multiple groups, then we'll need to change this file to make it compatible with that, since the assumption for memory graph is that there is only one sample group. And we should think/discuss how to display multiple sample groups.

But I think that the condition should be sampleGroups.length === 0 instead, and that we should throw because if that shouldn't happen we shouldn't silently ignore the problem.

Throwing an error seems too much to me. If Firefox didn't capture any counter samples, that shouldn't make the whole front-end crash. console.error would be better I think. Also I don't think we should change the code to account all the sample groups(which there are no other groups right now and it's very unlikely because of the reason I mentioned earlier). I think it's okay to have an if check for 0 element and then usage of sampleGroups[0]. What do you think?

}
}
}
],
Copy link
Member Author

Choose a reason for hiding this comment

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

I added this test inside gecko-2.json because that comment says so 😄

// - nothing other than what gecko-1.json already tests, but it uses
// version 13 so it's easier to modify for future tests

But I think(if I remember correctly) previously we had a JSON file for each upgraders and then we decided to reduce those because of a few reasons.

  1. It takes a lot of time to run the test.
  2. It's a bit painful to add those tests for each upgraders.

I see your reasoning but I think it's okay to lie here a bit, because counters don't affect any other places in the upgrading/processing part and if we start to increment that number again, I'm afraid that we are gonna start having an upgrader for each version again.(not that I researched but I think new features tend to change more than the old features at first usually)
For example I had to create a processed-3.json for page information because it was affecting other markers and their upgraders. But this seems harmless here.
So I would prefer keeping it here if that's okay. What do you think?

}
]
},
"counters": [
Copy link
Member Author

Choose a reason for hiding this comment

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

preprocessedProfileVersion is 24 here.

@canova canova requested a review from julienw October 25, 2019 13:46
Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good !

I still would like the throws in TrackMemory instead of all console.error because if we enter these if conditions this means that we have a bug in some other code.
If we throw this can be caught in tests, and otherwise in runtime we'll see very quick that we did a mistake. On the contrary with the error (even with a console.error) we might miss it.

Again, I advise for this throw because this should never happen. If this could happen then this would be another story.

I hope this is clearer!

@canova canova force-pushed the counter-sample-groups branch from c17bfa5 to 722f504 Compare October 28, 2019 15:59
@canova
Copy link
Member Author

canova commented Oct 28, 2019

@julienw thanks for the review. Yeah, that makes sense. Changed the code to throw errors instead.

@canova canova merged commit 276be24 into firefox-devtools:master Oct 28, 2019
@canova canova deleted the counter-sample-groups branch October 28, 2019 16:13
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.

2 participants