Skip to content

Commit 244c868

Browse files
authored
merge accounting of the (mutually exclusive) picture and dl cache entries in reported statistics (flutter#28392)
1 parent b8a759b commit 244c868

File tree

4 files changed

+13
-37
lines changed

4 files changed

+13
-37
lines changed

flow/raster_cache.cc

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,7 @@ size_t RasterCache::GetLayerCachedEntriesCount() const {
413413
}
414414

415415
size_t RasterCache::GetPictureCachedEntriesCount() const {
416-
return picture_cache_.size();
417-
}
418-
419-
size_t RasterCache::GetDisplayListCachedEntriesCount() const {
420-
return display_list_cache_.size();
416+
return picture_cache_.size() + display_list_cache_.size();
421417
}
422418

423419
void RasterCache::SetCheckboardCacheImages(bool checkerboard) {
@@ -434,14 +430,13 @@ void RasterCache::SetCheckboardCacheImages(bool checkerboard) {
434430

435431
void RasterCache::TraceStatsToTimeline() const {
436432
#if !FLUTTER_RELEASE
437-
FML_TRACE_COUNTER("flutter", "RasterCache", reinterpret_cast<int64_t>(this),
438-
"LayerCount", layer_cache_.size(), "LayerMBytes",
439-
EstimateLayerCacheByteSize() / kMegaByteSizeInBytes,
440-
"PictureCount", picture_cache_.size(), "PictureMBytes",
441-
EstimatePictureCacheByteSize() / kMegaByteSizeInBytes,
442-
"DisplayListCount", display_list_cache_.size(),
443-
"DisplayListMBytes",
444-
EstimateDisplayListCacheByteSize() / kMegaByteSizeInBytes);
433+
FML_TRACE_COUNTER(
434+
"flutter", //
435+
"RasterCache", reinterpret_cast<int64_t>(this), //
436+
"LayerCount", GetLayerCachedEntriesCount(), //
437+
"LayerMBytes", EstimateLayerCacheByteSize() / kMegaByteSizeInBytes, //
438+
"PictureCount", GetPictureCachedEntriesCount(), //
439+
"PictureMBytes", EstimatePictureCacheByteSize() / kMegaByteSizeInBytes);
445440

446441
#endif // !FLUTTER_RELEASE
447442
}
@@ -463,17 +458,12 @@ size_t RasterCache::EstimatePictureCacheByteSize() const {
463458
picture_cache_bytes += item.second.image->image_bytes();
464459
}
465460
}
466-
return picture_cache_bytes;
467-
}
468-
469-
size_t RasterCache::EstimateDisplayListCacheByteSize() const {
470-
size_t display_list_cache_bytes = 0;
471461
for (const auto& item : display_list_cache_) {
472462
if (item.second.image) {
473-
display_list_cache_bytes += item.second.image->image_bytes();
463+
picture_cache_bytes += item.second.image->image_bytes();
474464
}
475465
}
476-
return display_list_cache_bytes;
466+
return picture_cache_bytes;
477467
}
478468

479469
} // namespace flutter

flow/raster_cache.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,28 +186,17 @@ class RasterCache {
186186

187187
size_t GetPictureCachedEntriesCount() const;
188188

189-
size_t GetDisplayListCachedEntriesCount() const;
190-
191189
/**
192190
* @brief Estimate how much memory is used by picture raster cache entries in
193-
* bytes.
191+
* bytes, including cache entries in the SkPicture cache and the DisplayList
192+
* cache.
194193
*
195194
* Only SkImage's memory usage is counted as other objects are often much
196195
* smaller compared to SkImage. SkImageInfo::computeMinByteSize is used to
197196
* estimate the SkImage memory usage.
198197
*/
199198
size_t EstimatePictureCacheByteSize() const;
200199

201-
/**
202-
* @brief Estimate how much memory is used by display list raster cache
203-
* entries in bytes.
204-
*
205-
* Only SkImage's memory usage is counted as other objects are often much
206-
* smaller compared to SkImage. SkImageInfo::computeMinByteSize is used to
207-
* estimate the SkImage memory usage.
208-
*/
209-
size_t EstimateDisplayListCacheByteSize() const;
210-
211200
/**
212201
* @brief Estimate how much memory is used by layer raster cache entries in
213202
* bytes.

shell/common/shell.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,9 +1707,6 @@ bool Shell::OnServiceProtocolEstimateRasterCacheMemory(
17071707
response->AddMember<uint64_t>("pictureBytes",
17081708
raster_cache.EstimatePictureCacheByteSize(),
17091709
response->GetAllocator());
1710-
response->AddMember<uint64_t>("displayListBytes",
1711-
raster_cache.EstimateDisplayListCacheByteSize(),
1712-
response->GetAllocator());
17131710
return true;
17141711
}
17151712

shell/common/shell_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2185,7 +2185,7 @@ TEST_F(ShellTest, OnServiceProtocolEstimateRasterCacheMemoryWorks) {
21852185
document.Accept(writer);
21862186
std::string expected_json =
21872187
"{\"type\":\"EstimateRasterCacheMemory\",\"layerBytes\":40000,\"picture"
2188-
"Bytes\":400,\"displayListBytes\":0}";
2188+
"Bytes\":400}";
21892189
std::string actual_json = buffer.GetString();
21902190
ASSERT_EQ(actual_json, expected_json);
21912191

0 commit comments

Comments
 (0)