Skip to content

Commit da7d180

Browse files
authored
More performance optimizations (LLNL#470)
1 parent 942e832 commit da7d180

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

include/caliper/common/Entry.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Entry
4242
{ }
4343

4444
Entry(Node* node)
45-
: m_node(node)
45+
: m_node(node), m_value(node->data())
4646
{ }
4747

4848
Entry(const Attribute& attr, const Variant& val)
@@ -72,10 +72,7 @@ class Entry
7272

7373
/// \brief Return top-level data value of this entry
7474
Variant value() const {
75-
if (!m_node)
76-
return Variant();
77-
78-
return Attribute::is_attribute(m_node) ? m_value : m_node->data();
75+
return m_value;
7976
}
8077

8178
/// \brief Extract data value for attribute \a attr_id from this entry

src/caliper/Blackboard.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ Blackboard::add(cali_id_t key, const Entry& value, bool include_in_snapshots)
4545
}
4646

4747
hashtable[I].key = key;
48-
hashtable[I].is_occupied = true;
4948
hashtable[I].value = value;
5049

5150
if (include_in_snapshots) {
@@ -81,14 +80,14 @@ Blackboard::del(cali_id_t key)
8180

8281
size_t I = find_existing_entry(key);
8382

84-
if (!hashtable[I].is_occupied || hashtable[I].key != key)
83+
if (hashtable[I].key != key)
8584
return;
8685

8786
{
8887
size_t j = I;
8988
while (true) {
9089
j = (j+1) % Nmax;
91-
if (!hashtable[j].is_occupied)
90+
if (hashtable[j].key == CALI_INV_ID)
9291
break;
9392
size_t k = hashtable[j].key % Nmax;
9493
if ((j > I && (k <= I || k > j)) || (j < I && (k <= I && k > j))) {
@@ -99,7 +98,6 @@ Blackboard::del(cali_id_t key)
9998
}
10099

101100
hashtable[I].key = CALI_INV_ID;
102-
hashtable[I].is_occupied = false;
103101
hashtable[I].value = Entry();
104102

105103
--num_entries;

src/caliper/Blackboard.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class Blackboard {
2929

3030
struct blackboard_entry_t {
3131
cali_id_t key { CALI_INV_ID };
32-
bool is_occupied { false };
3332
Entry value { };
3433
};
3534

@@ -55,7 +54,7 @@ class Blackboard {
5554
inline size_t find_existing_entry(cali_id_t key) const {
5655
size_t I = key % Nmax;
5756

58-
while (hashtable[I].is_occupied && hashtable[I].key != key)
57+
while (hashtable[I].key != key && hashtable[I].key != CALI_INV_ID)
5958
I = (I+1) % Nmax;
6059

6160
return I;
@@ -64,7 +63,7 @@ class Blackboard {
6463
inline size_t find_free_slot(cali_id_t key) const {
6564
size_t I = key % Nmax;
6665

67-
while (hashtable[I].is_occupied)
66+
while (hashtable[I].key != CALI_INV_ID)
6867
I = (I+1) % Nmax;
6968

7069
return I;
@@ -91,7 +90,7 @@ class Blackboard {
9190

9291
size_t I = find_existing_entry(key);
9392

94-
if (!hashtable[I].is_occupied || hashtable[I].key != key)
93+
if (hashtable[I].key != key)
9594
return Entry();
9695

9796
return hashtable[I].value;

0 commit comments

Comments
 (0)