Optimize: Do not wipe dict cache when copying speller objects.

Review Request #123852 - Created May 19, 2015 and submitted

Information
Milian Wolff
sonnet
master
fd1043c...
Reviewers
kdeframeworks
mlaurent, sandsmark, sars
This removes a serious performance penalty from enabling on-the-fly spell
checking in KTextEditor. For some reason, the copy assignment of a Speller
object invalidated the internal cache which happened very often from the Kate
code base. Now, the cache is kept valid and reused, and the performance is good
again. I'm not sure whether this has any unintentional side-effects, but the
tests work fine and spell checking in KatePart still looks good as well,
and is now fast again.

E.g. previously I easily ended up with heaptrack reports such as this one:

2284529 calls to allocation functions with 16.23MB peak consumption from
HashMgr::add_word(char const*, int, int, unsigned short*, int, char const*, bool)
  in /usr/lib/libhunspell-1.3.so.0
1978045 calls with 2.30MB peak consumption from:
    HashMgr::load_tables(char const*, char const*)
      in /usr/lib/libhunspell-1.3.so.0
    HashMgr::HashMgr(char const*, char const*, char const*)
      in /usr/lib/libhunspell-1.3.so.0
    Hunspell::Hunspell(char const*, char const*, char const*)
      in /usr/lib/libhunspell-1.3.so.0
    HunspellDict
      at .../sonnet/src/plugins/hunspell/hunspelldict.cpp:36
      in /home/milian/projects/compiled/kf5/lib64/plugins/kf5/sonnet/hunspell.so
    HunspellClient::createSpeller(QString const&)
      at .../sonnet/src/plugins/hunspell/hunspellclient.cpp:43
      in /home/milian/projects/compiled/kf5/lib64/plugins/kf5/sonnet/hunspell.so
    Sonnet::Loader::createSpeller(QString const&, QString const&) const
      at .../sonnet/src/core/loader.cpp:103
      in /home/milian/projects/compiled/kf5/lib64/libKF5SonnetCore.so.5
    Sonnet::Speller::Private::updateDict()
      at .../sonnet/src/core/speller.cpp:64
      in /home/milian/projects/compiled/kf5/lib64/libKF5SonnetCore.so.5
    Sonnet::Speller::Private::recreateDict()
      at .../sonnet/src/core/speller.cpp:79
      in /home/milian/projects/compiled/kf5/lib64/libKF5SonnetCore.so.5
    Sonnet::Speller::operator=(Sonnet::Speller const&)
      at .../sonnet/src/core/speller.cpp:111
      in /home/milian/projects/compiled/kf5/lib64/libKF5SonnetCore.so.5
    Sonnet::BackgroundChecker::setSpeller(Sonnet::Speller const&)
      at .../sonnet/src/core/backgroundchecker.cpp:131
      in /home/milian/projects/compiled/kf5/lib64/libKF5SonnetCore.so.5
    KateOnTheFlyChecker::performSpellCheck()
      at .../ktexteditor/src/spellcheck/ontheflycheck.cpp:405
      in /home/milian/projects/compiled/kf5/lib64/libKF5TextEditor.so.5

  
Kåre Särs
Laurent Montel
Milian Wolff
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted with commit 1334cdcbce2f355455faf0bf9693881462c20416 by Milian Wolff to branch master.
Loading...