Bug 457785 - Kate is extremely slow to exit
Summary: Kate is extremely slow to exit
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (other bugs)
Version First Reported In: 22.04.3
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-12 06:22 UTC by Aaron Williams
Modified: 2022-08-16 00:07 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Williams 2022-08-12 06:22:21 UTC
SUMMARY
Whenever a new session of kate is started, exiting takes a significant amount of time, often a minute or more. In this case I only have a single file open, i.e. kate -n somefile.txt. The file is also typically fairly small, like a GIT commit message.

The window on the screen closes quickly, as one would expect, but returning to the command prompt is extremely slow.



STEPS TO REPRODUCE
1. Type kate -n somefile.txt
2. Quit kate

OBSERVED RESULT
When I quit the window closes right away as one would expect, however there is a very long delay until Kate returns to the command prompt.

EXPECTED RESULT
I do not expect a long delay.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
(gdb) thread apply all bt

Thread 8 (Thread 0x7f66a7f91700 (LWP 1385040) "QFileInfoGather"):
#0  0x00007f66ceaa370c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f66d351519b in QWaitCondition::wait(QMutex*, QDeadlineTimer) () from /usr/lib64/libQt5Core.so.5
#2  0x00007f66d4b2514c in ?? () from /usr/lib64/libQt5Widgets.so.5
#3  0x00007f66d350e8bc in ?? () from /usr/lib64/libQt5Core.so.5
#4  0x00007f66cea9c6ea in start_thread () from /lib64/libpthread.so.0
#5  0x00007f66d2d40a8f in clone () from /lib64/libc.so.6

Thread 7 (Thread 0x7f66a8792700 (LWP 1385039) "QFileInfoGather"):
#0  0x00007f66ceaa370c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f66d351519b in QWaitCondition::wait(QMutex*, QDeadlineTimer) () from /usr/lib64/libQt5Core.so.5
#2  0x00007f66d4b2514c in ?? () from /usr/lib64/libQt5Widgets.so.5
#3  0x00007f66d350e8bc in ?? () from /usr/lib64/libQt5Core.so.5
#4  0x00007f66cea9c6ea in start_thread () from /lib64/libpthread.so.0
#5  0x00007f66d2d40a8f in clone () from /lib64/libc.so.6

Thread 6 (Thread 0x7f66ba33d700 (LWP 1384870) "Thread (pooled)"):
#0  0x00007f66ceaa3a5e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f66d351512a in QWaitCondition::wait(QMutex*, QDeadlineTimer) () from /usr/lib64/libQt5Core.so.5
#2  0x00007f66d3512584 in ?? () from /usr/lib64/libQt5Core.so.5
#3  0x00007f66d350e8bc in ?? () from /usr/lib64/libQt5Core.so.5
#4  0x00007f66cea9c6ea in start_thread () from /lib64/libpthread.so.0
#5  0x00007f66d2d40a8f in clone () from /lib64/libc.so.6

Thread 5 (Thread 0x7f66bb33f700 (LWP 1384868) "Thread (pooled)"):
#0  0x00007f66d2d342f6 in ppoll () from /lib64/libc.so.6
#1  0x00007f66d3765d51 in qt_safe_poll(pollfd*, unsigned long, timespec const*) () from /usr/lib64/libQt5Core.so.5
#2  0x00007f66d367d9fb in ?? () from /usr/lib64/libQt5Core.so.5
#3  0x00007f66d36735eb in QProcess::waitForFinished(int) () from /usr/lib64/libQt5Core.so.5
#4  0x00007f66be039793 in KateProjectIndex::loadCtags (this=this@entry=0x13f27e0, files=..., ctagsMap=..., force=force@entry=false) at /usr/src/debug/kate-22.04.3-lp154.1.20.x86_64/addons/project/kateprojectindex.cpp:109
#5  0x00007f66be039b1e in KateProjectIndex::KateProjectIndex (this=0x13f27e0, baseDir=..., indexDir=..., files=..., ctagsMap=..., force=<optimized out>) at /usr/src/debug/kate-22.04.3-lp154.1.20.x86_64/addons/project/kateprojectindex.cpp:39
#6  0x00007f66be029b60 in KateProjectWorker::run (this=0xcf7cb0) at /usr/src/debug/kate-22.04.3-lp154.1.20.x86_64/addons/project/kateprojectworker.cpp:95
#7  0x00007f66d351221a in ?? () from /usr/lib64/libQt5Core.so.5
#8  0x00007f66d350e8bc in ?? () from /usr/lib64/libQt5Core.so.5
#9  0x00007f66cea9c6ea in start_thread () from /lib64/libpthread.so.0
#10 0x00007f66d2d40a8f in clone () from /lib64/libc.so.6

Thread 4 (Thread 0x7f66bc341700 (LWP 1384865) "Thread (pooled)"):
#0  0x00007f66ceaa3a5e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f66d351512a in QWaitCondition::wait(QMutex*, QDeadlineTimer) () from /usr/lib64/libQt5Core.so.5
--Type <RET> for more, q to quit, c to continue without paging--c
#2  0x00007f66d3512584 in ?? () from /usr/lib64/libQt5Core.so.5
#3  0x00007f66d350e8bc in ?? () from /usr/lib64/libQt5Core.so.5
#4  0x00007f66cea9c6ea in start_thread () from /lib64/libpthread.so.0
#5  0x00007f66d2d40a8f in clone () from /lib64/libc.so.6

Thread 3 (Thread 0x7f66bf547700 (LWP 1384862) "QDBusConnection"):
#0  0x00007f66d2d341e9 in poll () from /lib64/libc.so.6
#1  0x00007f66cc5aeb19 in g_main_context_poll (priority=<optimized out>, n_fds=3, fds=0x1fc9430, timeout=<optimized out>, context=0xb3ebb0) at ../glib/gmain.c:4478
#2  g_main_context_iterate (context=context@entry=0xb3ebb0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4170
#3  0x00007f66cc5aec2c in g_main_context_iteration (context=0xb3ebb0, may_block=1) at ../glib/gmain.c:4240
#4  0x00007f66d376a02c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQt5Core.so.5
#5  0x00007f66d370648a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQt5Core.so.5
#6  0x00007f66d350d377 in QThread::exec() () from /usr/lib64/libQt5Core.so.5
#7  0x00007f66d524a2e5 in ?? () from /usr/lib64/libQt5DBus.so.5
#8  0x00007f66d350e8bc in ?? () from /usr/lib64/libQt5Core.so.5
#9  0x00007f66cea9c6ea in start_thread () from /lib64/libpthread.so.0
#10 0x00007f66d2d40a8f in clone () from /lib64/libc.so.6

Thread 2 (Thread 0x7f66c26aa700 (LWP 1384860) "QXcbEventQueue"):
#0  0x00007f66d2d341e9 in poll () from /lib64/libc.so.6
#1  0x00007f66cf0c9387 in poll (__timeout=-1, __nfds=1, __fds=0x7f66c26a9ae8) at /usr/include/bits/poll2.h:46
#2  _xcb_conn_wait (c=c@entry=0x84a6c0, cond=cond@entry=0x84a700, vector=vector@entry=0x0, count=count@entry=0x0) at xcb_conn.c:479
#3  0x00007f66cf0cafba in xcb_wait_for_event (c=0x84a6c0) at xcb_in.c:697
#4  0x00007f66c51f8d20 in ?? () from /usr/lib64/libQt5XcbQpa.so.5
#5  0x00007f66d350e8bc in ?? () from /usr/lib64/libQt5Core.so.5
#6  0x00007f66cea9c6ea in start_thread () from /lib64/libpthread.so.0
#7  0x00007f66d2d40a8f in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7f66d8dd29c0 (LWP 1384859) "kate"):
#0  0x00007f66d2d341e9 in poll () from /lib64/libc.so.6
#1  0x00007f66cc5aeb19 in g_main_context_poll (priority=<optimized out>, n_fds=19, fds=0x36666a0, timeout=<optimized out>, context=0x858d20) at ../glib/gmain.c:4478
#2  g_main_context_iterate (context=context@entry=0x858d20, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4170
#3  0x00007f66cc5aec2c in g_main_context_iteration (context=0x858d20, may_block=1) at ../glib/gmain.c:4240
#4  0x00007f66d376a02c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQt5Core.so.5
#5  0x00007f66d370648a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQt5Core.so.5
#6  0x00007f66d370fcc7 in QCoreApplication::exec() () from /usr/lib64/libQt5Core.so.5
#7  0x000000000044223d in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/kate-22.04.3-lp154.1.20.x86_64/kate/main.cpp:703
Comment 1 Aaron Williams 2022-08-12 06:53:24 UTC
I removed anonymous.katesession and the problem has disappeared. I have preserved the original file.
Comment 2 Waqar Ahmed 2022-08-12 07:13:00 UTC
> #3  0x00007f66d36735eb in QProcess::waitForFinished(int) () from /usr/lib64/libQt5Core.so.5
> #4  0x00007f66be039793 in KateProjectIndex::loadCtags (this=this@entry=0x13f27e0, files=..., ctagsMap=..., force=force@entry=false) at /usr/src/debug/kate-22.04.3-lp154.1.20.x86_64/addons/project/kateprojectindex.cpp:109

Seems like you have CTags enabled in the project plugin. When you open a single file in a git repo, it loads the whole repo as a project and starts CTags indexing. When you quit, that indexing hasn't finished yet so it waits.
Comment 3 Aaron Williams 2022-08-12 10:19:22 UTC
This would explain another problem I have where when logging back in ctags consumes an inordinate amount of memory sorting (well over 100GB!) It would be nice if I could limit this or if ctags could be killed. In the case of the files taking a very long time the number of files in the tree was fairly small, though I have several other massive trees I also open. I have disabled this and the problem seems to have disappeared.
Comment 4 Waqar Ahmed 2022-08-12 10:57:22 UTC
22.04 tries to restore the projects you had open last time which can lead to unpleasant results. I assume you dont use sessions so a lot of projects have accumulated. Check the combobox at the top of project files tree, it will list all open projects. Try closing a few of them and it should be a lot better.

22.08 provides an option allowing you to opt-out of project restoration.
Comment 5 Waqar Ahmed 2022-08-14 10:55:19 UTC
Marking this as fixed as we have included an option that causes this problem. With 22.08 you can disable project restoration in the Project plugin settings and this problem will go away.

I will try to make other improvements around this to ensure that things are not so bad if one has multiple projects open.
Comment 6 Aaron Williams 2022-08-14 22:49:31 UTC
I generally do not use sessions. Despite disabling ctags, each time I start Kate it never picks up the new settings., making this ctags issue especially annoying.
Comment 7 Waqar Ahmed 2022-08-15 12:59:25 UTC
> Despite disabling ctags, each time I start Kate it never picks up the new settings

You mean CTags setting is reenabled?
Comment 8 Aaron Williams 2022-08-16 00:07:44 UTC
Yes. Any changes to the settings of Kate do not seem to take hold. Note that I had numerous instances of Kate running. I was able to fix this by logging out and deleting ~/.local/share/kate/anonymous.katesession. If other instances of kate are running, settings do not take effect.