SUMMARY When opening a text file which is stored on an NFS mount, inputting a key has a noticable delay. Looking at nfsstat, every key press increases the "write" operation counter, and whatever this operation is is blocking the UI thread. The same behavior happens when saving swap files is turned off and all plugins are turned off. STEPS TO REPRODUCE 1. Open file on NFS share 2. Enter text OBSERVED RESULT Each key press causes causes an NFS write operation which hangs the UI for a short time EXPECTED RESULT UI does not hang SOFTWARE/OS VERSIONS Operating System: Gentoo Linux 2.17 KDE Plasma Version: 6.3.2 KDE Frameworks Version: 6.11.0 Qt Version: 6.8.2 Kernel Version: 6.13.5-gentoo-dist (64-bit) Graphics Platform: Wayland Processors: 24 × 13th Gen Intel® Core™ i7-13700F Memory: 62.6 GiB of RAM Graphics Processor: AMD Radeon RX 6800 XT Manufacturer: Micro-Star International Co., Ltd. Product Name: MS-7D25 System Version: 1.0
Mnn, if the swap files are off, that is strange. It would be interesting where that happens, if you could run Kate in some profiler like 'hotspot' and tell where the most time is spend that would perhaps show the bottleneck.
(In reply to Christoph Cullmann from comment #1) > Mnn, if the swap files are off, that is strange. It would be interesting > where that happens, if you could run Kate in some profiler like 'hotspot' > and tell where the most time is spend that would perhaps show the bottleneck. Trying it again, it does seem related to the swap files, my bad. Just disabling them and testing right away doesn't work which is why I didn't catch it initially, you have to close and reopen the file for the freezes to go away after setting it to either disabled or storing them in a custom local directory. This is strange though, since it's set to "Save swap files every 15s". Why does this setting do something on every key press? Also, should I still attach the generated perf.data file from hotspot? Not sure I'm doing this right since I'm not seeing a relevant function. Most of the time seems to be spent in the UI drawing code in libQt6Gui and I'm not seeing any IO calls anywhere.
Could be that io wait will not show properly in the hotspot files. Not sure why the 15 seconds setting doesn't help needs to be investigated.
I inspected the code, I see no reason why we should flush more often than once per interval, we even use just one global timer for all files.
We do flush after each edit. We sync on each sync interval.
We could try to move the flush to the place we sync.
I will take a look.
https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/798 Can you test that branch?
(In reply to Christoph Cullmann from comment #8) > https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/798 > > Can you test that branch? I applied the patch to ktexteditor 6.12.0 and looks like that fixes it. I realized I could turn on NFS debugging to look at the operations, and there: Without the patch (one write for each character typed): > [ 4218.028400] NFS: fsync file(saiko/.Test.txt.kate-swp) datasync 1 > [ 4218.031784] NFS: write(saiko/.Test.txt.kate-swp, 16@20494) > [ 4218.119789] NFS: write(saiko/.Test.txt.kate-swp, 16@20510) > [ 4218.178227] NFS: write(saiko/.Test.txt.kate-swp, 16@20526) > [ 4218.228303] NFS: write(saiko/.Test.txt.kate-swp, 16@20542) > ... > [ 4232.747619] NFS: write(saiko/.Test.txt.kate-swp, 16@24622) > [ 4232.892042] NFS: write(saiko/.Test.txt.kate-swp, 16@24638) > [ 4233.039792] NFS: write(saiko/.Test.txt.kate-swp, 16@24654) > [ 4233.139649] NFS: fsync file(saiko/.Test.txt.kate-swp) datasync 1 With the patch (every 15s only right before the fsync): > [ 4372.943790] NFS: write(saiko/.Test.txt.kate-swp, 6864@5422) > [ 4373.150276] NFS: fsync file(saiko/.Test.txt.kate-swp) datasync 1 > [ 4387.943589] NFS: write(saiko/.Test.txt.kate-swp, 6496@12286) > [ 4388.170490] NFS: fsync file(saiko/.Test.txt.kate-swp) datasync 1 Thanks!
Git commit 13972aefd78ccb25a85318f6ebd0afac0b191ab0 by Christoph Cullmann. Committed on 22/03/2025 at 14:44. Pushed by cullmann into branch 'master'. Try to flush less often to disk Bundles flush with sync, avoid stall on nfs. M +8 -8 src/swapfile/kateswapfile.cpp https://invent.kde.org/frameworks/ktexteditor/-/commit/13972aefd78ccb25a85318f6ebd0afac0b191ab0
Thanks for testing this.