Bug 325442 - Constant loop reading of /etc/passwd from /proc updates
Summary: Constant loop reading of /etc/passwd from /proc updates
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-29 20:17 UTC by zeronullity
Modified: 2016-08-28 15:04 UTC (History)
13 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zeronullity 2013-09-29 20:17:20 UTC
Konsole is causing a loop to constantly read from /etc/passwd every second.. even while idle  by pulling information from /proc/{pid}/stat etc.. Is there no better way of doing this?

Reproducible: Always

Steps to Reproduce:
1. strace -p {konsole}
2. inotifywait /etc/passwd -mrq
3.
Actual Results:  
Constant reading of /etc/passwd every second because of constant /proc access even while idle.

Expected Results:  
I'm sure it's reading from a cached passwd file but I don't think there should be any activity while idle or while nothing is running in Konsole window.
Comment 1 Kurt Hindenburg 2013-10-01 14:03:51 UTC
yep
Comment 2 Jos van den Oever 2014-04-01 13:46:13 UTC
Confirmed in Konsole Version 2.12.3.
Comment 3 Jason Tibbitts 2016-05-19 18:43:51 UTC
I'm running konsole5 15.12.3 and the behavior persists.  Is there anything we can do to track this down?

Some time ago there was a big push to minimize the number of wakeups programs were doing in order to extend battery life.  Is there still any focus on that kind of thing, or still anyone keeping track of places which need optimization  of wakeups?
Comment 4 Kurt Hindenburg 2016-05-30 15:24:16 UTC
I'm looking at this - it is the readUserName() which is causing this.
Comment 5 Kurt Hindenburg 2016-05-31 00:01:13 UTC
Git commit 0edded4975b6c687d6c8b671b13dadf498e76b7f by Kurt Hindenburg.
Committed on 30/05/2016 at 23:58.
Pushed by hindenburg into branch 'master'.

Only readUserName if tab title format has %u

readUserName() reads /etc/passwd every few seconds.  Change it to only
do this if we need to replace %u with the user name in the tab title.

A temporary helper as this doesn't really fix the underlining issue.
ProcessInfo really needs re-worked.

M  +37   -21   src/ProcessInfo.cpp
M  +8    -3    src/ProcessInfo.h
M  +4    -2    src/Session.cpp

http://commits.kde.org/konsole/0edded4975b6c687d6c8b671b13dadf498e76b7f
Comment 6 Kevin Funk 2016-07-20 12:41:31 UTC
This needs to be fixed as it also has an impact on battery life.

Note the bad behavior is multiplied by the number of applications using konsole part. Right now I see tons of open/close events from yakuake/dolphin/kate/kdevelop on /etc/passwd.

With 2x kdevelop, 1x kate, 1x yakuake with 10x konsole windows I get around 35 OPENs on /etc/passwd per second.

Easy to test:
sudo fatrace -f O -s 10 | grep /etc/passwd | wc -l
Comment 7 Nikita Skovoroda 2016-07-20 12:48:26 UTC
Yes, it causes about 130 events per second for me, constantly. Most of that comes from a kate window (I have some files opened) and yakuake (I have several tabs opened, but not too many, around 10).
Comment 8 Andreas Hartmetz 2016-07-20 12:51:02 UTC
The reading of /etc/passwd is just the most visible symptom, it can be fixed with KDirWatch. Ideally there'd be ways to blocking-wait for changes in all (or as many as possible) of the process / tab title information.
Comment 9 Martin Sandsmark 2016-08-13 16:47:53 UTC
with https://quickgit.kde.org/?p=konsole.git&a=commit&h=bb6abc0bc8a23f46752f7341d43e4275e9085fa9 one possible solution is to not call updateWorkingDirectory() in getDynamicTitle() if _reportedWorkingUrl is valid.
Comment 10 Martin Sandsmark 2016-08-27 11:26:51 UTC
Git commit e07a62ede32467089c1e4c57f7fed141ea009c49 by Martin T. H. Sandsmark.
Committed on 27/08/2016 at 11:26.
Pushed by sandsmark into branch 'master'.

Remove unused environment reading code

REVIEW: 128674

M  +26   -150  src/ProcessInfo.cpp
M  +11   -48   src/ProcessInfo.h

http://commits.kde.org/konsole/e07a62ede32467089c1e4c57f7fed141ea009c49
Comment 11 Martin Sandsmark 2016-08-27 20:41:32 UTC
Git commit 392ee33cf8ffec54d41d342d7cba8fe82a13adc0 by Martin T. H. Sandsmark.
Committed on 27/08/2016 at 20:41.
Pushed by sandsmark into branch 'master'.

Don't re-read process information that should be static

This changes the process info code to only update the information that
can change about a process when updating information about a process.
REVIEW: 128777

M  +125  -110  src/ProcessInfo.cpp
M  +8    -7    src/ProcessInfo.h

http://commits.kde.org/konsole/392ee33cf8ffec54d41d342d7cba8fe82a13adc0
Comment 12 Martin Sandsmark 2016-08-28 15:04:27 UTC
Git commit e7770aba9f6af26cba3dbecc1ac085acb214c6cc by Martin T. H. Sandsmark.
Committed on 28/08/2016 at 15:04.
Pushed by sandsmark into branch 'master'.

Avoid polling processes if they report what we need with OCS7

This is apparently what the OCS7 stuff is supposed to solve, so let's
use it if we can.

REVIEW: 128784

M  +0    -27   src/ProcessInfo.cpp
M  +5    -24   src/ProcessInfo.h
M  +44   -6    src/Session.cpp

http://commits.kde.org/konsole/e7770aba9f6af26cba3dbecc1ac085acb214c6cc