After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 641992 - gnome-session-is-accelerated too slow
gnome-session-is-accelerated too slow
Status: RESOLVED FIXED
Product: gnome-session
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Session Maintainers
Session Maintainers
[gnome3-important]
Depends on:
Blocks:
 
 
Reported: 2011-02-10 00:42 UTC by Matthias Clasen
Modified: 2011-03-14 13:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Increase session runnable helper timeout (1.16 KB, patch)
2011-02-16 19:29 UTC, Colin Walters
rejected Details | Review
Add gnome-session-check-accelerated which sets X property (7.04 KB, patch)
2011-02-28 21:25 UTC, Colin Walters
committed Details | Review
avoid double checking (3.13 KB, patch)
2011-03-11 23:49 UTC, Matthias Clasen
none Details | Review
avoid double checking (3.64 KB, patch)
2011-03-12 22:20 UTC, Matthias Clasen
reviewed Details | Review
avoid double checking (4.39 KB, patch)
2011-03-13 23:24 UTC, Matthias Clasen
none Details | Review
avoid double checking (4.35 KB, patch)
2011-03-13 23:25 UTC, Matthias Clasen
accepted-commit_now Details | Review

Description Matthias Clasen 2011-02-10 00:42:30 UTC
Entirely due to mesa/GL suckiness, but on a cold cache, it takes 1.3s on my system. That is way beyond the 500ms which gnome-session gives it, and causes me to end up in the fallback session sometimes, although my system is perfectly capable of running gnome-shell.
Comment 1 William Jon McCann 2011-02-10 00:54:32 UTC
Do we really need to run this each time?
Comment 2 Vincent Untz 2011-02-13 12:08:11 UTC
Jon: what could we do instead? How to handle people changing hardware, or updated drivers, etc. I'm totally willing to handle this another way :-)

I guess, as a workaround, we can change the timeout... It's still annoying, though, since it makes login much slower. Maybe we could have gdm run the test and pass the result to gnome-session via an environment variable?
Comment 3 Matthias Clasen 2011-02-14 15:11:05 UTC
we could just rely on the result from previous runs, and have a way in control-center to force a re-run, maybe.
Comment 4 Colin Walters 2011-02-16 19:29:28 UTC
Created attachment 181040 [details] [review]
Increase session runnable helper timeout

Half a second is *way* to short.
Comment 5 Vincent Untz 2011-02-16 23:06:48 UTC
Comment on attachment 181040 [details] [review]
Increase session runnable helper timeout

30 seconds is a no-go. Keep in mind that this completely blocks the login, so a long delay is more broken than getting to the fallback mode.

I'm potentially willing to go up to 2s, though.
Comment 6 Matthias Clasen 2011-02-17 16:23:07 UTC
After a second or so, you probably want to start showing some 'still working...' animation, else users will start hitting the powerbutton...
Comment 7 William Jon McCann 2011-02-17 16:30:02 UTC
Surely the system capabilities don't change between boot and session login, right?  Seems a bit odd to do this every login.  No one changes graphics hardware while the system is running and if they do then we should know that.

Probing hardware capabilities is something that would be better done at boot I think.  Eventually GDM will need to know this anyway.
Comment 8 Adam Williamson 2011-02-23 16:42:48 UTC
numbers: we have 9 out of 71 testers at the Nouveau test day reporting this issue - https://fedoraproject.org/wiki/Test_Day:2011-02-22_Nouveau . So far with Radeon (happening today), 5 out of 30 testers report this issue.

Downstream bug - https://bugzilla.redhat.com/show_bug.cgi?id=679326 .
Comment 9 John Reiser 2011-02-23 20:30:08 UTC
(In reply to comment #7)
> Surely the system capabilities don't change between boot and session login,
> right?

There can be more than one DISPLAY (in the X11 sense) on a box, more than one display (in the hardware sense), and the capabilities can vary widely.  For instance, there are "VGA attached via USB2.0" products (such as the eVGA brand UV Plus products, and others) which can stream HDTV but are very limited in some other ways.

But there should be nothing to preclude GDM from determining this session property well before "login:".
Comment 10 Colin Walters 2011-02-28 00:15:39 UTC
(In reply to comment #5)
> (From update of attachment 181040 [details] [review])
> 30 seconds is a no-go.

Under what failure conditions will it take the full 30 seconds though?  If we don't know of any, then it seems far better to be reliable here than to pick a different arbitrary and also way too short timeout.
Comment 11 John Reiser 2011-02-28 03:29:19 UTC
Regardless of how long it may take gnome-session-is-accelerated to produce an answer, gdm can do things to avoid the longest delays.  Such as: pre-fetch gnome-session-is-accelerated and its executables and libraries (just read() them as files and discard the buffers), and do this in parallel with invoking gdm, before gdm actually invokes gnome-session-is-accelerated as a sub-task and waits for the result.  In the case of a LiveCD or LiveDVD with actual rotating optical media, the pre-fetch is notably effective, particularly because it overlaps the reading of gnome-session-is-accelerated with the time it takes the human to activate the "login:" mechanism (click a button or type <Enter>, or wait for a multi-second timeout to expire.)
Comment 12 Colin Walters 2011-02-28 14:35:51 UTC
I will work on a GDM patch.  But in the meantime, it makes no sense to leave the timeout in gnome-session as half of a second.
Comment 13 Vincent Untz 2011-02-28 14:52:07 UTC
Colin: feel free to change it to 2s or 3s. From what I've read, this should be enough.
Comment 14 Ray Strode [halfline] 2011-02-28 15:01:43 UTC
(In reply to comment #11)
> Such as: pre-fetch
> gnome-session-is-accelerated and its executables and libraries (just read()
> them as files and discard the buffers)
Isn't this what readahead is already doing?  It seems like either readahead needs to be fixed, or the assumption that this is where the bottleneck is, is wrong (in which case mesa needs to be profiled to figure out why it's so slow to load
Comment 15 Colin Walters 2011-02-28 15:35:32 UTC
(In reply to comment #13)
> Colin: feel free to change it to 2s or 3s. From what I've read, this should be
> enough.

Done; even 3 seconds still feels potentially too short to me if say you're using a multiseat system and have concurrent logins, or the equivalent of "yum update" happens to be running, or NFS root scenarios, etc.
Comment 16 Colin Walters 2011-02-28 21:25:57 UTC
Created attachment 182136 [details] [review]
Add gnome-session-check-accelerated which sets X property

It would make sense to run gnome-session-is-accelerated in
GDM, in parallel with the user is typing their password.  A
good way to pass that knowledge through to gnome-session
so it knows it can avoid repeating the same check is via
an X property.

So this new tool "gnome-session-check-accelerated" runs
"gnome-session-is-accelerated" and stores that status as
an X property.  gnome-session will then itself run it
again, but it should pick up the property and reuse that
value.
Comment 17 Matthias Clasen 2011-03-01 00:01:34 UTC
I agree with the principle, but why do you need to make this a separate tool ?
I guess this to handle cases where the gl-using process is crashing or otherwise going off into the weeds ?
Comment 18 Colin Walters 2011-03-01 16:52:02 UTC
(In reply to comment #17)
> I agree with the principle, but why do you need to make this a separate tool ?
> I guess this to handle cases where the gl-using process is crashing or
> otherwise going off into the weeds ?

Right, gnome-session-is-accelerated isn't in the gnome-session process for the reasons outlined in its source.

gnome-session-*check*-accelerated is a separate tool so it can be run by both gnome-session and gdm conveniently.
Comment 19 Vincent Untz 2011-03-01 17:32:15 UTC
I'm assuming that using GTK+/GDK in the helper tool has no major impact on the execution time, but I've no idea about that. If it has an impact, it looks rather easy to do pure X.

One thing we might want to handle: if gnome-session (or gdm) kills gnome-session-check-accelerated because it takes too long, then we should make g-s-check-accelerated kill g-s-is-accelerated too.

Btw, exit_1_message() isn't used anywhere.

I also find the two names a bit confusing since it's unclear which one does what. Maybe we should rename g-s-is-accelerated to something else, like g-s-check-accelerated-gl.
Comment 20 Ray Strode [halfline] 2011-03-02 14:49:53 UTC
Why two tools at all? Why not just have gnome-session-is-accelerated set the property in its exit path and exit before really starting if it's already set?
Comment 21 Ray Strode [halfline] 2011-03-02 14:54:26 UTC
if we're worried about mesa hanging, we could fork a child or whatever.  it's just really bizarre to have two tiny programs both with essentially the same name
Comment 22 André Klapper 2011-03-03 21:16:49 UTC
[Removing GNOME3.0 target as decided in release-team meeting on March 03, 2011.
This report has an "important" categorisation for GNOME3.0 but is not considered a hard blocker. For querying use the corresponding whiteboard entry added.]
Comment 23 Colin Walters 2011-03-03 21:49:06 UTC
(In reply to comment #20)
> Why two tools at all? Why not just have gnome-session-is-accelerated set the
> property in its exit path and exit before really starting if it's already set?

I already answered that above.  I'll attach a new patch which renames is-accelerated to check-accelerated-helper to make their relationship clearer from just the names (but I already wrote comments in the source).
Comment 24 Ray Strode [halfline] 2011-03-03 22:16:22 UTC
Well, you wrote

> gnome-session-*check*-accelerated is a separate tool so it can be run by both
> gnome-session and gdm conveniently.

which is an argument for having a separate tool, but we already have a separate tool...  So, I followed up with, why two tools?

If the concern is the first tool is going to hang (is that the concern?), then why do you spawn it synchronously from the second tool?
Comment 25 Colin Walters 2011-03-03 22:29:40 UTC
(In reply to comment #24)
> Well, you wrote
> 
> > gnome-session-*check*-accelerated is a separate tool so it can be run by both
> > gnome-session and gdm conveniently.
> 
> which is an argument for having a separate tool, but we already have a separate
> tool...  So, I followed up with, why two tools?
> 
> If the concern is the first tool is going to hang (is that the concern?), then
> why do you spawn it synchronously from the second tool?

https://bugzilla.gnome.org/show_bug.cgi?id=641992#c18

"gnome-session-*check*-accelerated is a separate tool so it can be run by both
gnome-session and gdm conveniently."
Comment 26 Vincent Untz 2011-03-06 22:53:52 UTC
Colin: I believe we should still handle the "process gets terminated" case I talked about in comment 19.

(To address Ray's concerns, we could also have all the code in the same process, and do a fork/exec before doing the gl code -- not sure it's worth it, though)
Comment 27 Matthias Clasen 2011-03-11 23:49:56 UTC
Created attachment 183183 [details] [review]
avoid double checking

Here is a patch that implements a strategy to avoid duplicating the gl checks when gnome-session spawns the runnablehelper before the one spawned by gdm is done:

Before doing the gl check, set the property to '2' to indicate 'test in progress'.
When we see a '2' upon initially inspecting the property, we lay low and wait for a propertynotify (for up to 5 seconds). When it arrives, we reread the property and return the newly cached value.
Comment 28 Matthias Clasen 2011-03-12 04:19:23 UTC
Ray has added an autostart file for gnome-session-check-accelerated to gdm now.
Comment 29 Matthias Clasen 2011-03-12 22:20:17 UTC
Created attachment 183245 [details] [review]
avoid double checking

Slightly improved patch.

1) it actually compiles

2) only wait once for a property change; if we don't get one, just go ahead and to the check ourselves
Comment 30 Colin Walters 2011-03-13 17:17:53 UTC
Review of attachment 183245 [details] [review]:

Please use git formatted commits; the commit message is extremely useful for reviewers, since it helps describe your intention.

::: tools/gnome-session-check-accelerated.c
@@ +82,3 @@
+        XSelectInput (GDK_DISPLAY_XDISPLAY (display), rootwin, PropertyChangeMask);
+        gdk_window_add_filter (root, filter, NULL);
+        return GDK_FILTER_CONTINUE;

Can you call it "on_property_notify_timeout"?

@@ +95,3 @@
         int estatus;
+#undef LIBEXECDIR
+#define LIBEXECDIR "."

Uhh...what?

@@ +133,3 @@
+
+                        }
+                                if (wait_for_property_notify ())

} else {
Comment 31 Matthias Clasen 2011-03-13 23:24:32 UTC
Created attachment 183306 [details] [review]
avoid double checking
Comment 32 Matthias Clasen 2011-03-13 23:25:45 UTC
Created attachment 183308 [details] [review]
avoid double checking
Comment 33 Vincent Untz 2011-03-14 11:14:18 UTC
Comment on attachment 183308 [details] [review]
avoid double checking

Hrm, splinter doesn't work for this patch. So old-style review.

It looks good. I have a few suggestions for small changes below. Please commit!

>+static GdkFilterReturn
>+property_notify_filter (GdkXEvent *xevent,
>+                        GdkEvent  *event,
>+                        gpointer   data)
>+{
>+        XPropertyEvent *ev = xevent;
>+
>+        if (ev->type == PropertyNotify && ev->atom == is_accelerated_atom) {
>+                property_changed = TRUE;
>+                gtk_main_quit ();
>+        }

Should we also check that the property is changed to 0 or 1, or are we fine assuming that a change is always something valid anyway?

>+        XSelectInput (GDK_DISPLAY_XDISPLAY (display), rootwin, PropertyChangeMask);
>+        gdk_window_add_filter (root, property_notify_filter, NULL);

I'd probably pass property_changed as user_data here and avoid a global variable. But I'll leave this up to you.

>+        g_timeout_add (5000, on_property_notify_timeout, NULL);

Can we put a define at the top for 5000? That's the kind of value I prefer to easily find at the top of a file.

>+                        if (*is_accelerated_ptr == 2) {

Maybe also use a define for 2. Will make it look less random when reading the code.

>+                                /* Test in progress, wait */
>+                                if (wait_for_property_notify ())
>+                                        goto read;
>+                                /* else fall through and do the check ourselves */
>+
>+                        }
>+                        else {

Nitpick: merge on one line.
Comment 34 Matthias Clasen 2011-03-14 13:23:58 UTC
Pushed with those corrections, thanks