When I was on 19.10 with GNOME 3.34 I could spawn command with GLib so many times without causing any lag to the GNOME shell or any app. But on 20.04 with GNOME 3.36.1 even a simple spawn command can create some lags for entire GNOME shell and even apps.
To show you how I do it, I've created this simple GNOME shell extension:
const Mainloop = imports.mainloop;
const GLib = imports.gi.GLib;
let timeout;
function init(){
}
function enable(){
timeout = Mainloop.timeout_add_seconds(1.0,() => {
var [ok, out, err, exit] = GLib.spawn_command_line_sync('pgrep Discord');
log('Discord is running');
return true;
});
}
function disable(){
Mainloop.source_remove(timeout);
}
Why is that lag happening? how can I fix the lag issue on this code?
pgrep
in Ubuntu 20.04 is extremely slow. The run time is linear to your stack limit (ulimit -S -s
to check), it can easily reach 30 sec even on fast machines. If you have no stack limit, anypgrep
call will fail:Bug reports are open for Ubuntu (Debian, Archlinux), but see no traffic. Please consider marking that you are affected too: https://bugs.launchpad.net/ubuntu/+source/procps/+bug/1874824
The bug is fixed in procps, but distributions are not picking it up ...