Commit Graph
15 Commits
Author SHA1 Message Date
Cédric Krier d02f8acae2 Do not rely on keyword arguments order in LRUDict update test
The insertion order in dictionary is only preserved since Python 3.7.

issue9413
2020-06-17 01:08:22 +02:00
Cédric Krier 23bac3a173 Wait cache sync after clearing cache in test
The test relies on the cache being cleared before setting a value from the old
transaction. So we must wait for the synchronisation to happen when channel is
used.

issue9413
review327461011
2020-06-17 00:25:57 +02:00
Cédric Krier b3f8d125f9 Use custom class to store record data
By using a class with slots instead of standard dict, we can reduce a lot the
memory usage to store the record data in the caches and values.
Also we can rely on the data in the cache to exist only for real field which
can be used to create a fast path in ModelStorage.__getattr__.
As now storing data in the cache has no extra cost, we can store data from the
transactional cache in the local. This allow also to have a shorter path in
ModelStorage.__getattr__.
For more memory efficiency, we remove the record from the cache instead of
clearing them. It was better to clear a dict but a record is less expensive to
re-instantiate than clearing.

issue9369
issue9225
review297861002
2020-06-13 09:48:03 +02:00
Cédric Krier 89c737a819 Test memory cache with committed transaction as current
The tests did not correspond to a proper use case because the transaction
committed was not the current transaction. So this could lead to wrong cache
being reset and wrong cache being tested.

issue8502
review289171002
2020-02-10 23:13:26 +01:00
Nicolas Évrard 8fb13634ea Use direct access to backend classes
issue8836
review258421002
2019-12-06 17:33:47 +01:00
Cédric Krier 7dbcc96b8e Use separate connection to query cache table
The table is a hot spot for contention so we must minimize the duration lock
are kept on it. As at the start of a transaction, the cache may be sync and so
it locks all the row in the table, the transaction used for this query should
not be the main one that lasts a long time. Idem for the commit.

issue8447
review283591002
2019-07-08 21:24:33 +02:00
Cédric Krier 4b4c57a362 Add duration on Cache
issue8249
review283181002
2019-04-11 18:35:25 +02:00
Cédric Krier 45946c23ef Wait up to 10 seconds for cache sync in tests
On busy host, it may require some time to receive the notification.

issue8198
review269141003
2019-03-16 14:56:32 +01:00
Cédric Krier e5e92ac81a Allow to use channel to synchronize Cache
When the clear timeout of the cache is zero, we launch a thread to synchronize
caches if the back-end support channels.
The thread is started on the first call to sync for the database.
The channel is also used to clear the cache of the process initiating the
clearing. This allows to test the mechanism is working with a single process.
So there will be a small delay even on single instance.

issue8027
review68431002
2019-03-09 17:03:38 +01:00
Cédric Krier c4ddbb064a Prevent filling cache with data from old transaction
Once the cache has been cleared, we must ensure that transaction started
before the clearing cannot fill the global cache.

issue8019
review56541002
2019-03-02 23:11:14 +01:00
Cédric Krier 9eaac0f3a3 Cast timestamp as datetime for sqlite back-end
SQLite backend returns a string for the datetime so the comparison between
timestamp fails.

issue8080
review48721002
2019-02-13 10:23:44 +01:00
Cédric Krier da24071467 Make Cache transactional
We implement sync, commit and rollback to follow transaction semantic.
When a transaction clears a cache, the global cache is cleared only when the
transaction is committed meanwhile the transaction will use a cache for itself
only.
We remove _nocache option because the sync, commit and rollback operate only
for the transaction.

issue7975
review53521002
2019-01-18 11:57:11 +01:00
Cédric Krier c144f8c349 Fix most flake8 errors
review8771002
2014-12-02 12:54:01 +01:00
Cédric Krier a6ffa18908 Add run-tests script and cleanup tests
issue2121
issue2420
review2491002
2014-01-12 19:58:22 +01:00
Cédric Krier 1e60085854 Use a better hashing method for context
repr doesn't guarantee to have always the same string

review642002
2013-02-04 19:59:05 +01:00