8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 20:43:02 +01:00

Optimize run-time stats collection a bit

This commit is contained in:
hvlad 2016-06-23 00:30:47 +03:00
parent 79542dfe66
commit b5d150e56a
2 changed files with 18 additions and 9 deletions

View File

@ -33,19 +33,15 @@ namespace Jrd {
GlobalPtr<RuntimeStatistics> RuntimeStatistics::dummy;
void RuntimeStatistics::bumpRelValue(const StatType index, SLONG relation_id, SINT64 delta)
void RuntimeStatistics::findAndBumpRelValue(const StatType index, SLONG relation_id, SINT64 delta)
{
fb_assert(index >= 0);
++relChgNumber;
FB_SIZE_T pos;
if (rel_counts.find(relation_id, pos))
rel_counts[pos].bumpCounter(index, delta);
if (rel_counts.find(relation_id, rel_last_pos))
rel_counts[rel_last_pos].bumpCounter(index, delta);
else
{
RelationCounts counts(relation_id);
counts.bumpCounter(index, delta);
rel_counts.add(counts);
rel_counts.insert(rel_last_pos, counts);
}
}

View File

@ -191,6 +191,7 @@ public:
{
memset(values, 0, sizeof values);
rel_counts.clear();
rel_last_pos = (FB_SIZE_T) ~0;
allChgNumber = 0;
relChgNumber = 0;
}
@ -212,7 +213,18 @@ public:
return rel_counts.find(relation_id, pos) ? rel_counts[pos].getCounter(index) : 0;
}
void bumpRelValue(const StatType index, SLONG relation_id, SINT64 delta = 1);
void bumpRelValue(const StatType index, SLONG relation_id, SINT64 delta = 1)
{
fb_assert(index >= 0);
++relChgNumber;
if (rel_last_pos != (FB_SIZE_T)~0 && rel_counts[rel_last_pos].getRelationId() == relation_id)
rel_counts[rel_last_pos].bumpCounter(index, delta);
else
findAndBumpRelValue(index, relation_id, delta);
}
void findAndBumpRelValue(const StatType index, SLONG relation_id, SINT64 delta);
// Calculate difference between counts stored in this object and current
// counts of given request. Counts stored in object are destroyed.
@ -333,6 +345,7 @@ private:
SINT64 values[TOTAL_ITEMS];
RelCounters rel_counts;
FB_SIZE_T rel_last_pos;
// These two numbers are used in adjust() and assign() methods as "generation"
// values in order to avoid costly operations when two instances of RuntimeStatistics