Track how much measure cache entries are used
Summary: @public Adds the maximum number of measure cache entries in use to the metrics for `YGMarkerLayout` Reviewed By: SidharthGuglani Differential Revision: D13844731 fbshipit-source-id: fa66dbf1b7a1799494f72ecc17dfaef04d0b56e4
This commit is contained in:
committed by
Facebook Github Bot
parent
68f7001ed4
commit
1bc97a5e48
@@ -110,7 +110,7 @@ TEST_F(MarkerTest, layout_marker_counts_single_node_layout) {
|
|||||||
|
|
||||||
ASSERT_EQ(
|
ASSERT_EQ(
|
||||||
markerCookie.end.markerData.layout,
|
markerCookie.end.markerData.layout,
|
||||||
(YGMarkerLayoutData{.layouts = 1, .measures = 0}));
|
(YGMarkerLayoutData{.layouts = 1, .measures = 0, .maxMeasureCache = 1}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MarkerTest, layout_marker_counts_multi_node_layout) {
|
TEST_F(MarkerTest, layout_marker_counts_multi_node_layout) {
|
||||||
@@ -122,7 +122,7 @@ TEST_F(MarkerTest, layout_marker_counts_multi_node_layout) {
|
|||||||
|
|
||||||
ASSERT_EQ(
|
ASSERT_EQ(
|
||||||
markerCookie.end.markerData.layout,
|
markerCookie.end.markerData.layout,
|
||||||
(YGMarkerLayoutData{.layouts = 3, .measures = 4}));
|
(YGMarkerLayoutData{.layouts = 3, .measures = 4, .maxMeasureCache = 3}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MarkerTest, layout_marker_counts_cache_hits_single_node_layout) {
|
TEST_F(MarkerTest, layout_marker_counts_cache_hits_single_node_layout) {
|
||||||
@@ -152,10 +152,26 @@ TEST_F(MarkerTest, layout_marker_counts_cache_hits_multi_node_layout) {
|
|||||||
markerCookie.end.markerData.layout,
|
markerCookie.end.markerData.layout,
|
||||||
(YGMarkerLayoutData{.layouts = 3,
|
(YGMarkerLayoutData{.layouts = 3,
|
||||||
.measures = 0,
|
.measures = 0,
|
||||||
|
.maxMeasureCache = 5,
|
||||||
.cachedLayouts = 0,
|
.cachedLayouts = 0,
|
||||||
.cachedMeasures = 4}));
|
.cachedMeasures = 4}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(MarkerTest, layout_marker_has_max_measure_cache) {
|
||||||
|
auto root = makeNode();
|
||||||
|
auto a = addChild(root);
|
||||||
|
auto b = addChild(root);
|
||||||
|
YGNodeStyleSetFlexBasis(a.get(), 10.0f);
|
||||||
|
|
||||||
|
for (auto s : {20, 30, 40}) {
|
||||||
|
calculateLayout(root, s, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT_EQ(
|
||||||
|
markerCookie.end.markerData.layout,
|
||||||
|
(YGMarkerLayoutData{.layouts = 3, .measures = 3, .maxMeasureCache = 7}));
|
||||||
|
}
|
||||||
|
|
||||||
void* MarkerTest::startMarker(
|
void* MarkerTest::startMarker(
|
||||||
YGMarker marker,
|
YGMarker marker,
|
||||||
YGNodeRef node,
|
YGNodeRef node,
|
||||||
@@ -211,6 +227,7 @@ decltype(MarkerTest::markerCookie) MarkerTest::markerCookie = {};
|
|||||||
|
|
||||||
bool operator==(const YGMarkerLayoutData& lhs, const YGMarkerLayoutData& rhs) {
|
bool operator==(const YGMarkerLayoutData& lhs, const YGMarkerLayoutData& rhs) {
|
||||||
return lhs.layouts == rhs.layouts && lhs.measures == rhs.measures &&
|
return lhs.layouts == rhs.layouts && lhs.measures == rhs.measures &&
|
||||||
|
lhs.maxMeasureCache == rhs.maxMeasureCache &&
|
||||||
lhs.cachedLayouts == rhs.cachedLayouts &&
|
lhs.cachedLayouts == rhs.cachedLayouts &&
|
||||||
lhs.cachedMeasures == rhs.cachedMeasures;
|
lhs.cachedMeasures == rhs.cachedMeasures;
|
||||||
}
|
}
|
||||||
@@ -218,6 +235,7 @@ bool operator==(const YGMarkerLayoutData& lhs, const YGMarkerLayoutData& rhs) {
|
|||||||
void PrintTo(const YGMarkerLayoutData data, std::ostream* os) {
|
void PrintTo(const YGMarkerLayoutData data, std::ostream* os) {
|
||||||
*os << "YGMarkerLayoutData{ layouts = " << data.layouts
|
*os << "YGMarkerLayoutData{ layouts = " << data.layouts
|
||||||
<< ", measures = " << data.measures
|
<< ", measures = " << data.measures
|
||||||
|
<< ", maxMeasureCache = " << data.maxMeasureCache
|
||||||
<< ", cachedLayouts = " << data.cachedLayouts
|
<< ", cachedLayouts = " << data.cachedLayouts
|
||||||
<< ", cachedMeasures = " << data.cachedMeasures << " }";
|
<< ", cachedMeasures = " << data.cachedMeasures << " }";
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@ typedef YG_ENUM_BEGIN(YGMarker){
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
int layouts;
|
int layouts;
|
||||||
int measures;
|
int measures;
|
||||||
|
int maxMeasureCache;
|
||||||
int cachedLayouts;
|
int cachedLayouts;
|
||||||
int cachedMeasures;
|
int cachedMeasures;
|
||||||
} YGMarkerLayoutData;
|
} YGMarkerLayoutData;
|
||||||
|
@@ -3889,6 +3889,11 @@ bool YGLayoutNodeInternal(
|
|||||||
layout->lastOwnerDirection = ownerDirection;
|
layout->lastOwnerDirection = ownerDirection;
|
||||||
|
|
||||||
if (cachedResults == nullptr) {
|
if (cachedResults == nullptr) {
|
||||||
|
if (layout->nextCachedMeasurementsIndex + 1 >
|
||||||
|
(uint32_t) layoutMarkerData.maxMeasureCache) {
|
||||||
|
layoutMarkerData.maxMeasureCache =
|
||||||
|
layout->nextCachedMeasurementsIndex + 1;
|
||||||
|
}
|
||||||
if (layout->nextCachedMeasurementsIndex == YG_MAX_CACHED_RESULT_COUNT) {
|
if (layout->nextCachedMeasurementsIndex == YG_MAX_CACHED_RESULT_COUNT) {
|
||||||
if (gPrintChanges) {
|
if (gPrintChanges) {
|
||||||
YGLog(node, YGLogLevelVerbose, "Out of cache entries!\n");
|
YGLog(node, YGLogLevelVerbose, "Out of cache entries!\n");
|
||||||
|
Reference in New Issue
Block a user