Ticket #1656: 0001-Removes-the-use-of-O_SYNC-unless-an-environment-vari.patch

File 0001-Removes-the-use-of-O_SYNC-unless-an-environment-vari.patch, 1.4 KB (added by quozl, 14 years ago)

alternate proposed implementation using environment variables

  • src/sugar/activity/activityfactory.py

    From ea10d500c100f9636a78c1d3c5279d5fc5a97a76 Mon Sep 17 00:00:00 2001
    From: James Cameron <quozl@laptop.org>
    Date: Thu, 11 Feb 2010 17:03:42 +1100
    Subject: [PATCH] Removes the use of O_SYNC unless an environment variable enables it
    
    With O_SYNC on open of log files, on systems with slow filesystem random
    write performance, there is random activity startup time.
    
    This additional use of an environment variable has been tested to cost
    no more than 2ms on OLPC XO-1.5 hardware.
    ---
     src/sugar/activity/activityfactory.py |    6 ++++--
     1 files changed, 4 insertions(+), 2 deletions(-)
    
    diff --git a/src/sugar/activity/activityfactory.py b/src/sugar/activity/activityfactory.py
    index eda7d9a..0c32598 100644
    a b def get_command(activity, activity_id=None, object_id=None, uri=None): 
    145145
    146146
    147147def open_log_file(activity):
     148    flags = os.O_EXCL | os.O_CREAT | os.O_WRONLY
     149    if os.environ.has_key('SUGAR_LOGS_SYNC'):
     150        flags = flags | os.O_SYNC
    148151    i = 1
    149152    while True:
    150153        path = env.get_logs_path('%s-%s.log' % (activity.get_bundle_id(), i))
    151154        try:
    152             fd = os.open(path, os.O_EXCL | os.O_CREAT \
    153                              | os.O_SYNC | os.O_WRONLY, 0644)
     155            fd = os.open(path, flags, 0644)
    154156            f = os.fdopen(fd, 'w', 0)
    155157            return (path, f)
    156158        except OSError, e: