Skip to content

Draft: perf: Faster contact switching by caching spell checkers

Nicoco requested to merge nicoco/gajim:gspell-checker-cache into master

This commit makes is snappier to switch between chat by caching the Gspell.Checker objects.

It triggers a linter error about a possible memory leak using lru_cache on methods but AFAIU it can be safely ignored since MessageInputTextView and TextBufferManager are singletons, see https://bugs.python.org/issue19859

Maybe 128 is too high a value for this cache, I'm not sure what's a sane size.

Benchmark

Procedure: switching between 2 contacts 20 times

Before patch

Name Call Count Time (ms) Own time (ms)
_init_spell_checker 20 884 883
show_chat 20 1842 224
switch_contact 20 1088 185

After patch

Name Call Count Time (ms) Own time (ms)
show_chat 20 823 223
switch_contact 20 3 0
_init_spell_checker 20 100 0
Edited by Nicoco

Merge request reports