aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfusearchive.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/fusearchive.py b/fusearchive.py
index a1d737e..d5d82af 100755
--- a/fusearchive.py
+++ b/fusearchive.py
@@ -26,9 +26,11 @@ fuse.feature_assert('stateful_files', 'has_init')
magic_blocksize = 1024 * 128
magic_depth = 5
-debug_level = 3
+debug_level = 0
gzip_compress_level = 6
+magic_profiling = False
+
# Memory for dirty blocks, per file (1M)
dirty_size = 1024 * 1024 * 1;
# This is the number of actualy blocks in that size
@@ -41,6 +43,9 @@ def dmsg(level,message):
# This will write out a data block, it will return a key that can get this
# data back later
def save_chunk( chunk ):
+ if magic_profiling:
+ return( [ 0, 0 ] )
+
dmsg( 2, "Begin save_chunk" )
# Save this hash string, similar to the backuppc algo
digest = sha.new( chunk ).digest()
@@ -99,6 +104,9 @@ def save_chunk( chunk ):
# This will return a data block by key that was saved previously
def load_chunk( key ):
+ if magic_profiling:
+ return ''
+
( hash, seq ) = key
dmsg( 2, "Begin load_chunk" )
@@ -130,19 +138,23 @@ class FuseArchiveStream:
"""This just allows switching out writer classes easily"""
@staticmethod
def open( path, mode = 'r' ):
- #return gzip.open( path, mode, gzip_compress_level )
- return open( path, mode )
+ return gzip.open( path, mode, gzip_compress_level )
+ #return open( path, mode )
class FuseArchiveSerializer:
"""This lets us experiment with different main file serializers"""
@staticmethod
def dump( file, obj ):
out = FuseArchiveStream.open( file, "wb" )
- cPickle.dump( obj, out, -1 ) # new file format
+ if not magic_profiling:
+ cPickle.dump( obj, out, -1 ) # new file format
out.close()
@staticmethod
def load( file ):
+ if magic_profiling:
+ return { 'size': 0, 'chunks': 0, 'chunk_size': 0 }
+
inp = FuseArchiveStream.open( file, "rb" )
magic = cPickle.load( inp )
inp.close()
@@ -455,6 +467,9 @@ class FuseArchive(Fuse):
return data
def write(self, buf, offset):
+ if magic_profiling:
+ return len( buf )
+
dmsg( 3, "Writing to " + self.orig_path + " offset: " + str( offset ) )
index = int( offset / self.chunk_size )
@@ -670,7 +685,7 @@ if __name__ == '__main__':
# psyco.full()
#except ImportError:
# pass
- if False:
+ if True:
import hotshot
prof = hotshot.Profile( "fusearchive_stats" )
prof.runcall(main)