aboutsummaryrefslogtreecommitdiff
path: root/piglit-run.py
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2011-08-03 12:09:53 -0700
committerPaul Berry <stereotype441@gmail.com>2011-08-05 13:32:44 -0700
commitfcaa47b28ba46f692b1ff05ff09b14a67c766a88 (patch)
treecec1b605a173fd5fb72954f57f8f9f6a949502a3 /piglit-run.py
parentb4274e7581a779b398f0b7588e38f672b2419e6d (diff)
downloadpiglit-fcaa47b28ba46f692b1ff05ff09b14a67c766a88.tar.gz
piglit-run.py: Remove SyncFileWriter as it's not necessary with JSON.
Prior to JSON-ification, piglit wrote each test's results in a single call, and SyncFileWriter ensured that these were done sequentially. Now, the JSON writer internally handles locking and concurrency, so SyncFileWriter is unnecessary. Furthermore, outputting a single test's results now takes multiple write calls, so SyncFileWriter wouldn't actually guard against concurrency issues anyway. This also removes a fsync() call on each write, fixing a major performance regression on machines with non-SSDs. Prior to the JSON work, since each test mapped to a single write call, we were doing one fsync() per test case. With JSON, we started doing many more fsyncs. But none of them are actually necessary, so just scrap them all. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=39737 Cc: Chad Versace <chad@chad-versace.us> Cc: Ian Romanick <idr@freedesktop.org> Cc: Dave Airlie <airlied@gmail.com> Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Chad Versace <chad@chad-versace.us> Tested-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'piglit-run.py')
-rwxr-xr-xpiglit-run.py34
1 files changed, 2 insertions, 32 deletions
diff --git a/piglit-run.py b/piglit-run.py
index bbc38073..c5f5a4a8 100755
--- a/piglit-run.py
+++ b/piglit-run.py
@@ -32,37 +32,6 @@ import traceback
import framework.core as core
from framework.threads import synchronized_self
-class SyncFileWriter:
- '''
- Using the 'print' syntax to write to an instance of this class
- may have unexpected results in a multithreaded program. For example:
- print >> file, "a", "b", "c"
- will call write() to write "a", then call write() to write "b", and so on...
- This type of execution allows for another thread to call write() before
- the original statement completes its execution.
- To avoid this behavior, call file.write() explicitly. For example:
- file.write("a", "b", "c", "\n")
- will ensure that "a b c" gets written to the file before any other thread
- is given write access.
- '''
- def __init__(self, filename):
- self.file = open(filename, 'w')
-
- @synchronized_self
- def write(self, *args):
- [self.file.write(str(a)) for a in args]
- self.file.flush()
- os.fsync(self.file.fileno())
-
- @synchronized_self
- def writeLine(self, *args):
- self.write(*args)
- self.write('\n')
-
- @synchronized_self
- def close(self):
- self.file.close()
-
#############################################################################
##### Main program
#############################################################################
@@ -149,7 +118,8 @@ def main():
# Begin json.
result_filepath = os.path.join(resultsDir, 'main')
- json_writer = core.JSONWriter(SyncFileWriter(result_filepath))
+ result_file = open(result_filepath, 'w')
+ json_writer = core.JSONWriter(result_file)
json_writer.open_dict()
json_writer.write_dict_item('name', results.name)