Optimize performance of compact records

* Make compact records pure namedtuples (remove all dict behaviour)
* Add profiler decorator for dashboard requests performance analysis
* Introduced new parameter 'collect_profiler_stats' for file name
  where profile stats could be stored
* Fix py33 test failures

Change-Id: Ic5c900047a493541510974e9bc9c161f5606739e
This commit is contained in:
Ilya Shakhat
2014-06-30 19:56:23 +04:00
committed by Ilya Shakhat
parent 8ab2a069b4
commit a7eb7d024b
16 changed files with 134 additions and 112 deletions

View File

@@ -15,10 +15,8 @@
import collections
import os
import UserDict
import flask
import itertools
from oslo.config import cfg
import six
@@ -37,27 +35,8 @@ RECORD_FIELDS_FOR_AGGREGATE = ['record_id', 'primary_key', 'record_type',
'disagreement', 'value', 'status',
'blueprint_id']
_CompactRecordTuple = collections.namedtuple('CompactRecord',
RECORD_FIELDS_FOR_AGGREGATE)
class CompactRecord(_CompactRecordTuple, UserDict.DictMixin):
__slots__ = ()
def __getitem__(self, key):
if isinstance(key, str):
return getattr(self, key)
else:
return super(CompactRecord, self).__getitem__(key)
def keys(self):
return RECORD_FIELDS_FOR_AGGREGATE
def has_key(self, key):
return key in RECORD_FIELDS_FOR_AGGREGATE
def iteritems(self):
return itertools.izip(RECORD_FIELDS_FOR_AGGREGATE, self)
CompactRecord = collections.namedtuple('CompactRecord',
RECORD_FIELDS_FOR_AGGREGATE)
def compact_records(records):
@@ -70,7 +49,7 @@ def compact_records(records):
def extend_record(record):
runtime_storage_inst = get_vault()['runtime_storage']
return runtime_storage_inst.get_by_key(
runtime_storage_inst._get_record_name(record['record_id']))
runtime_storage_inst._get_record_name(record.record_id))
def get_vault():