diff options
| author | Raphael Collet <rco@odoo.com> | 2020-06-09 17:51:55 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-07-24 08:30:00 +0000 |
| commit | 9b7a4e1815de580575bed6657f9f8915907ce534 (patch) | |
| tree | ff10116622be73e8ec3195ac24aca2f6fb57f872 /addons/web/static/src/js/views/basic/basic_controller.js | |
| parent | 6c29ed3d427b6891996fa053d3c2f8fd7ca1ba64 (diff) | |
[IMP] core: smaller and faster field cache
Consider a context-dependent field and two possible cache structures for
storing the data of that field for N records and K context keys. The
common use-case is to assume that N is much larger than K. We look at
how many dicts are used in each cache structure, where we label dicts
with N entries as "large", and dicts with K entries as "small".
Structure | Number of dicts
---------------------------+-------------------
cache[field][id][key] | 1 large + N small
cache[field][key][id] | 1 small + K large
It is known that "small" dicts have a large relative overhead when
compared to "large" dicts. Given this fact, the second cache structure
will generate less memory overhead. Here are numbers for N=16, showing
the size in bytes taken by the cache structure. Larger values of N lead
to larger size differences, always in favor of the second structure.
Structure | K=1 | K=2 | K=3 | K=4 | K=5 | K=6
-----------------------+------+------+------+------+------+------
cache[field][id][key] | 4488 | 4488 | 4488 | 4488 | 4488 | 6536
cache[field][key][id] | 888 | 1536 | 2184 | 2832 | 3480 | 4256
Moreover, some memory operations are performed on many records and a
single context key. Those operations are clearly simpler and faster
with the second cache structure.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_controller.js')
0 files changed, 0 insertions, 0 deletions
