lxcid / ListDiff

Swift port of IGListKit's IGListDiff
MIT License
241 stars 23 forks source link

#6 adopt walkarounds for collection view #7

Closed Usipov closed 5 years ago

Usipov commented 6 years ago

Adopted this walkarounds

Added stress tests of continuous random collection view updates


testing iteration 3
  from 10, to: 10.
  deletes 339, inserts: 339, moves 274, updates: 79.

testing iteration 4
  from 10, to: 87.
  deletes 93, inserts: 170, moves 47, updates: 95.

testing iteration 5
  from 87, to: 178.
  deletes 92, inserts: 183, moves 296, updates: 127.

testing iteration 6
  from 178, to: 222.
  deletes 139, inserts: 183, moves 129, updates: 277.

testing iteration 7
  from 222, to: 260.
  deletes 307, inserts: 345, moves 96, updates: 92.

testing iteration 8
  from 260, to: 146.
  deletes 323, inserts: 209, moves 74, updates: 108.

testing iteration 9
  from 146, to: 231.
  deletes 398, inserts: 483, moves 179, updates: 39.

testing iteration 10
  from 231, to: 488.
  deletes 215, inserts: 472, moves 249, updates: 17.

testing iteration 11
  from 488, to: 104.
  deletes 496, inserts: 112, moves 215, updates: 22.

testing iteration 12
  from 104, to: 189.
  deletes 68, inserts: 153, moves 143, updates: 301.
Usipov commented 6 years ago

ci integration failed, becuase the tests are run via swift test which does not support swift and objective-c files why not to use simple xcodebuild?

lxcid commented 6 years ago

Hey this looks amazing! It might take a while to look into this though but I love to get this work into master! I wanna thank you first for this PR! cheers!

devpolant commented 5 years ago

@Usipov Thanks a lot for your pull request, but I have found an issue with autoreleasepool { .. } in your implementation of ListDiffStressTests. You are starting the next iteration synchronously in the same autoreleasepool block, so some time later the test will crash because of unable to alloc new memory:

xctest(12364,0x7aa21c0) malloc: *** mach_vm_map(size=8388608) failed (error code=3)
*** error: can't allocate region securely
*** set a breakpoint in malloc_error_break to debug
2018-10-04 13 47 24

Test using a lot of memory (3.15 GB), as you can see on screenshot.

As a workaround you can dispatch the next test iteration asynchronously on main queue that allows you to properly clear used memory in autorelease pool block.

DispatchQueue.main.async {
    self?.performTest(
        index: index + 1,
        expectations: expectations,
        previousCellDataList: cellDataGeneratorResult.to
    )
}
Usipov commented 5 years ago

@AntonPoltoratskyi, hmmmm...... lol I even had this async dispatch in my uncommited changes. Probably forgot to commit