Skip to content

Commit

Permalink
Add ability to experiment between sync and non sync mount item pool
Browse files Browse the repository at this point in the history
Summary:
After we have unified the implementation of `MountItemPool` between rendercore and litho, we are left with one single difference. Litho used synchronized pools, while rendercore didn't. For the sake of simplicity, we are going to test using non-synchronized pools in Litho as well.

This behavior is only needed for *MountSpecs* as Primitives/Mountables already rely on the render core default.

Reviewed By: zielinskimz

Differential Revision: D48731650

fbshipit-source-id: f8e7635aaa4e16cc585e5ce8db6d47c58c003b8e
  • Loading branch information
Fabio Carballo authored and facebook-github-bot committed Aug 28, 2023
1 parent 369e064 commit be77daf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.facebook.litho.annotations.OnAttached;
import com.facebook.litho.annotations.OnCreateTreeProp;
import com.facebook.litho.annotations.OnDetached;
import com.facebook.litho.config.ComponentsConfiguration;
import com.facebook.litho.debug.LithoDebugEventAttributes;
import com.facebook.rendercore.ContentAllocator;
import com.facebook.rendercore.MountItemsPool;
Expand Down Expand Up @@ -776,7 +777,10 @@ public boolean canPreallocate() {
*/
@Override
public MountItemsPool.ItemPool onCreateMountContentPool() {
return new MountItemsPool.DefaultItemPool(getPoolableContentType(), poolSize(), true);
return new MountItemsPool.DefaultItemPool(
getPoolableContentType(),
poolSize(),
ComponentsConfiguration.getDefaultComponentsConfiguration().useSyncMountPools());
}

@ThreadSafe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,16 @@ public static ComponentsConfiguration.Builder getDefaultComponentsConfigurationB

private final boolean mNestedPreallocationEnabled;

private final boolean mUseSyncMountPools;

public boolean isNestedPreallocationEnabled() {
return mNestedPreallocationEnabled;
}

public boolean useSyncMountPools() {
return mUseSyncMountPools;
}

public boolean getUseCancelableLayoutFutures() {
return mUseCancelableLayoutFutures;
}
Expand Down Expand Up @@ -358,6 +364,7 @@ private ComponentsConfiguration(ComponentsConfiguration.Builder builder) {
mShouldDisableBgFgOutputs = builder.mShouldDisableBgFgOutputs;
mUseIncrementalMountGapWorker = builder.mUseIncrementalMountGapWorker;
mNestedPreallocationEnabled = builder.mNestedPreallocationEnabled;
mUseSyncMountPools = builder.mUseSyncItemPools;
}

public boolean shouldReuseOutputs() {
Expand Down Expand Up @@ -396,6 +403,8 @@ public static class Builder {
boolean mUseIncrementalMountGapWorker = IncrementalMountExtensionConfigs.useGapWorker;
boolean mNestedPreallocationEnabled = false;

boolean mUseSyncItemPools = true;

protected Builder() {}

public Builder useCancelableLayoutFutures(boolean enable) {
Expand Down Expand Up @@ -438,6 +447,11 @@ public Builder useIncrementalMountGapWorker(boolean enabled) {
return this;
}

public Builder useSyncItemPools(boolean enabled) {
mUseSyncItemPools = enabled;
return this;
}

/**
* If true, uses the root ComponentTree's mount content allows the usage of the preallocation
* handler to perform preallocation for nested trees.
Expand Down

0 comments on commit be77daf

Please sign in to comment.