Skip to content

Commit 040b57c

Browse files
committed
Add idle_cycles Perf counter
1 parent 746a83e commit 040b57c

5 files changed

Lines changed: 15 additions & 0 deletions

File tree

include/Homa/Perf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ struct Stats {
3535
/// CPU time spent actively processing Homa messages in cycles.
3636
uint64_t active_cycles;
3737

38+
/// CPU time spent running Homa with no work to do in cycles.
39+
uint64_t idle_cycles;
40+
3841
/// Number of bytes sent by the transport.
3942
uint64_t tx_bytes;
4043

src/Perf.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ struct Counters {
7171
*/
7272
Counters()
7373
: active_cycles(0)
74+
, idle_cycles(0)
7475
, tx_bytes(0)
7576
, rx_bytes(0)
7677
, tx_data_pkts(0)
@@ -102,6 +103,7 @@ struct Counters {
102103
void add(const Counters* other)
103104
{
104105
active_cycles.add(other->active_cycles);
106+
idle_cycles.add(other->idle_cycles);
105107
tx_bytes.add(other->tx_bytes);
106108
rx_bytes.add(other->rx_bytes);
107109
tx_data_pkts.add(other->tx_data_pkts);
@@ -128,6 +130,7 @@ struct Counters {
128130
void dumpStats(Stats* stats)
129131
{
130132
stats->active_cycles = active_cycles.get();
133+
stats->idle_cycles = idle_cycles.get();
131134
stats->tx_bytes = tx_bytes.get();
132135
stats->rx_bytes = rx_bytes.get();
133136
stats->tx_data_pkts = tx_data_pkts.get();
@@ -151,6 +154,9 @@ struct Counters {
151154
/// CPU time spent actively processing Homa messages in cycles.
152155
Stat<uint64_t> active_cycles;
153156

157+
/// CPU time spent running Homa with no work to do in cycles.
158+
Stat<uint64_t> idle_cycles;
159+
154160
/// Number of bytes sent by the transport.
155161
Stat<uint64_t> tx_bytes;
156162

src/Receiver.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,8 @@ Receiver::trySendGrants()
786786
uint64_t elapsed_cycles = PerfUtils::Cycles::rdtsc() - start_tsc;
787787
if (!idle) {
788788
Perf::counters.active_cycles.add(elapsed_cycles);
789+
} else {
790+
Perf::counters.idle_cycles.add(elapsed_cycles);
789791
}
790792
}
791793

src/Sender.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,8 @@ Sender::trySend()
10351035
uint64_t elapsed_cycles = PerfUtils::Cycles::rdtsc() - start_tsc;
10361036
if (!idle) {
10371037
Perf::counters.active_cycles.add(elapsed_cycles);
1038+
} else {
1039+
Perf::counters.idle_cycles.add(elapsed_cycles);
10381040
}
10391041
}
10401042

src/TransportImpl.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ TransportImpl::processPackets()
144144
uint64_t elapsed_cycles = PerfUtils::Cycles::rdtsc() - start_tsc;
145145
if (!idle) {
146146
Perf::counters.active_cycles.add(elapsed_cycles);
147+
} else {
148+
Perf::counters.idle_cycles.add(elapsed_cycles);
147149
}
148150
}
149151

0 commit comments

Comments
 (0)