summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2010-04-20 09:06:57 +1000
committerAndrew Gerrand <adg@golang.org>2010-04-20 09:06:57 +1000
commit5b8efb07ea9b77daa2cb81d361da2a2635f52c12 (patch)
tree2de250888dfb5f60bb3c968f32f05b37421b3ace
parent9e9230327b4b6da0356a5d1ee9a80b77618ec718 (diff)
downloadgolang-5b8efb07ea9b77daa2cb81d361da2a2635f52c12.tar.gz
godashboard: bz2 compress logs in data store
This results in a 10-20x size reduction per record. (from ~150kb to ~10kb) This revision has been pushed live, as I'm in the process of converting Log records to bz2-compresed CompressedLog records. I would have waited but we're running seriously low on space and it seemed like a sane (and reversible) move. R=rsc CC=golang-dev http://codereview.appspot.com/872048
-rw-r--r--misc/dashboard/godashboard/gobuild.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/misc/dashboard/godashboard/gobuild.py b/misc/dashboard/godashboard/gobuild.py
index 58c7cd196..f892eeba1 100644
--- a/misc/dashboard/godashboard/gobuild.py
+++ b/misc/dashboard/godashboard/gobuild.py
@@ -25,6 +25,7 @@ import os
import re
import struct
import time
+import bz2
# local imports
import key
@@ -70,9 +71,10 @@ class Cache(db.Model):
data = db.BlobProperty()
expire = db.IntegerProperty()
-# A Log contains the textual build log of a failed build. The key name is the
-# hex digest of the SHA256 hash of the contents.
-class Log(db.Model):
+# A CompressedLog contains the textual build log of a failed build.
+# The key name is the hex digest of the SHA256 hash of the contents.
+# The contents is bz2 compressed.
+class CompressedLog(db.Model):
log = db.BlobProperty()
# For each builder, we store the last revision that it built. So, if it
@@ -241,12 +243,13 @@ class LogHandler(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
hash = self.request.path[5:]
- l = Log.get_by_key_name(hash)
+ l = CompressedLog.get_by_key_name(hash)
if l is None:
self.response.set_status(404)
return
+ log = bz2.decompress(l.log)
self.response.set_status(200)
- self.response.out.write(l.log)
+ self.response.out.write(log)
# Init creates the commit with id 0. Since this commit doesn't have a parent,
# it cannot be created by Build.
@@ -288,8 +291,8 @@ class Build(webapp.RequestHandler):
loghash = ''
if len(log) > 0:
loghash = hashlib.sha256(log).hexdigest()
- l = Log(key_name = loghash)
- l.log = log
+ l = CompressedLog(key_name=loghash)
+ l.log = bz2.compress(log)
l.put()
date = parseDate(self.request.get('date'))