[ovs-dev] [PATCH v2] python: idl: Avoid pre-allocating column defaults
Ilya Maximets
i.maximets at ovn.org
Tue Nov 30 00:32:47 UTC 2021
On 11/5/21 15:13, Terry Wilson wrote:
> Many python implementations pre-allocate space for multiple
> objects in empty dicts and lists. Using a custom dict-like object
> that only generates these objects when they are accessed can save
> memory.
>
> On a fairly pathological case where the DB has 1000 networks each
> with 100 ports, with only 'name' fields set, this saves around
> 300MB of memory.
>
> One could argue that if values are not going to change from their
> defaults, then users should not be monitoring those columns, but
> it's also probably good to not waste memory even if user code is
> sub-optimal.
>
> Signed-off-by: Terry Wilson <twilson at redhat.com>
> ---
> python/ovs/db/idl.py | 39 +++++++++++++++++++++++++++++++++------
> 1 file changed, 33 insertions(+), 6 deletions(-)
Thanks, Terry, Dumitru and Flavio! Applied.
Best regards, Ilya Maximets.
More information about the dev
mailing list