pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
btop-git: add patch to cache getpwuid() calls.
Module Name: pkgsrc-wip
Committed By: Santhosh Raju <fox%NetBSD.org@localhost>
Pushed By: fox
Date: Mon May 18 07:23:56 2026 +0200
Changeset: 62489e6e749f932c1c3aae42bcdc1dab980a9423
Modified Files:
btop-git/Makefile
btop-git/distinfo
Added Files:
btop-git/patches/patch-src_netbsd_btop__collect.cpp
Log Message:
btop-git: add patch to cache getpwuid() calls.
While here also enable debug builds.
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=62489e6e749f932c1c3aae42bcdc1dab980a9423
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
btop-git/Makefile | 2 +-
btop-git/distinfo | 1 +
.../patches/patch-src_netbsd_btop__collect.cpp | 50 ++++++++++++++++++++++
3 files changed, 52 insertions(+), 1 deletion(-)
diffs:
diff --git a/btop-git/Makefile b/btop-git/Makefile
index fb2a90f44b..6bcbf94c90 100644
--- a/btop-git/Makefile
+++ b/btop-git/Makefile
@@ -26,7 +26,7 @@ USE_CXX_FEATURES+= c++20
INSTALLATION_DIRS= ${PKGMANDIR}/man1
CXXFLAGS+= -DNDEBUG
-MAKE_ENV+= STRIP=true VERBOSE=true
+MAKE_ENV+= STRIP=false VERBOSE=true DEBUG=true
SUBST_CLASSES+= themes
SUBST_SED.themes+= -e 's,/usr/local/share/btop/themes,${PREFIX}/share/btop/themes,'
diff --git a/btop-git/distinfo b/btop-git/distinfo
index eacd9fcc25..b7de36e4c2 100644
--- a/btop-git/distinfo
+++ b/btop-git/distinfo
@@ -5,3 +5,4 @@ SHA512 (btop-1.4.7-6e39144aaf5a6bc01b9f795010b0914431067183.tar.gz) = b90d96cc53
Size (btop-1.4.7-6e39144aaf5a6bc01b9f795010b0914431067183.tar.gz) = 1280353 bytes
SHA1 (patch-Makefile) = 7cec0d616dd445ad139f0868141d15d1687bf402
SHA1 (patch-src_btop.cpp) = d82f33f0f894d2ecfe622116b650ef06dac42666
+SHA1 (patch-src_netbsd_btop__collect.cpp) = bb00b530a53f3993c328020e24853723d5100818
diff --git a/btop-git/patches/patch-src_netbsd_btop__collect.cpp b/btop-git/patches/patch-src_netbsd_btop__collect.cpp
new file mode 100644
index 0000000000..ae8da3b2a6
--- /dev/null
+++ b/btop-git/patches/patch-src_netbsd_btop__collect.cpp
@@ -0,0 +1,50 @@
+$NetBSD$
+
+Cache UID->username mappings to reduce getpwuid() calls.
+
+getpwuid() uses an internal libc mutex and is NOT a POSIX cancellation point.
+When the Runner thread stalls and pthread_cancel is called, the thread may
+be blocked inside getpwuid() waiting for the mutex. Since it's not a
+cancellation point, the thread cannot be cancelled cleanly.
+
+By caching the UID->username mappings, we minimize the number of getpwuid()
+calls, reducing the window where the thread can get stuck in a non-cancellable
+state.
+
+--- src/netbsd/btop_collect.cpp.orig 2026-05-06 15:50:33.000000000 +0000
++++ src/netbsd/btop_collect.cpp
+@@ -1091,7 +1091,7 @@
+ namespace Proc {
+
+ vector<proc_info> current_procs;
+- std::unordered_map<string, string> uid_user;
++ std::unordered_map<uid_t, string> uid_user;
+ string current_sort;
+ string current_filter;
+ bool current_rev = false;
+@@ -1248,9 +1248,22 @@
+ }
+ new_proc.ppid = kproc->p_ppid;
+ new_proc.cpu_s = round(kproc->p_ustart_sec);
+- struct passwd *pwd = getpwuid(kproc->p_uid);
+- if (pwd)
+- new_proc.user = pwd->pw_name;
++ //? Cache UID->username to avoid repeated getpwuid() calls
++ //? getpwuid() holds an internal libc mutex and is NOT a cancellation point,
++ //? so pthread_cancel during getpwuid() causes the Runner thread to stall
++ auto uid = kproc->p_uid;
++ if (auto it = uid_user.find(uid); it != uid_user.end()) {
++ new_proc.user = it->second;
++ } else {
++ struct passwd *pwd = getpwuid(uid);
++ if (pwd) {
++ uid_user[uid] = pwd->pw_name;
++ new_proc.user = pwd->pw_name;
++ } else {
++ uid_user[uid] = std::to_string(uid);
++ new_proc.user = uid_user[uid];
++ }
++ }
+ }
+ new_proc.p_nice = kproc->p_nice;
+ new_proc.state = kproc->p_stat;
Home |
Main Index |
Thread Index |
Old Index