Diffusion Krita e0dc28559bb7

Add a comment about the assert in KisTiledExtentManager

Authored by dkazakov on Apr 29 2020, 6:22 AM.

Description

Add a comment about the assert in KisTiledExtentManager

We cannot reliably verify correctness of concurrent access to the
tile engine. Doing run-time verification would degrage performance
significantly. We can only catch faulty situation by side effects,
e.g. when KisTiledExtentManager's sees that the number of tiles
in a column became negative.

Invariants of the tiled data manager:

  1. if one thread writes to area rc, no other thread should read or write to this area
  1. concurrent and overlapping reads from the same rc are allowed, unless there is write operation touching this rc.

What happens if we break these invariants:

  1. ThreadA writes to rc, ThreadB reads from rc -> ThreadB will read garbage, no crash will happen, Krita can continue.
  1. ThreadA writes to rc, ThreadB writes to rc -> rc will contain garbage, no crash will happen, Krita can continue.
  1. ThreadA clears rc (or uses writeBytes), ThreadB reads or writes to rc -> extent manager will enter inconsistent state (or assert), Krita behavior is undefined.

Details

Committed
dkazakovJun 2 2020, 10:04 AM
Parents
R37:2f238737b78b: Add an assert and a unittest for a bug in KisTiledExtentManager
Branches
Unknown
Tags
Unknown