https://bugs.kde.org/show_bug.cgi?id=504287

            Bug ID: 504287
           Summary: KFileWidget is laggy on systems with many groups
    Classification: Frameworks and Libraries
           Product: frameworks-kio
           Version: 6.14.0
          Platform: Debian testing
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Open/save dialogs
          Assignee: kio-bugs-n...@kde.org
          Reporter: bizy...@pm.me
                CC: kdelibs-b...@kde.org
  Target Milestone: ---

SUMMARY
When browsing directories with restricted (unreadable) subdirectories, such as
/tmp, the KDE file dialog has major UI lags if the system has many groups. This
affects file pickers in KDE and Qt apps, as well as the XDG portal.

This is caused by repeated calls to KUser::groups from the paint code, which
calls getgrouplist, which has to read and parse /etc/group and /etc/group.cache
over and over again. See the attached flame graph.

$ cat /etc/group.cache | wc -l
27634
$ du -h /etc/group.cache
752K    /etc/group.cache

There should be no need for this: getgrouplist's result can be cached and
reused for the duration of the dialog's execution.

STEPS TO REPRODUCE
1. Build KIO with tests
2. Run
https://invent.kde.org/frameworks/kio/-/blob/master/tests/kfilewidgettest_gui.cpp
3. Navigate to /tmp or /

OBSERVED RESULT
Moving the mouse over restricted subdirectories (with the lock emblem) causes
UI freezes.

EXPECTED RESULT
No UI slowdowns.

SOFTWARE/OS VERSIONS
KDE Frameworks Version: 6.11, 6.14

ADDITIONAL INFORMATION
Relevant code:

* KFileItem::isReadable:
https://invent.kde.org/frameworks/kio/-/blob/85ac29eda6/src/core/kfileitem.cpp?page=2#L1292
* KUser::groups:
https://invent.kde.org/frameworks/kcoreaddons/-/blob/f67da202b88231/src/lib/util/kuser_unix.cpp#L328

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to