Compare commits

..

6 Commits

Author SHA1 Message Date
Robert Roth
4285abe72b Prepared release 2.35.90 2017-02-13 23:21:31 +02:00
Benoît Dejean
1a103bf142 When parsing /proc/cpuinfo, ignore paragraphs that do not describe a CPU/core. 2017-01-28 09:39:43 +01:00
Benoît Dejean
3ff313dd03 Update git ignore list. 2017-01-22 10:56:59 +01:00
Benoît Dejean
01a56e2e30 Use g_ascii_isspace instead of isspace because the later is slower and we
only need to deal with ascii.
2017-01-22 10:45:26 +01:00
Benoît Dejean
7afc81f99d Do not cache getpagesize(), it is already. 2017-01-22 10:45:26 +01:00
Benoît Dejean
b0ab056e99 Use a dynamically allocated buffer to read /proc/cpuinfo to handle computers
with a lot of CPUs.

https://bugzilla.gnome.org/show_bug.cgi?id=323354
2017-01-22 10:45:26 +01:00
8 changed files with 75 additions and 59 deletions

64
.gitignore vendored
View File

@@ -1,45 +1,38 @@
*~
*.a
*.bak
*.core
*.diff
*.gmo
*.header
*.in
*.la
*.lo
*.o
*.out
*.a
*.gmo
*.lo
*.la
*.core
*.patch
*.pot
*.s
*.sed
*.sin
*.stamp
.libs
*.swp
*~
.deps
Makefile
Makefile.in
src/daemon/libgtop_daemon2
src/daemon/libgtop_server2
stamp-h1
po/stamp-it
po/POTFILES
po/Makefile.in.in
missing
m4/
ltmain.sh
libtool
libgtopconfig.h
libgtop.spec
libgtop-2.0.pc
lib/lib.c
lib/GTop-2.0.gir
lib/GTop-2.0.typelib
.libs
ABOUT-NLS
INSTALL
Makefile
Makevars.template
Rules-quot
aclocal.m4
autom4te.cache/
compile
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
compile
depcomp
doc/libgtop2.info
doc/mdate-sh
@@ -79,3 +72,20 @@ examples/timings
examples/wd
gtk-doc.make
install-sh
lib/GTop-2.0.gir
lib/GTop-2.0.typelib
lib/lib.c
libgtop-2.0.pc
libgtop.spec
libgtopconfig.h
libtool
ltmain.sh
m4/
missing
po/POTFILES
po/stamp-it
src/daemon/libgtop_daemon2
src/daemon/libgtop_server2
stamp-h1
stamp-po
tmp-*

12
NEWS
View File

@@ -1,3 +1,15 @@
13 February 2017: Overview of changes in 2.35.90
================================================
* Linux:
- Use dynamically allocated cpu buffer
- Do not cache getpagesize()
- Use faster g_ascii_isspace in tokenization
- Ignore paragraphs not describing a CPU/core
* Updated translations
* Added more gettext options
16 January 2017: Overview of changes in 2.34.2
================================================

View File

@@ -3,8 +3,8 @@ dnl Configure script for the Gnome library
dnl
m4_define([libgtop_major_version], [2])
m4_define([libgtop_minor_version], [34])
m4_define([libgtop_micro_version], [2])
m4_define([libgtop_minor_version], [35])
m4_define([libgtop_micro_version], [90])
m4_define([libgtop_version], [libgtop_major_version.libgtop_minor_version.libgtop_micro_version])
dnl increment if the interface has additions, changes, removals.

View File

@@ -51,7 +51,7 @@ char *
skip_token (const char *p)
{
p = next_token(p);
while (*p && !isspace(*p)) p++;
while (*p && !g_ascii_isspace(*p)) p++;
p = next_token(p);
return (char *)p;
}
@@ -178,20 +178,6 @@ get_boot_time(glibtop *server)
}
size_t
get_page_size(void)
{
static size_t pagesize = 0;
if(G_UNLIKELY(!pagesize))
{
pagesize = getpagesize();
}
return pagesize;
}
gboolean
check_cpu_line(glibtop *server, const char *line, unsigned i)

View File

@@ -37,7 +37,7 @@ G_BEGIN_DECLS
static inline char*
next_token(const char *p)
{
while (isspace(*p)) p++;
while (g_ascii_isspace(*p)) p++;
return (char*) p;
}
@@ -122,10 +122,6 @@ unsigned long
get_boot_time(glibtop *server);
size_t
get_page_size(void);
gboolean
check_cpu_line(glibtop *server, const char *line, unsigned n);

View File

@@ -82,7 +82,7 @@ void
glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid)
{
char buffer [BUFSIZ], *p;
const size_t pagesize = get_page_size();
const size_t pagesize = getpagesize();
memset (buf, 0, sizeof (glibtop_proc_mem));

View File

@@ -53,7 +53,7 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
pid_t pid)
{
char buffer [BUFSIZ], *p;
const size_t pagesize = get_page_size();
const size_t pagesize = getpagesize();
memset (buf, 0, sizeof (glibtop_proc_segment));

View File

@@ -36,23 +36,34 @@ static glibtop_sysinfo sysinfo = { .flags = 0 };
static void
init_sysinfo (glibtop *server)
{
char buffer [65536];
char* buffer;
gchar ** processors;
if(G_LIKELY(sysinfo.flags)) return;
file_to_buffer(server, buffer, sizeof buffer, FILENAME);
if (!g_file_get_contents(FILENAME, &buffer, NULL, NULL)) {
glibtop_error_io_r(server, "g_file_get_contents(%s)", FILENAME);
}
/* cpuinfo records are seperated by a blank line */
processors = g_strsplit(buffer, "\n\n", 0);
for(sysinfo.ncpu = 0;
sysinfo.ncpu < GLIBTOP_NCPU && processors[sysinfo.ncpu] && *processors[sysinfo.ncpu];
sysinfo.ncpu++) {
g_free(buffer);
sysinfo.ncpu = 0;
for (char** this_proc = &processors[0]; *this_proc && **this_proc; this_proc++) {
if (sysinfo.ncpu >= GLIBTOP_NCPU) {
glibtop_warn_r(server, "Cannot deal with more than %d CPUs", GLIBTOP_NCPU);
break;
}
gchar **parts, **p;
if (g_strrstr (processors[sysinfo.ncpu], "processor" ) == NULL)
if (g_strrstr (*this_proc, "processor" ) == NULL) {
/* skip unknown paragraph */
continue;
}
glibtop_entry * const cpuinfo = &sysinfo.cpuinfo[sysinfo.ncpu];
cpuinfo->labels = g_ptr_array_new ();
@@ -64,7 +75,7 @@ init_sysinfo (glibtop *server)
g_free, g_free);
/* "<key> : <value>" */
parts = g_strsplit_set(processors[sysinfo.ncpu], ":\n", 0);
parts = g_strsplit_set(*this_proc, ":\n", 0);
for(p = parts; *p && *(p+1); p += 2) {
@@ -85,6 +96,7 @@ init_sysinfo (glibtop *server)
g_free(parts);
sysinfo.ncpu++;
}
g_strfreev(processors);