[PATCH] performance increase using mode cache
Dennis Gregorovic <[email protected]>
| Newsgroups | gmane.linux.rpm.metadata |
|---|---|
| Message-ID | <[email protected]> |
I've started profiling createrepo. The first performance improvement I've come implemented is pretty straightforward. Instead of calling stat.S_ISDIR(mode) on every file, use a cache. On my test machine, this saves about 3/4 of a second per 100 files. The patch is attached. Cheers -- Dennis _______________________________________________ Rpm-metadata mailing list [email protected] https://lists.dulug.duke.edu/mailman/listinfo/rpm-metadata
dumpMetaData-mode_cache.patch
(text/x-patch, 880 B)
--- dumpMetadata.py.orig 2005-11-23 15:12:57.000000000 -0500
+++ dumpMetadata.py 2005-11-23 15:05:54.000000000 -0500
@@ -212,6 +212,9 @@
"""each rpm is one object, you pass it an rpm file
it opens the file, and pulls the information out in bite-sized chunks :)
"""
+
+ mode_cache = {}
+
def __init__(self, ts, basedir, filename, options):
try:
stats = os.stat(os.path.join(basedir, filename))
@@ -451,7 +454,9 @@
if mode is None or mode == '':
self.filenames.append(file)
continue
- if stat.S_ISDIR(mode):
+ if not RpmMetaData.mode_cache.has_key(mode):
+ RpmMetaData.mode_cache[mode] = stat.S_ISDIR(mode)
+ if RpmMetaData.mode_cache[mode]:
self.dirnames.append(file)
else:
if flag is None: