From 67e71c9ff4d8ed55341c99b2cc278b8efa294e89 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Fri, 30 May 2008 18:51:27 +0000 Subject: Add -O3 mode to importscript to relax reason deduplication process (Results in 1000X speedup for large databases) Because it breaks common reason display in the reporting system, this is non-default behavior git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4639 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Reports/importscript.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/lib/Server/Reports/importscript.py') diff --git a/src/lib/Server/Reports/importscript.py b/src/lib/Server/Reports/importscript.py index 83df3ac94..a37f64214 100755 --- a/src/lib/Server/Reports/importscript.py +++ b/src/lib/Server/Reports/importscript.py @@ -180,7 +180,11 @@ if __name__ == '__main__': for (xpath, obj, tablename) in pattern: for x in statistics.findall(xpath): kargs = build_reason_kwargs(x) - rls = Reason.objects.filter(**kargs) + if '-O3' not in sys.argv: + rls = Reason.objects.filter(**kargs) + else: + rls = [] + if rls: rr = rls[0] if verbose: @@ -190,9 +194,13 @@ if __name__ == '__main__': rr.save() if verbose: print "Created reason: %s" % rr.id - links = obj.objects.filter(name=x.get('name'), - kind=x.tag, - reason=rr) + if '-O3' not in sys.argv: + links = obj.objects.filter(name=x.get('name'), + kind=x.tag, + reason=rr) + else: + links = [] + if links: item_id = links[0].id if verbose: @@ -204,7 +212,7 @@ if __name__ == '__main__': newitem.save() item_id = newitem.id if verbose: - print "Bad item INSERTED having reason id %s and ID %s" % (rr.id, item_id) + print "%s item INSERTED having reason id %s and ID %s" % (xpath, rr.id, item_id) try: cursor.execute("INSERT INTO "+tablename+"_interactions VALUES (NULL, %s, %s);", [item_id, current_interaction_id]) @@ -213,7 +221,11 @@ if __name__ == '__main__': for times in statistics.findall('OpStamps'): for metric, value in times.items(): - mmatch = Performance.objects.filter(metric=metric, value=value) + if '-O3' not in sys.argv: + mmatch = Performance.objects.filter(metric=metric, value=value) + else: + mmatch = [] + if mmatch: item_id = mmatch[0].id else: -- cgit v1.2.3-1-g7c22