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

Add various performance improvements #551

Merged
merged 4 commits into from
Jul 2, 2019

Conversation

martijnwalraven
Copy link
Contributor

@martijnwalraven martijnwalraven commented May 28, 2019

This PR adds various performance improvements, mostly focusing on response parsing. Among other things, it changes the response path representation to a linked list, and it adds a fast path for parsing results that don't need to be stored in the cache, which can be activated with a new .fetchIgnoringCacheCompletely cache policy. For large query results, this seems to show an 80-85% performance improvement.

@designatednerd
Copy link
Contributor

designatednerd commented Jun 26, 2019

@martijnwalraven Wanna update this in the 🇳🇱 morning and make it non-draft?

@martijnwalraven martijnwalraven marked this pull request as ready for review June 28, 2019 11:24
@designatednerd
Copy link
Contributor

ergh, @martijnwalraven I think you need to push some new code after you mark a draft ready - unfortunately travis keeps saying this is a draft PR.

@designatednerd
Copy link
Contributor

@martijnwalraven I'm seeing ReadWriteFromStoreTests.testReadHeroAndFriendsNamesQuery() fail wildly inconsistently, I don't know if that's a pre-existing issue or if it might have something to do with some changes here.

@designatednerd
Copy link
Contributor

OK, looks like it's the Thread Sanitizer throwing a fit that's causing these inconsistent fails. This is happening considerably more often than it is on master so I'm gonna mark this as changes requested until we can figure out why it's suddenly freaking out here.

Here's the error I'm getting in ApolloClient.swift (highlighted line is 238):

Screen Shot 2019-07-01 at 10 55 17 AM

Here's the big old barf of notes from Xcode.

WARNING: ThreadSanitizer: data race (pid=5366)
  Write of size 1 at 0x7b180000adb8 by thread T3 (mutexes: read M285832581809704016, write M1510, write M1502, write M1505, write M1508, write M1509, write M1500, write M1514, write M1515):
    #0 AsynchronousOperation.state.setter <compiler-generated> (Apollo:x86_64+0x474bd)
    #1 closure #1 in FetchQueryOperation.start() ApolloClient.swift:238 (Apollo:x86_64+0x95bad)
    #2 partial apply for closure #1 in FetchQueryOperation.start() <compiler-generated> (Apollo:x86_64+0x96f44)
    #3 closure #2 in ApolloStore.load<A>(query:resultHandler:) ApolloStore.swift:136 (Apollo:x86_64+0x23a3e)
    #4 partial apply for closure #2 in ApolloStore.load<A>(query:resultHandler:) <compiler-generated> (Apollo:x86_64+0x27c29)
    #5 closure #1 in closure #1 in Promise.catch(_:) Promise.swift:137 (Apollo:x86_64+0x882b0)
    #6 partial apply for closure #1 in closure #1 in Promise.catch(_:) <compiler-generated> (Apollo:x86_64+0x8ed24)
    #7 thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> () <compiler-generated> (Apollo:x86_64+0x8c2af)
    #8 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> () <compiler-generated> (Apollo:x86_64+0x8e690)
    #9 thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x8badf)
    #10 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x8eb75)
    #11 closure #1 in Promise.resolve(_:) Promise.swift:218 (Apollo:x86_64+0x8b930)
    #12 partial apply for closure #1 in Promise.resolve(_:) <compiler-generated> (Apollo:x86_64+0x8e73b)
    #13 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8bb46)
    #14 thunk for @callee_guaranteed () -> (@error @owned Error)partial apply <compiler-generated> (Apollo:x86_64+0x8e7ee)
    #15 Mutex.withLock<A>(_:) Locking.swift:29 (Apollo:x86_64+0x159b2)
    #16 Promise.resolve(_:) Promise.swift:212 (Apollo:x86_64+0x8b0a9)
    #17 Promise.reject(_:) Promise.swift:208 (Apollo:x86_64+0x85327)
    #18 partial apply for Promise.reject(_:) <compiler-generated> (Apollo:x86_64+0x8ebca)
    #19 closure #1 in closure #1 in Promise.andThen(_:) Promise.swift:123 (Apollo:x86_64+0x87396)
    #20 partial apply for closure #1 in closure #1 in Promise.andThen(_:) <compiler-generated> (Apollo:x86_64+0x8ee14)
    #21 thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> () <compiler-generated> (Apollo:x86_64+0x8c2af)
    #22 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> () <compiler-generated> (Apollo:x86_64+0x8e690)
    #23 thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x8badf)
    #24 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x8eb75)
    #25 closure #1 in Promise.resolve(_:) Promise.swift:218 (Apollo:x86_64+0x8b930)
    #26 partial apply for closure #1 in Promise.resolve(_:) <compiler-generated> (Apollo:x86_64+0x8e73b)
    #27 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8bb46)
    #28 thunk for @callee_guaranteed () -> (@error @owned Error)partial apply <compiler-generated> (Apollo:x86_64+0x8e7ee)
    #29 Mutex.withLock<A>(_:) Locking.swift:29 (Apollo:x86_64+0x159b2)
    #30 Promise.resolve(_:) Promise.swift:212 (Apollo:x86_64+0x8b0a9)
    #31 Promise.reject(_:) Promise.swift:208 (Apollo:x86_64+0x85327)
    #32 partial apply for Promise.reject(_:) <compiler-generated> (Apollo:x86_64+0x8ebca)
    #33 closure #1 in closure #1 in Promise.map<A>(_:) Promise.swift:163 (Apollo:x86_64+0x8923b)
    #34 partial apply for closure #1 in closure #1 in Promise.map<A>(_:) <compiler-generated> (Apollo:x86_64+0x8e1d0)
    #35 thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> () <compiler-generated> (Apollo:x86_64+0x8c2af)
    #36 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> () <compiler-generated> (Apollo:x86_64+0x8e690)
    #37 thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x8badf)
    #38 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x8eb75)
    #39 closure #1 in Promise.resolve(_:) Promise.swift:218 (Apollo:x86_64+0x8b930)
    #40 partial apply for closure #1 in Promise.resolve(_:) <compiler-generated> (Apollo:x86_64+0x8e73b)
    #41 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8bb46)
    #42 thunk for @callee_guaranteed () -> (@error @owned Error)partial apply <compiler-generated> (Apollo:x86_64+0x8e7ee)
    #43 Mutex.withLock<A>(_:) Locking.swift:29 (Apollo:x86_64+0x159b2)
    #44 Promise.resolve(_:) Promise.swift:212 (Apollo:x86_64+0x8b0a9)
    #45 Promise.reject(_:) Promise.swift:208 (Apollo:x86_64+0x85327)
    #46 partial apply for Promise.reject(_:) <compiler-generated> (Apollo:x86_64+0x8ebca)
    #47 closure #1 in closure #1 in Promise.catch(_:) Promise.swift:137 (Apollo:x86_64+0x882b0)
    #48 partial apply for closure #1 in closure #1 in Promise.catch(_:) <compiler-generated> (Apollo:x86_64+0x8ed24)
    #49 thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> () <compiler-generated> (Apollo:x86_64+0x8c2af)
    #50 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> () <compiler-generated> (Apollo:x86_64+0x8e690)
    #51 thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x8badf)
    #52 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x8eb75)
    #53 closure #1 in Promise.resolve(_:) Promise.swift:218 (Apollo:x86_64+0x8b930)
    #54 partial apply for closure #1 in Promise.resolve(_:) <compiler-generated> (Apollo:x86_64+0x8e73b)
    #55 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8bb46)
    #56 thunk for @callee_guaranteed () -> (@error @owned Error)partial apply <compiler-generated> (Apollo:x86_64+0x8e7ee)
    #57 Mutex.withLock<A>(_:) Locking.swift:29 (Apollo:x86_64+0x159b2)
    #58 Promise.resolve(_:) Promise.swift:212 (Apollo:x86_64+0x8b0a9)
    #59 Promise.reject(_:) Promise.swift:208 (Apollo:x86_64+0x85327)
    #60 partial apply for Promise.reject(_:) <compiler-generated> (Apollo:x86_64+0x8ebca)
    #61 closure #1 in closure #1 in Promise.andThen(_:) Promise.swift:123 (Apollo:x86_64+0x87396)
    #62 partial apply for closure #1 in closure #1 in Promise.andThen(_:) <compiler-generated> (Apollo:x86_64+0x8ee14)
    #63 thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> () <compiler-generated> (Apollo:x86_64+0x8c2af)
    #64 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> () <compiler-generated> (Apollo:x86_64+0x8e690)
    #65 thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x8badf)
    #66 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x8eb75)
    #67 closure #1 in Promise.resolve(_:) Promise.swift:218 (Apollo:x86_64+0x8b930)
    #68 partial apply for closure #1 in Promise.resolve(_:) <compiler-generated> (Apollo:x86_64+0x8e73b)
    #69 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8bb46)
    #70 thunk for @callee_guaranteed () -> (@error @owned Error)partial apply <compiler-generated> (Apollo:x86_64+0x8e7ee)
    #71 Mutex.withLock<A>(_:) Locking.swift:29 (Apollo:x86_64+0x159b2)
    #72 Promise.resolve(_:) Promise.swift:212 (Apollo:x86_64+0x8b0a9)
    #73 Promise.reject(_:) Promise.swift:208 (Apollo:x86_64+0x85327)
    #74 partial apply for Promise.reject(_:) <compiler-generated> (Apollo:x86_64+0x8ebca)
    #75 closure #1 in closure #1 in Promise.flatMap<A>(_:) Promise.swift:180 (Apollo:x86_64+0x89e7c)
    #76 partial apply for closure #1 in closure #1 in Promise.flatMap<A>(_:) <compiler-generated> (Apollo:x86_64+0x8dff0)
    #77 thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> () <compiler-generated> (Apollo:x86_64+0x8c2af)
    #78 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> () <compiler-generated> (Apollo:x86_64+0x8e690)
    #79 thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x8badf)
    #80 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x8eb75)
    #81 closure #1 in Promise.resolve(_:) Promise.swift:218 (Apollo:x86_64+0x8b930)
    #82 partial apply for closure #1 in Promise.resolve(_:) <compiler-generated> (Apollo:x86_64+0x8e73b)
    #83 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8bb46)
    #84 thunk for @callee_guaranteed () -> (@error @owned Error)partial apply <compiler-generated> (Apollo:x86_64+0x8e7ee)
    #85 Mutex.withLock<A>(_:) Locking.swift:29 (Apollo:x86_64+0x159b2)
    #86 Promise.resolve(_:) Promise.swift:212 (Apollo:x86_64+0x8b0a9)
    #87 Promise.reject(_:) Promise.swift:208 (Apollo:x86_64+0x85327)
    #88 partial apply for Promise.reject(_:) <compiler-generated> (Apollo:x86_64+0x8ebca)
    #89 closure #1 in closure #1 in Promise.map<A>(_:) Promise.swift:160 (Apollo:x86_64+0x892f4)
    #90 partial apply for closure #1 in closure #1 in Promise.map<A>(_:) <compiler-generated> (Apollo:x86_64+0x8e1d0)
    #91 thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> () <compiler-generated> (Apollo:x86_64+0x8c2af)
    #92 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> () <compiler-generated> (Apollo:x86_64+0x8e690)
    #93 thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x8badf)
    #94 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A>) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x8eb75)
    #95 closure #1 in Promise.resolve(_:) Promise.swift:218 (Apollo:x86_64+0x8b930)
    #96 partial apply for closure #1 in Promise.resolve(_:) <compiler-generated> (Apollo:x86_64+0x8e73b)
    #97 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8bb46)
    #98 thunk for @callee_guaranteed () -> (@error @owned Error)partial apply <compiler-generated> (Apollo:x86_64+0x8e7ee)
    #99 Mutex.withLock<A>(_:) Locking.swift:29 (Apollo:x86_64+0x159b2)
    #100 Promise.resolve(_:) Promise.swift:212 (Apollo:x86_64+0x8b0a9)
    #101 Promise.fulfill(_:) Promise.swift:204 (Apollo:x86_64+0x8512f)
    #102 partial apply for Promise.fulfill(_:) <compiler-generated> (Apollo:x86_64+0x8ec2a)
    #103 thunk for @escaping @callee_guaranteed (@in_guaranteed B) -> () <compiler-generated> (Apollo:x86_64+0x5bacf)
    #104 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed B) -> () <compiler-generated> (Apollo:x86_64+0x5f269)
    #105 thunk for @escaping @callee_guaranteed (@in_guaranteed B) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x5d02f)
    #106 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed B) -> (@out ()) <compiler-generated> (Apollo:x86_64+0x5edf4)
    #107 closure #2 in closure #1 in DataLoader.dispatch() DataLoader.swift:52 (Apollo:x86_64+0x5e10f)
    #108 partial apply for closure #2 in closure #1 in DataLoader.dispatch() <compiler-generated> (Apollo:x86_64+0x5e920)
    #109 thunk for @escaping @callee_guaranteed (@guaranteed [B]) -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x5e23a)
    #110 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed [B]) -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x5ea10)
    #111 closure #1 in closure #1 in Promise.andThen(_:) Promise.swift:117 (Apollo:x86_64+0x8725f)
    #112 partial apply for closure #1 in closure #1 in Promise.andThen(_:) <compiler-generated> (Apollo:x86_64+0x8ee14)
    #113 closure #1 in Promise.whenResolved(_:) Promise.swift:230 (Apollo:x86_64+0x8c06e)
    #114 partial apply for closure #1 in Promise.whenResolved(_:) <compiler-generated> (Apollo:x86_64+0x8e50f)
    #115 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8bb46)
    #116 partial apply for thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8e5be)
    #117 Mutex.withLock<A>(_:) Locking.swift:29 (Apollo:x86_64+0x159b2)
    #118 Promise.whenResolved(_:) Promise.swift:226 (Apollo:x86_64+0x861de)
    #119 closure #1 in Promise.andThen(_:) Promise.swift:113 (Apollo:x86_64+0x86e23)
    #120 partial apply for closure #1 in Promise.andThen(_:) <compiler-generated> (Apollo:x86_64+0x86f22)
    #121 Promise.init(_:) Promise.swift:63 (Apollo:x86_64+0x84e0a)
    #122 Promise.__allocating_init(_:) Promise.swift (Apollo:x86_64+0x82d1c)
    #123 Promise.andThen(_:) Promise.swift:112 (Apollo:x86_64+0x81f41)
    #124 closure #1 in DataLoader.dispatch() DataLoader.swift:50 (Apollo:x86_64+0x5c770)
    #125 partial apply for closure #1 in DataLoader.dispatch() <compiler-generated> (Apollo:x86_64+0x5c88d)
    #126 thunk for @escaping @callee_guaranteed () -> () <compiler-generated> (Apollo:x86_64+0x1d500)
    #127 __tsan::invoke_and_release_block(void*) <null>:1570672 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x6a42b)
    #128 _dispatch_client_callout <null>:1570672 (libdispatch.dylib:x86_64+0x363c)

  Previous read of size 1 at 0x7b180000adb8 by thread T5:
    #0 AsynchronousOperation.state.getter <compiler-generated> (Apollo:x86_64+0x4733e)
    #1 AsynchronousOperation.isFinished.getter AsynchronousOperation.swift:45 (Apollo:x86_64+0x47ca6)
    #2 @objc AsynchronousOperation.isFinished.getter <compiler-generated> (Apollo:x86_64+0x47bd0)
    #3 __NSOQSchedule_f <null>:1570672 (Foundation:x86_64+0x561bf)
    #4 _dispatch_client_callout <null>:1570672 (libdispatch.dylib:x86_64+0x363c)

  Location is heap block of size 96 at 0x7b180000ada0 allocated by main thread:
    #0 calloc <null>:1570704 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x4cca2)
    #1 class_createInstance <null>:1570704 (libobjc.A.dylib:x86_64h+0x64eb)
    #2 ApolloClient.fetch<A>(query:fetchHTTPMethod:cachePolicy:context:queue:resultHandler:) ApolloClient.swift:98 (Apollo:x86_64+0x90dce)
    #3 closure #1 in FetchQueryTests.testClearCacheWithPOST() FetchQueryTests.swift:399 (ApolloCacheDependentTests:x86_64+0x708f6)
    #4 partial apply for closure #1 in FetchQueryTests.testClearCacheWithPOST() <compiler-generated> (ApolloCacheDependentTests:x86_64+0x70dd0)
    #5 static InMemoryTestCacheProvider.withCache(initialRecords:execute:) TestCacheProvider.swift:13 (ApolloTestSupport:x86_64+0x7892)
    #6 protocol witness for static TestCacheProvider.withCache(initialRecords:execute:) in conformance InMemoryTestCacheProvider <compiler-generated> (ApolloTestSupport:x86_64+0x7e4c)
    #7 XCTestCase.withCache(initialRecords:execute:) TestCacheProvider.swift:51 (ApolloTestSupport:x86_64+0x9b80)
    #8 FetchQueryTests.testClearCacheWithPOST() FetchQueryTests.swift:370 (ApolloCacheDependentTests:x86_64+0x6f68b)
    #9 @objc FetchQueryTests.testClearCacheWithPOST() <compiler-generated> (ApolloCacheDependentTests:x86_64+0x71e73)
    #10 __invoking___ <null>:1570704 (CoreFoundation:x86_64h+0x4aacb)

  Mutex M285832581809704016 is already destroyed.

  Mutex M1510 (0x7b14000203b0) created at:
    #0 pthread_mutex_init <null>:1570560 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2b153)
    #1 Mutex.init() Locking.swift:7 (Apollo:x86_64+0x152f6)
    #2 Mutex.__allocating_init() Locking.swift (Apollo:x86_64+0x14d18)
    #3 Promise.init(fulfilled:) Promise.swift:32 (Apollo:x86_64+0x83876)
    #4 Promise.__allocating_init(fulfilled:) Promise.swift (Apollo:x86_64+0x83710)
    #5 InMemoryNormalizedCache.loadRecords(forKeys:) InMemoryNormalizedCache.swift:10 (Apollo:x86_64+0x4005c)
    #6 protocol witness for NormalizedCache.loadRecords(forKeys:) in conformance InMemoryNormalizedCache <compiler-generated> (Apollo:x86_64+0x40a96)
    #7 partial apply <compiler-generated> (Apollo:x86_64+0x2b6c9)
    #8 closure #1 in DataLoader.dispatch() DataLoader.swift:50 (Apollo:x86_64+0x5c5c9)
    #9 partial apply for closure #1 in DataLoader.dispatch() <compiler-generated> (Apollo:x86_64+0x5c88d)
    #10 thunk for @escaping @callee_guaranteed () -> () <compiler-generated> (Apollo:x86_64+0x1d500)
    #11 __tsan::invoke_and_release_block(void*) <null>:1570560 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x6a42b)
    #12 _dispatch_client_callout <null>:1570560 (libdispatch.dylib:x86_64+0x363c)

  Mutex M1502 (0x7b140001d840) created at:
    #0 pthread_mutex_init <null>:1570560 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2b153)
    #1 Mutex.init() Locking.swift:7 (Apollo:x86_64+0x152f6)
    #2 Mutex.__allocating_init() Locking.swift (Apollo:x86_64+0x14d18)
    #3 Promise.init(_:) Promise.swift:32 (Apollo:x86_64+0x84a92)
    #4 Promise.__allocating_init(_:) Promise.swift (Apollo:x86_64+0x82d1c)
    #5 DataLoader.subscript.getter DataLoader.swift:25 (Apollo:x86_64+0x5a7c0)
    #6 ApolloStore.ReadTransaction.loadObject(forKey:) ApolloStore.swift:195 (Apollo:x86_64+0x26123)
    #7 ApolloStore.ReadTransaction.execute<A>(selections:onObjectWithKey:variables:accumulator:) ApolloStore.swift:178 (Apollo:x86_64+0x22b23)
    #8 closure #1 in ApolloStore.load<A>(query:) ApolloStore.swift:126 (Apollo:x86_64+0x2281a)
    #9 partial apply for closure #1 in ApolloStore.load<A>(query:) <compiler-generated> (Apollo:x86_64+0x275d7)
    #10 thunk for @escaping @callee_guaranteed (@guaranteed ApolloStore.ReadTransaction) -> (@owned Promise<A>, @error @owned Error) <compiler-generated> (Apollo:x86_64+0x20a0d)
    #11 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed ApolloStore.ReadTransaction) -> (@owned Promise<A>, @error @owned Error) <compiler-generated> (Apollo:x86_64+0x20b59)
    #12 closure #1 in closure #1 in Promise.flatMap<A>(_:) Promise.swift:175 (Apollo:x86_64+0x89c82)
    #13 partial apply for closure #1 in closure #1 in Promise.flatMap<A>(_:) <compiler-generated> (Apollo:x86_64+0x8dff0)
    #14 closure #1 in Promise.whenResolved(_:) Promise.swift:230 (Apollo:x86_64+0x8c06e)
    #15 partial apply for closure #1 in Promise.whenResolved(_:) <compiler-generated> (Apollo:x86_64+0x8e50f)
    #16 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8bb46)
    #17 partial apply for thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8e5be)
    #18 Mutex.withLock<A>(_:) Locking.swift:29 (Apollo:x86_64+0x159b2)
    #19 Promise.whenResolved(_:) Promise.swift:226 (Apollo:x86_64+0x861de)
    #20 closure #1 in Promise.flatMap<A>(_:) Promise.swift:171 (Apollo:x86_64+0x8982b)
    #21 partial apply for closure #1 in Promise.flatMap<A>(_:) <compiler-generated> (Apollo:x86_64+0x8992e)
    #22 Promise.init(_:) Promise.swift:63 (Apollo:x86_64+0x84e0a)
    #23 Promise.__allocating_init(_:) Promise.swift (Apollo:x86_64+0x82d1c)
    #24 Promise.flatMap<A>(_:) Promise.swift:170 (Apollo:x86_64+0x8953f)
    #25 ApolloStore.withinReadTransaction<A>(_:) ApolloStore.swift:91 (Apollo:x86_64+0x1fcec)
    #26 ApolloStore.load<A>(query:) ApolloStore.swift:122 (Apollo:x86_64+0x22268)
    #27 ApolloStore.load<A>(query:resultHandler:) ApolloStore.swift:133 (Apollo:x86_64+0x232e8)
    #28 FetchQueryOperation.start() ApolloClient.swift:221 (Apollo:x86_64+0x9516c)
    #29 @objc FetchQueryOperation.start() <compiler-generated> (Apollo:x86_64+0x95c50)
    #30 __NSOQSchedule_f <null>:1570560 (Foundation:x86_64+0x56196)
    #31 _dispatch_client_callout <null>:1570560 (libdispatch.dylib:x86_64+0x363c)

  Mutex M1505 (0x7b140001d610) created at:
    #0 pthread_mutex_init <null>:1570560 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2b153)
    #1 Mutex.init() Locking.swift:7 (Apollo:x86_64+0x152f6)
    #2 Mutex.__allocating_init() Locking.swift (Apollo:x86_64+0x14d18)
    #3 Promise.init(_:) Promise.swift:32 (Apollo:x86_64+0x84a92)
    #4 Promise.__allocating_init(_:) Promise.swift (Apollo:x86_64+0x82d1c)
    #5 Promise.map<A>(_:) Promise.swift:153 (Apollo:x86_64+0x8892f)
    #6 ApolloStore.ReadTransaction.loadObject(forKey:) ApolloStore.swift:195 (Apollo:x86_64+0x261db)
    #7 ApolloStore.ReadTransaction.execute<A>(selections:onObjectWithKey:variables:accumulator:) ApolloStore.swift:178 (Apollo:x86_64+0x22b23)
    #8 closure #1 in ApolloStore.load<A>(query:) ApolloStore.swift:126 (Apollo:x86_64+0x2281a)
    #9 partial apply for closure #1 in ApolloStore.load<A>(query:) <compiler-generated> (Apollo:x86_64+0x275d7)
    #10 thunk for @escaping @callee_guaranteed (@guaranteed ApolloStore.ReadTransaction) -> (@owned Promise<A>, @error @owned Error) <compiler-generated> (Apollo:x86_64+0x20a0d)
    #11 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed ApolloStore.ReadTransaction) -> (@owned Promise<A>, @error @owned Error) <compiler-generated> (Apollo:x86_64+0x20b59)
    #12 closure #1 in closure #1 in Promise.flatMap<A>(_:) Promise.swift:175 (Apollo:x86_64+0x89c82)
    #13 partial apply for closure #1 in closure #1 in Promise.flatMap<A>(_:) <compiler-generated> (Apollo:x86_64+0x8dff0)
    #14 closure #1 in Promise.whenResolved(_:) Promise.swift:230 (Apollo:x86_64+0x8c06e)
    #15 partial apply for closure #1 in Promise.whenResolved(_:) <compiler-generated> (Apollo:x86_64+0x8e50f)
    #16 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8bb46)
    #17 partial apply for thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8e5be)
    #18 Mutex.withLock<A>(_:) Locking.swift:29 (Apollo:x86_64+0x159b2)
    #19 Promise.whenResolved(_:) Promise.swift:226 (Apollo:x86_64+0x861de)
    #20 closure #1 in Promise.flatMap<A>(_:) Promise.swift:171 (Apollo:x86_64+0x8982b)
    #21 partial apply for closure #1 in Promise.flatMap<A>(_:) <compiler-generated> (Apollo:x86_64+0x8992e)
    #22 Promise.init(_:) Promise.swift:63 (Apollo:x86_64+0x84e0a)
    #23 Promise.__allocating_init(_:) Promise.swift (Apollo:x86_64+0x82d1c)
    #24 Promise.flatMap<A>(_:) Promise.swift:170 (Apollo:x86_64+0x8953f)
    #25 ApolloStore.withinReadTransaction<A>(_:) ApolloStore.swift:91 (Apollo:x86_64+0x1fcec)
    #26 ApolloStore.load<A>(query:) ApolloStore.swift:122 (Apollo:x86_64+0x22268)
    #27 ApolloStore.load<A>(query:resultHandler:) ApolloStore.swift:133 (Apollo:x86_64+0x232e8)
    #28 FetchQueryOperation.start() ApolloClient.swift:221 (Apollo:x86_64+0x9516c)
    #29 @objc FetchQueryOperation.start() <compiler-generated> (Apollo:x86_64+0x95c50)
    #30 __NSOQSchedule_f <null>:1570560 (Foundation:x86_64+0x56196)
    #31 _dispatch_client_callout <null>:1570560 (libdispatch.dylib:x86_64+0x363c)

  Mutex M1508 (0x7b14000200e0) created at:
    #0 pthread_mutex_init <null>:1570560 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2b153)
    #1 Mutex.init() Locking.swift:7 (Apollo:x86_64+0x152f6)
    #2 Mutex.__allocating_init() Locking.swift (Apollo:x86_64+0x14d18)
    #3 Promise.init(_:) Promise.swift:32 (Apollo:x86_64+0x84a92)
    #4 Promise.__allocating_init(_:) Promise.swift (Apollo:x86_64+0x82d1c)
    #5 Promise.flatMap<A>(_:) Promise.swift:170 (Apollo:x86_64+0x8953f)
    #6 ApolloStore.ReadTransaction.execute<A>(selections:onObjectWithKey:variables:accumulator:) ApolloStore.swift:178 (Apollo:x86_64+0x22d74)
    #7 closure #1 in ApolloStore.load<A>(query:) ApolloStore.swift:126 (Apollo:x86_64+0x2281a)
    #8 partial apply for closure #1 in ApolloStore.load<A>(query:) <compiler-generated> (Apollo:x86_64+0x275d7)
    #9 thunk for @escaping @callee_guaranteed (@guaranteed ApolloStore.ReadTransaction) -> (@owned Promise<A>, @error @owned Error) <compiler-generated> (Apollo:x86_64+0x20a0d)
    #10 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed ApolloStore.ReadTransaction) -> (@owned Promise<A>, @error @owned Error) <compiler-generated> (Apollo:x86_64+0x20b59)
    #11 closure #1 in closure #1 in Promise.flatMap<A>(_:) Promise.swift:175 (Apollo:x86_64+0x89c82)
    #12 partial apply for closure #1 in closure #1 in Promise.flatMap<A>(_:) <compiler-generated> (Apollo:x86_64+0x8dff0)
    #13 closure #1 in Promise.whenResolved(_:) Promise.swift:230 (Apollo:x86_64+0x8c06e)
    #14 partial apply for closure #1 in Promise.whenResolved(_:) <compiler-generated> (Apollo:x86_64+0x8e50f)
    #15 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8bb46)
    #16 partial apply for thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8e5be)
    #17 Mutex.withLock<A>(_:) Locking.swift:29 (Apollo:x86_64+0x159b2)
    #18 Promise.whenResolved(_:) Promise.swift:226 (Apollo:x86_64+0x861de)
    #19 closure #1 in Promise.flatMap<A>(_:) Promise.swift:171 (Apollo:x86_64+0x8982b)
    #20 partial apply for closure #1 in Promise.flatMap<A>(_:) <compiler-generated> (Apollo:x86_64+0x8992e)
    #21 Promise.init(_:) Promise.swift:63 (Apollo:x86_64+0x84e0a)
    #22 Promise.__allocating_init(_:) Promise.swift (Apollo:x86_64+0x82d1c)
    #23 Promise.flatMap<A>(_:) Promise.swift:170 (Apollo:x86_64+0x8953f)
    #24 ApolloStore.withinReadTransaction<A>(_:) ApolloStore.swift:91 (Apollo:x86_64+0x1fcec)
    #25 ApolloStore.load<A>(query:) ApolloStore.swift:122 (Apollo:x86_64+0x22268)
    #26 ApolloStore.load<A>(query:resultHandler:) ApolloStore.swift:133 (Apollo:x86_64+0x232e8)
    #27 FetchQueryOperation.start() ApolloClient.swift:221 (Apollo:x86_64+0x9516c)
    #28 @objc FetchQueryOperation.start() <compiler-generated> (Apollo:x86_64+0x95c50)
    #29 __NSOQSchedule_f <null>:1570560 (Foundation:x86_64+0x56196)
    #30 _dispatch_client_callout <null>:1570560 (libdispatch.dylib:x86_64+0x363c)

  Mutex M1509 (0x7b140000dc10) created at:
    #0 pthread_mutex_init <null>:1570560 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2b153)
    #1 Mutex.init() Locking.swift:7 (Apollo:x86_64+0x152f6)
    #2 Mutex.__allocating_init() Locking.swift (Apollo:x86_64+0x14d18)
    #3 Promise.init(_:) Promise.swift:32 (Apollo:x86_64+0x84a92)
    #4 Promise.__allocating_init(_:) Promise.swift (Apollo:x86_64+0x82d1c)
    #5 Promise.andThen(_:) Promise.swift:112 (Apollo:x86_64+0x81f41)
    #6 closure #1 in closure #1 in Promise.flatMap<A>(_:) Promise.swift:175 (Apollo:x86_64+0x89d15)
    #7 partial apply for closure #1 in closure #1 in Promise.flatMap<A>(_:) <compiler-generated> (Apollo:x86_64+0x8dff0)
    #8 closure #1 in Promise.whenResolved(_:) Promise.swift:230 (Apollo:x86_64+0x8c06e)
    #9 partial apply for closure #1 in Promise.whenResolved(_:) <compiler-generated> (Apollo:x86_64+0x8e50f)
    #10 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8bb46)
    #11 partial apply for thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (Apollo:x86_64+0x8e5be)
    #12 Mutex.withLock<A>(_:) Locking.swift:29 (Apollo:x86_64+0x159b2)
    #13 Promise.whenResolved(_:) Promise.swift:226 (Apollo:x86_64+0x861de)
    #14 closure #1 in Promise.flatMap<A>(_:) Promise.swift:171 (Apollo:x86_64+0x8982b)
    #15 partial apply for closure #1 in Promise.flatMap<A>(_:) <compiler-generated> (Apollo:x86_64+0x8992e)
    #16 Promise.init(_:) Promise.swift:63 (Apollo:x86_64+0x84e0a)
    #17 Promise.__allocating_init(_:) Promise.swift (Apollo:x86_64+0x82d1c)
    #18 Promise.flatMap<A>(_:) Promise.swift:170 (Apollo:x86_64+0x8953f)
    #19 ApolloStore.withinReadTransaction<A>(_:) ApolloStore.swift:91 (Apollo:x86_64+0x1fcec)
    #20 ApolloStore.load<A>(query:) ApolloStore.swift:122 (Apollo:x86_64+0x22268)
    #21 ApolloStore.load<A>(query:resultHandler:) ApolloStore.swift:133 (Apollo:x86_64+0x232e8)
    #22 FetchQueryOperation.start() ApolloClient.swift:221 (Apollo:x86_64+0x9516c)
    #23 @objc FetchQueryOperation.start() <compiler-generated> (Apollo:x86_64+0x95c50)
    #24 __NSOQSchedule_f <null>:1570560 (Foundation:x86_64+0x56196)
    #25 _dispatch_client_callout <null>:1570560 (libdispatch.dylib:x86_64+0x363c)

  Mutex M1500 (0x7b1400015a50) created at:
    #0 pthread_mutex_init <null>:1570560 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2b153)
    #1 Mutex.init() Locking.swift:7 (Apollo:x86_64+0x152f6)
    #2 Mutex.__allocating_init() Locking.swift (Apollo:x86_64+0x14d18)
    #3 Promise.init(_:) Promise.swift:32 (Apollo:x86_64+0x84a92)
    #4 Promise.__allocating_init(_:) Promise.swift (Apollo:x86_64+0x82d1c)
    #5 Promise.flatMap<A>(_:) Promise.swift:170 (Apollo:x86_64+0x8953f)
    #6 ApolloStore.withinReadTransaction<A>(_:) ApolloStore.swift:91 (Apollo:x86_64+0x1fcec)
    #7 ApolloStore.load<A>(query:) ApolloStore.swift:122 (Apollo:x86_64+0x22268)
    #8 ApolloStore.load<A>(query:resultHandler:) ApolloStore.swift:133 (Apollo:x86_64+0x232e8)
    #9 FetchQueryOperation.start() ApolloClient.swift:221 (Apollo:x86_64+0x9516c)
    #10 @objc FetchQueryOperation.start() <compiler-generated> (Apollo:x86_64+0x95c50)
    #11 __NSOQSchedule_f <null>:1570560 (Foundation:x86_64+0x56196)
    #12 _dispatch_client_callout <null>:1570560 (libdispatch.dylib:x86_64+0x363c)

  Mutex M1514 (0x7b140001d890) created at:
    #0 pthread_mutex_init <null>:1570560 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2b153)
    #1 Mutex.init() Locking.swift:7 (Apollo:x86_64+0x152f6)
    #2 Mutex.__allocating_init() Locking.swift (Apollo:x86_64+0x14d18)
    #3 Promise.init(_:) Promise.swift:32 (Apollo:x86_64+0x84a92)
    #4 Promise.__allocating_init(_:) Promise.swift (Apollo:x86_64+0x82d1c)
    #5 Promise.map<A>(_:) Promise.swift:153 (Apollo:x86_64+0x8892f)
    #6 ApolloStore.load<A>(query:) ApolloStore.swift:127 (Apollo:x86_64+0x223c0)
    #7 ApolloStore.load<A>(query:resultHandler:) ApolloStore.swift:133 (Apollo:x86_64+0x232e8)
    #8 FetchQueryOperation.start() ApolloClient.swift:221 (Apollo:x86_64+0x9516c)
    #9 @objc FetchQueryOperation.start() <compiler-generated> (Apollo:x86_64+0x95c50)
    #10 __NSOQSchedule_f <null>:1570560 (Foundation:x86_64+0x56196)
    #11 _dispatch_client_callout <null>:1570560 (libdispatch.dylib:x86_64+0x363c)

  Mutex M1515 (0x7b14000209a0) created at:
    #0 pthread_mutex_init <null>:1570560 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2b153)
    #1 Mutex.init() Locking.swift:7 (Apollo:x86_64+0x152f6)
    #2 Mutex.__allocating_init() Locking.swift (Apollo:x86_64+0x14d18)
    #3 Promise.init(_:) Promise.swift:32 (Apollo:x86_64+0x84a92)
    #4 Promise.__allocating_init(_:) Promise.swift (Apollo:x86_64+0x82d1c)
    #5 Promise.andThen(_:) Promise.swift:112 (Apollo:x86_64+0x81f41)
    #6 ApolloStore.load<A>(query:resultHandler:) ApolloStore.swift:133 (Apollo:x86_64+0x233b1)
    #7 FetchQueryOperation.start() ApolloClient.swift:221 (Apollo:x86_64+0x9516c)
    #8 @objc FetchQueryOperation.start() <compiler-generated> (Apollo:x86_64+0x95c50)
    #9 __NSOQSchedule_f <null>:1570560 (Foundation:x86_64+0x56196)
    #10 _dispatch_client_callout <null>:1570560 (libdispatch.dylib:x86_64+0x363c)

  Thread T3 (tid=58036, running) is a GCD worker thread

  Thread T5 (tid=58038, running) is a GCD worker thread

SUMMARY: ThreadSanitizer: data race <compiler-generated> in AsynchronousOperation.state.setter
==================

Copy link
Contributor

@designatednerd designatednerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to figure out what's making thread sanitizer lose its tiny mind

@designatednerd designatednerd merged commit 86e7af2 into master Jul 2, 2019
@designatednerd designatednerd deleted the performance-improvements branch July 24, 2019 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants