for experimentation: configurable measure cache size
Summary: @public Allows to limit the number of measure cache entries used. This is purely for experimentation. The measure cache uses about half of every `YGNode`. Reducing its size would allow us to reduce resident memory used by Yoga. Reviewed By: SidharthGuglani Differential Revision: D14279027 fbshipit-source-id: e0d22138230bee7fb129c193eb6e4085de02a36e
This commit is contained in:
committed by
Facebook Github Bot
parent
6368416178
commit
de79f2a1d4
@@ -28,6 +28,15 @@ __forceinline const float fmaxf(const float a, const float b) {
|
|||||||
using namespace facebook::yoga;
|
using namespace facebook::yoga;
|
||||||
using detail::Log;
|
using detail::Log;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
size_t usedMeasureCacheEntries = YG_MAX_CACHED_RESULT_COUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGSetUsedCachedEntries(size_t n) {
|
||||||
|
usedMeasureCacheEntries =
|
||||||
|
n == 0 || n > YG_MAX_CACHED_RESULT_COUNT ? YG_MAX_CACHED_RESULT_COUNT : n;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
static int YGAndroidLog(
|
static int YGAndroidLog(
|
||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
@@ -3871,7 +3880,7 @@ bool YGLayoutNodeInternal(
|
|||||||
layoutMarkerData.maxMeasureCache =
|
layoutMarkerData.maxMeasureCache =
|
||||||
layout->nextCachedMeasurementsIndex + 1;
|
layout->nextCachedMeasurementsIndex + 1;
|
||||||
}
|
}
|
||||||
if (layout->nextCachedMeasurementsIndex == YG_MAX_CACHED_RESULT_COUNT) {
|
if (layout->nextCachedMeasurementsIndex == usedMeasureCacheEntries) {
|
||||||
if (gPrintChanges) {
|
if (gPrintChanges) {
|
||||||
Log::log(node, YGLogLevelVerbose, nullptr, "Out of cache entries!\n");
|
Log::log(node, YGLogLevelVerbose, nullptr, "Out of cache entries!\n");
|
||||||
}
|
}
|
||||||
|
@@ -411,6 +411,8 @@ WIN_EXPORT float YGRoundValueToPixelGrid(
|
|||||||
const bool forceCeil,
|
const bool forceCeil,
|
||||||
const bool forceFloor);
|
const bool forceFloor);
|
||||||
|
|
||||||
|
void YGSetUsedCachedEntries(size_t);
|
||||||
|
|
||||||
YG_EXTERN_C_END
|
YG_EXTERN_C_END
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Reference in New Issue
Block a user