! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
PATCH: sync discs before logging out
Status:
RESOLVED: FIXED
Severity:
enhancement
Product:
Xfce4-session
Component:
General

Comments

Description Auke Kok editbugs 2008-08-22 20:55:26 CEST
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
Comment 1 Auke Kok editbugs 2008-08-22 20:56:14 CEST
Created attachment 1785 
call sync(); before logging out or shutting down.
Comment 2 Auke Kok editbugs 2008-08-22 21:18:39 CEST
Comment from Benedikt: use _exit(); instead of exit();
Comment 3 Jean-François Wauthy editbugs 2008-08-23 16:19:21 CEST
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 ?
Comment 4 Auke Kok editbugs 2008-08-25 20:14:38 CEST
(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.
Comment 5 Brian J. Tarricone (not reading bugmail) 2008-10-01 07:07:04 CEST
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.
Comment 6 Brian J. Tarricone (not reading bugmail) 2008-10-01 07:08:46 CEST
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.
Comment 7 Auke Kok editbugs 2008-10-02 18:22:08 CEST
(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.
Comment 8 Brian J. Tarricone (not reading bugmail) 2008-10-07 09:00:16 CEST
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.

Bug #4313

Reported by:
Auke Kok
Reported on: 2008-08-22
Last modified on: 2009-07-14

People

Assignee:
Benedikt Meurer
CC List:
1 user

Version

Attachments

Additional information