User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008072914 Firefox/3.0 Build Identifier: We can speedup shutdown significantly by firing an asynchronous `sync();` call when the user starts the shutdown dialog. Before the user has even located the `shutdown` or `reboot` button with the mouse cursor we will have been able to sync all (or most) the dirty data back to discs. On systems with SSD's syncing discs is expensive as write speeds can be slow. therefore it's beneficial to sync as early as wel can. This patch syncs in the background before the shutdown/logout/reboot window is painted. If the user shuts down or reboots we get a huge shutdown time reduction since we will hardly have dirty data by the time that we need to umount. If the user only logs out we take a small hit. On desktop systems the sync() is hardly painful. On netbooks we are unlikely to ever log out since users use single-user desktops. The net gain from the patch can be reduced shutdown time by as much as 2-3 seconds. Reproducible: Always
Created attachment 1785 call sync(); before logging out or shutting down.
Comment from Benedikt: use _exit(); instead of exit();
In the, unlikely but possible, case of the sync taking a longer time to sync than the user to click on the button, shouldn't you add a waitpid before the end of parent process ?
(In reply to comment #3) > In the, unlikely but possible, case of the sync taking a longer time to sync > than the user to click on the button, shouldn't you add a waitpid before the > end of parent process ? > no, since waiting would mean wasting useful time in which the system could perform CPU-bound tasks.
My only issue with this is that if an application has unsaved data and requests to interact with the user before the SM shuts down the session, it's possible the user will be stuck with a poor experience if the disk is thrashing while an app is trying to present a dialog box to the user. So I'm thinking we should only start sync() when the SM has actually gotten SaveYourselfComplete and InteractDone messages from *all* clients. Yeah, this slows things down, but speed isn't everything.
Oh, hmm, you've put this into xfce4-session-logout, I see. This'll have to be done in xfce4-session itself to work within the limitations I suggested.
(In reply to comment #6) > Oh, hmm, you've put this into xfce4-session-logout, I see. This'll have to be > done in xfce4-session itself to work within the limitations I suggested. ioprio_set() should fix that, as it will drop the process that runs sync() to IDLE and thus not hold up any other task at all (lowest IO priority). This is exactly what we do with readahead on the fast boot systems, and works well caveat: only works on linux, so we should probably enable this code entirely for linux only for now.
Ok, implemented something like this in r28076. It starts sync()ing at the beginning of shutdown if we have ioprio_set(), and otherwise falls back to sync()ing right before app quit as it used to.