zodb / relstorage

A backend for ZODB that stores pickles in a relational database.
Other
54 stars 46 forks source link

Check cache for read current #472

Closed jamadden closed 3 years ago

jamadden commented 3 years ago

Use the cache to cheaply check if a readCurrent() violation will take place during an early part of two-phase commit, instead of waiting until tpc_vote when we've sent data to the database.

If the cache can prove that there is a newer version of an object stored, the conflict error will be raised during commit; if the cache can't prove it, the error will still be raised during tpc_vote.

This more closely matches what FileStorage does and can help avoid some unnecessary work.

I'm running the micro benchmark suite now, but I'm not expecting it to show any differences (the benchmarks don't actually trigger readCurrent conflicts, but they do use it). (ETA: They don't show any difference.)

/cc @jzuech3 @cutz

jamadden commented 3 years ago

I wrote a new benchmark specifically to exercise readCurrent conflicts. The good news is that, depending on settings such as concurrency level, I saw up to 22% of read conflict errors being caught by the cache. The bad news is that pyperf didn't report any significant performance difference, positive or negative.

I remain hopeful about impacts on real life though.