Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASDataController] Add an experiment that avoids flushing editing queue before starting the data pipeline pipeline #1564

Merged
merged 4 commits into from
Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Source/ASExperimentalFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ typedef NS_OPTIONS(NSUInteger, ASExperimentalFeatures) {
ASExperimentalSkipClearData = 1 << 6, // exp_skip_clear_data
ASExperimentalDidEnterPreloadSkipASMLayout = 1 << 7, // exp_did_enter_preload_skip_asm_layout
ASExperimentalDispatchApply = 1 << 8, // exp_dispatch_apply
ASExperimentalOOMBackgroundDeallocDisable = 1 << 9, // exp_oom_bg_dealloc_disable
ASExperimentalOOMBackgroundDeallocDisable = 1 << 9, // exp_oom_bg_dealloc_disable
ASExperimentalRemoveTextKitInitialisingLock = 1 << 10, // exp_remove_textkit_initialising_lock
ASExperimentalDrawingGlobal = 1 << 11, // exp_drawing_global
ASExperimentalOptimizeDataControllerPipeline = 1 << 12, // exp_optimize_data_controller_pipeline
ASExperimentalFeatureAll = 0xFFFFFFFF
};

Expand Down
3 changes: 2 additions & 1 deletion Source/ASExperimentalFeatures.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
@"exp_dispatch_apply",
@"exp_oom_bg_dealloc_disable",
@"exp_remove_textkit_initialising_lock",
@"exp_drawing_global"]));
@"exp_drawing_global",
@"exp_optimize_data_controller_pipeline"]));
if (flags == ASExperimentalFeatureAll) {
return allNames;
}
Expand Down
14 changes: 8 additions & 6 deletions Source/Details/ASDataController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,15 @@ - (void)updateWithChangeSet:(_ASHierarchyChangeSet *)changeSet
} else {
os_log_debug(ASCollectionLog(), "performBatchUpdates %@ %@", ASViewToDisplayNode(ASDynamicCast(self.dataSource, UIView)), changeSet);
}

NSTimeInterval transactionQueueFlushDuration = 0.0f;
{
AS::ScopeTimer t(transactionQueueFlushDuration);
dispatch_group_wait(_editingTransactionGroup, DISPATCH_TIME_FOREVER);

if (!ASActivateExperimentalFeature(ASExperimentalOptimizeDataControllerPipeline)) {
NSTimeInterval transactionQueueFlushDuration = 0.0f;
{
AS::ScopeTimer t(transactionQueueFlushDuration);
dispatch_group_wait(_editingTransactionGroup, DISPATCH_TIME_FOREVER);
}
}

// If the initial reloadData has not been called, just bail because we don't have our old data source counts.
// See ASUICollectionViewTests.testThatIssuingAnUpdateBeforeInitialReloadIsUnacceptable
// for the issue that UICollectionView has that we're choosing to workaround.
Expand Down
5 changes: 5 additions & 0 deletions Tests/ASCollectionModernDataSourceTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ @implementation ASCollectionModernDataSourceTests {

- (void)setUp {
[super setUp];

ASConfiguration *config = [ASConfiguration new];
config.experimentalFeatures = ASExperimentalOptimizeDataControllerPipeline;
[ASConfigurationManager test_resetWithConfiguration:config];

// Default is 2 sections: 2 items in first, 1 item in second.
sections = [NSMutableArray array];
[sections addObject:[ASTestSection new]];
Expand Down
12 changes: 11 additions & 1 deletion Tests/ASCollectionViewTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#import <OCMock/OCMock.h>
#import <AsyncDisplayKit/ASCollectionView+Undeprecated.h>
#import <AsyncDisplayKit/ASDisplayNode+FrameworkPrivate.h>

#import "ASDisplayNodeTestsHelper.h"
#import "ASTestCase.h"

@interface ASTextCellNodeWithSetSelectedCounter : ASTextCellNode

Expand Down Expand Up @@ -166,12 +168,20 @@ @interface ASCollectionView (InternalTesting)

@end

@interface ASCollectionViewTests : XCTestCase
@interface ASCollectionViewTests : ASTestCase

@end

@implementation ASCollectionViewTests

- (void)setUp
{
[super setUp];
ASConfiguration *config = [ASConfiguration new];
config.experimentalFeatures = ASExperimentalOptimizeDataControllerPipeline;
[ASConfigurationManager test_resetWithConfiguration:config];
}

- (void)tearDown
{
// We can't prevent the system from retaining windows, but we can at least clear them out to avoid
Expand Down
12 changes: 11 additions & 1 deletion Tests/ASCollectionViewThrashTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
#import <AsyncDisplayKit/ASCollectionView.h>
#import <stdatomic.h>

#import "ASTestCase.h"
#import "ASThrashUtility.h"

@interface ASCollectionViewThrashTests : XCTestCase
@interface ASCollectionViewThrashTests : ASTestCase

@end

Expand All @@ -25,8 +26,17 @@ @implementation ASCollectionViewThrashTests
BOOL _failed;
}

- (void)setUp
{
[super setUp];
ASConfiguration *config = [ASConfiguration new];
config.experimentalFeatures = ASExperimentalOptimizeDataControllerPipeline;
[ASConfigurationManager test_resetWithConfiguration:config];
}

- (void)tearDown
{
[super tearDown];
if (_failed && _update != nil) {
NSLog(@"Failed update %@: %@", _update, _update.logFriendlyBase64Representation);
}
Expand Down
9 changes: 6 additions & 3 deletions Tests/ASConfigurationTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
ASExperimentalDispatchApply,
ASExperimentalOOMBackgroundDeallocDisable,
ASExperimentalRemoveTextKitInitialisingLock,
ASExperimentalDrawingGlobal
ASExperimentalDrawingGlobal,
ASExperimentalOptimizeDataControllerPipeline
};

@interface ASConfigurationTests : ASTestCase <ASConfigurationDelegate>
Expand All @@ -53,11 +54,13 @@ + (NSArray *)names {
@"exp_dispatch_apply",
@"exp_oom_bg_dealloc_disable",
@"exp_remove_textkit_initialising_lock",
@"exp_drawing_global"
@"exp_drawing_global",
@"exp_optimize_data_controller_pipeline"
];
}

- (ASExperimentalFeatures)allFeatures {
- (ASExperimentalFeatures)allFeatures
{
ASExperimentalFeatures allFeatures = 0;
for (int i = 0; i < sizeof(features)/sizeof(ASExperimentalFeatures); i++) {
allFeatures |= features[i];
Expand Down
11 changes: 10 additions & 1 deletion Tests/ASTableViewTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#import <AsyncDisplayKit/ASTableView+Undeprecated.h>
#import <AsyncDisplayKit/ASInternalHelpers.h>

#import "ASTestCase.h"
#import "ASXCTExtensions.h"

#define NumberOfSections 10
Expand Down Expand Up @@ -217,12 +218,20 @@ - (ASSizeRange)tableView:(ASTableView *)tableView constrainedSizeForRowAtIndexPa

@end

@interface ASTableViewTests : XCTestCase
@interface ASTableViewTests : ASTestCase
@property (nonatomic, retain) ASTableView *testTableView;
@end

@implementation ASTableViewTests

- (void)setUp
{
[super setUp];
ASConfiguration *config = [ASConfiguration new];
config.experimentalFeatures = ASExperimentalOptimizeDataControllerPipeline;
[ASConfigurationManager test_resetWithConfiguration:config];
}

- (void)testDataSourceImplementsNecessaryMethods
{
ASTestTableView *tableView = [[ASTestTableView alloc] __initWithFrame:CGRectMake(0, 0, 100, 400)
Expand Down
12 changes: 11 additions & 1 deletion Tests/ASTableViewThrashTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
#import <AsyncDisplayKit/ASTableView+Undeprecated.h>
#import <stdatomic.h>

#import "ASTestCase.h"
#import "ASThrashUtility.h"

@interface ASTableViewThrashTests: XCTestCase
@interface ASTableViewThrashTests: ASTestCase
@end

@implementation ASTableViewThrashTests
Expand All @@ -27,8 +28,17 @@ @implementation ASTableViewThrashTests

#pragma mark Overrides

- (void)setUp
{
[super setUp];
ASConfiguration *config = [ASConfiguration new];
config.experimentalFeatures = ASExperimentalOptimizeDataControllerPipeline;
[ASConfigurationManager test_resetWithConfiguration:config];
}

- (void)tearDown
{
[super tearDown];
if (_failed && _update != nil) {
NSLog(@"Failed update %@: %@", _update, _update.logFriendlyBase64Representation);
}
Expand Down