New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 694609 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Oct 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Feature



Sign in to add a comment

Re-evaluate text blob caching

Project Member Reported by fmalita@chromium.org, Feb 21 2017

Issue description

We're currently side-caching one blob per InlineTextBox: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp?rcl=c51531ca429e54478b286186091d83a7419ce05f&l=445

This has some downsides:

a) if there's more than one blob per ITB, we cannot cache
b) we incur the storage and record-time lookup cost of a hashmap


At the time text blobs were added, caching was critical for record_time (see CT record_time_caching_disabled numbers below), but since then a couple of things happened: SlimmingPaint and the text shaping unification+cache.

Caching is still important in order to persist SkTextBlob objects across rasterization passes (the blob unique IDs are part of Ganesh's internal cache), but now we have some other options:

1) cache the text blob ref in InlineTextBox -- this is incremental, just converting from a side-cache to direct ITB blob ownership; saves the hashmap overhead.  Prolly not worth the trouble.


2) cache the text blob ref in ShapeResult -- this is an interesting twist: cache blobs per shaped word instead of per-ITB, and use blob composition to paint line boxes.  In theory it should yield a) fewer blobs (reduced memory?), b) smaller/more granular blobs (improved raster time culling?), and c) more drawTextBlob() commands (??).


3) don't retain text blobs in Blink at all - but instead rely on SlimmingPaint's display list caching (and partial inval) for blob persistence.  A quick 10k cluster telemetry run shows no surprises with this approach (setting record_time_partial_invalidation aside, different issue): caching_disabled numbers are up significantly, but normal/caching numbers are not affected (within noise levels).

https://storage.cloud.google.com/cluster-telemetry/tasks/chromium_perf_runs/fmalita-20170217190417/html/index.html

Fieldname                                       Total           Total with Patch Percentage Change Percentage Difference
record_time_caching_disabled (ms)               12251.554       18114.511        47.855%           38.615%
record_time_partial_invalidation_ms (ms)        10080.437       14614.953        44.983%           36.724%
record_time_subsequence_caching_disabled (ms)   4181.180        4194.221          0.312%            0.311%
pixels_rasterized (pixels)                      14920351836.300 14927884947.700   0.050%            0.050%
pixels_recorded (pixels)                        52238092956.500 52235819602.200  -0.004%           -0.004%
viewport_picture_size (bytes)                   2052746201.330  2052148013.330   -0.029%           -0.029%
rasterize_time (ms)                             39125.552       39041.546        -0.215%           -0.215%
record_time (ms)                                474.747         471.162          -0.755%           -0.758%
record_time_painting_disabled (ms)              7490.734        7404.198         -1.155%           -1.162%
record_time_construction_disabled (ms)          5309.852        5228.619         -1.530%           -1.542%

So #3 seems feasible, and #2 is an interesting option to explore.
 

Comment 1 by drott@chromium.org, Feb 21 2017

I'm very glad you're taking this on and re-evaluating this portion of paint caching in Blink. Thank you!

So, in option 3, Slimming Paint would temporarily keep the text blobs that the Font.cpp code would generate when it calls drawTextBlob, and we would not need to explicitly cache them? If that works, and if it does not perform significantly slower than 2, that sounds great to me.

@drott - yes, in option #3 SP is caching display list items (currently SKPs, but possibly other custom formats), including drawTextBlob() commands.  These are retained and reused until their DOM counterparts are invalidated (assuming SP's partial inval works as expected).

I'm hoping SP gurus can provide some reassurance that display item caching and partial inval in particular are currently in place/working as expected, and my explanation above is accurate :)  Then I'd be OK with landing #3 ASAP (working on CL).

#2 is still interesting because it changes the blob granularity and could possibly improve some metrics.  We can experiment with it later though.
Project Member

Comment 3 by bugdroid1@chromium.org, Feb 23 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6f057b93cf230adadd55af0490c836d91ba6e1fd

commit 6f057b93cf230adadd55af0490c836d91ba6e1fd
Author: fmalita <fmalita@chromium.org>
Date: Thu Feb 23 00:55:00 2017

Remove the text blob cache

SlimmingPaint display list item caching provides the same level of
SkTextBlob persistence.

BUG= 694609 
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2707083002
Cr-Commit-Position: refs/heads/master@{#452318}

[modify] https://crrev.com/6f057b93cf230adadd55af0490c836d91ba6e1fd/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp
[modify] https://crrev.com/6f057b93cf230adadd55af0490c836d91ba6e1fd/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
[modify] https://crrev.com/6f057b93cf230adadd55af0490c836d91ba6e1fd/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.h
[modify] https://crrev.com/6f057b93cf230adadd55af0490c836d91ba6e1fd/third_party/WebKit/Source/core/paint/TextPainter.cpp
[modify] https://crrev.com/6f057b93cf230adadd55af0490c836d91ba6e1fd/third_party/WebKit/Source/core/paint/TextPainter.h
[modify] https://crrev.com/6f057b93cf230adadd55af0490c836d91ba6e1fd/third_party/WebKit/Source/platform/BUILD.gn
[modify] https://crrev.com/6f057b93cf230adadd55af0490c836d91ba6e1fd/third_party/WebKit/Source/platform/fonts/Font.cpp
[modify] https://crrev.com/6f057b93cf230adadd55af0490c836d91ba6e1fd/third_party/WebKit/Source/platform/fonts/Font.h
[delete] https://crrev.com/aaa73ea0f5ac4aadf0f30e12a3e86fa3388ec1be/third_party/WebKit/Source/platform/fonts/TextBlob.h
[modify] https://crrev.com/6f057b93cf230adadd55af0490c836d91ba6e1fd/third_party/WebKit/Source/platform/text/TextRun.h

SGTM. Let's see if any of the perf graphs trigger in a negative way for this.
Cc: enne@chromium.org
Do our TextBlobs have only one run currently?

When looking at CDL, TextBlobs are somewhat tricky to serialize because 
they're opaque, and they save SkPaint font properties internally.  The drawText() counterparts are more simple since they're plain data plus a separate SkPaint which we can customize in CDL.

Is the main reason for using TextBlobs at this point to have a persistent ID for Skia's internal text blob cache?
Yes, blobs have at most one run (but runs may be broken into multiple blobs due to bidi/rotation differences).

The current advantages of using blobs over drawPosText:

1) cached bounds -> efficient raster-time culling
2) ref-counted & persistent -> efficient sharing & recording (not copying a bunch of glyph/pos data)
3) persistent unique ID -> Ganesh caching (GrTextBlobCache)

We could make SkTextBlob more transparent (public run iterator?), but there's no real advantage over using a TextBlob CDL other than saving a lot of typing.  Assuming the CDL would provide the same semantics (persistent IDs, cached bounds, and cached SkTextBlobs in the raster process).
Status: Fixed (was: Assigned)

Sign in to add a comment