-
Notifications
You must be signed in to change notification settings - Fork 6k
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding MockRasterCache
to our unit tests is great! We might want to minimize the duplicate code in MockRasterCache
so we're testing the real RasterCache
code instead of testing the duplicate code in MockRasterCache
. I see that your MockRasterCache
revealed some poor designs of the old RasterCache
which make the mock test quite difficult. Please let me know if you're able to fix it in this PR. If not, maybe I'll try to come up with a cleaning PR to improve the design and unblock your mock test.
54724ac
to
8a77a19
Compare
The A/B results from the
Note that some of the results that are shown as "worse" had a high variability and were mainly worse due to some outlier results. As it was, I had to do a lot of runs because every Nth run would get locked at 16ms which isn't helpful as it is not due to the performance of this code in either form (pre-or-post fix) and is due to getting stuck on a vsync wait. The main items of interest are the 20% improvement in average and 90% rasterizer times. I think I know one reason why the 99% and worst frames are not as good - currently we preroll the child layers even though we've already cached their rasterization. While there are some aspects of preroll that we might want to continue to do once we've decided to cache a layer, we don't want the child layers to be doing their own raster caching since it will be irrelevent - their output is already cached at an ancestor level. Indeed that's exactly what happens with this benchmark - the child is a picture layer and it happily wastes lots of cycles deciding and populating a cache with its contents even though they won't be used. I've decided that this issue should be fixed outside the scope of this particular work since it is already wasting cycles whether or not this fix lands. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the format of your docstrings, they aren't doxygen compatible.
flow/raster_cache.cc
Outdated
canvas_size.height()); | ||
internal_nodes_canvas.addCanvas(canvas); | ||
Layer::PaintContext paintContext = { | ||
(SkCanvas*)&internal_nodes_canvas, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: argument name comments would be a bit helpful here. Google has standardized on `/arg_name=/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I find that notation detracts from readability more than it helps. It has only appeared in a couple of places mostly in the Fuchsia modules so far and the few that I looked at look like what was once simple code becoming text soup. That discussion is probably for another venue, though.
In this particular case, every field is being copied over except for a couple. The somewhat clean code that makes it obvious that this particular process is a "mostly copy transfer/constructor" would start to look like /* really_long_and_obvious_name= */ really_long_and_obvious_name,
. Is that adding any value at that point?
The only two lines which are less than obvious are the null for the view_embedder (which is basically, we don't get to this code if there was a view_embedder in the first place so I could replace it with context->view_embedder
and it would be identical and more obvious, but waste code) and passing the supplied canvas
variable to the leaf_nodes_canvas
field only because the field has an adorned name.
I didn't write this code, I moved it a few lines in the source file. I feel it's pretty obvious so I don't see much value in adding what amounts to obfuscation notations unrelated to the actual fix that is happening just because a diff engine's robotic algorithm makes it look like new code in the review tool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaaclarke I've made some updates on the code that you commented on, did they satisfy the changes you were requesting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not my rule, google's: https://google.github.io/styleguide/cppguide.html#Function_Argument_Comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From that page:
When the meaning of a function argument is nonobvious, consider one of the following remedies:
- ...
- ...
- ...
- ...
- As a last resort, use comments to clarify argument meanings at the call site.
I don't think the remaining arguments qualify as "when the meaning is nonobvious" and I don't think this situation calls for a last resort. Further, I think that blindly using that last resort rule on every function call goes against everything that paragraph stands for. Their own example of a clean source example only uses it for one argument and that argument isn't clear from context.
The format isn't dictated, they only indicate that a comment be used - and I used a comment in the manner that all of the surrounding code in that modules uses.
I have the new refactoring done, but I am going over the doxygen style guidelines before I do another push... |
I've updated a lot of doc comments and did the refactoring to simplify the subclassing of MockRasterCache. Running the A/B test again for verification produces the following results on 5 runs:
|
I'm trying to figure out why the Linux Host Engine build is dying in the RasterCache testing code. For one thing, it is intermittent - maybe 50% of the time. Perhaps it is related to some uninitialized variables. It doesn't seem to happen without my changes, though, so it is not a pre-existing condition. The exact assert failure is in the Skia quickReject method during the call to drawImage from RCR::draw() and it is an assert that the device bounds are empty iff the raster clip is empty, which seems to be a setup issue in the canvas code, but then why would it only occur with these changes? (Note that the canvas in question is not created by the RasterCache code, it is created by the test code in raster_cache_unittests.cc.) Still investigating... |
I'm following up with Skia, but the failures I'm seeing in the Linux tests here seem to be a long-standing issue with the empty constructor for SkCanvas. The RasterCache unit tests use an empty SkCanvas to test the Draw() methods and the empty constructor leaves an uninitialized fDeviceClipBounds field which later causes an assert. I'm not sure why we never ran into this before this fix, but if we were always allocating them out of freshly mapped memory it would have always been an empty rect. Changing something in the code can cause it to be allocated in stale memory and then the unitialized values would show through. I'm following up with Skia to verify my assumptions, but pending that I don't think there is anything wrong with this fix as is. Either way, it is ready for review... |
86ff9a6
to
3daf579
Compare
I have rebased the fix on top of the Skia roll with their fix to the SkCanvas init so hopefully the Linux tests will be successful now. |
3daf579
to
185635b
Compare
6b9c595
to
ac3f66e
Compare
This is still blocked on changes requested by @gaaclarke |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, fyi @brief is optional, doxygen will take the first sentence to mean brief.
Good to know. It looks 99% similar to javadocs, and javadocs has that same "first sentence" rule, but I don't know what all the differences might be. |
I'm going to hold off until we discover the recent regression in the engine before I squash and merge. Hopefully we'll hear back on the bisect in the next hour or two. |
A recent change to how OpacityLayer manages its single child for caching purposes (see #14559) actually broke the caching of the single child. This fix not only restores the caching for the OpacityLayer, it adds tests that will detect if it successfully caches its child in practice (as long as there is only one).