zodb / relstorage

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

Cache: Heuristic to avoid storing large transactions? #330

Open jamadden opened 5 years ago

jamadden commented 5 years ago

Things like rebuilding catalogs can produce large transactions. While those transactions can use savepoints to reduce their internal memory usage, at the end of the transaction the local cache will currently store everything, up until its limit, potentially flushing out lots of other useful data (Especially if these are new objects, we have no idea if they'll be needed soon.) This can also take a long time in a way that blocks event loops (though it does grab and release an internal lock a lot so there is opportunity for thread/greenlet switching; but it also reads from disk).

We have a rough heuristic around the checkpoints to try to avoid polling large transactions. Perhaps we can do something similar-ish here: if the stored data is more than x% of the available cache space, don't bother?