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): |
145 | 145 | |
146 | 146 | |
147 | 147 | def 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 |
148 | 151 | i = 1 |
149 | 152 | while True: |
150 | 153 | path = env.get_logs_path('%s-%s.log' % (activity.get_bundle_id(), i)) |
151 | 154 | 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) |
154 | 156 | f = os.fdopen(fd, 'w', 0) |
155 | 157 | return (path, f) |
156 | 158 | except OSError, e: |