Skip to content
This repository was archived by the owner on Jun 27, 2018. It is now read-only.

Commit cfae93a

Browse files
committed
additional diagnostics on the breakup of returned query counters
1 parent 59d110b commit cfae93a

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

pyretic/core/language.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,12 @@ def __init__(self):
709709
self.byte_count_table = 0
710710
self.packet_count_persistent = 0
711711
self.byte_count_persistent = 0
712+
self.packet_count_persistent_apply = 0
713+
self.packet_count_persistent_removed = 0
714+
self.packet_count_persistent_existing = 0
715+
self.byte_count_persistent_apply = 0
716+
self.byte_count_persistent_removed = 0
717+
self.byte_count_persistent_existing = 0
712718
self.in_update_cv = Condition()
713719
self.in_update = False
714720
self.new_bucket = True
@@ -744,6 +750,8 @@ def apply(self):
744750
+ ' Packet is:\n' + repr(pkt))
745751
self.packet_count_persistent += 1
746752
self.byte_count_persistent += pkt['payload_len']
753+
self.packet_count_persistent_apply += 1
754+
self.byte_count_persistent_apply += pkt['payload_len']
747755
self.bucket.clear()
748756
self.log.debug('In bucket ' + str(id(self)) + ' apply(): ' +
749757
'persistent packet count is ' +
@@ -881,6 +889,8 @@ def handle_flow_removed(self, match, priority, version, flow_stat):
881889
packet_count) ) )
882890
self.packet_count_persistent += packet_count
883891
self.byte_count_persistent += byte_count
892+
self.packet_count_persistent_removed += packet_count
893+
self.byte_count_persistent_removed += byte_count
884894
# Note that there is no else action. We just forget
885895
# that this rule was ever associated with the bucket
886896
# if we get a "flow removed" message before we got
@@ -1034,6 +1044,10 @@ def stat_in_bucket(flow_stat, s):
10341044
' %d') % id(self))
10351045
self.packet_count_persistent -= extracted_pkts
10361046
self.byte_count_persistent -= extracted_bytes
1047+
self.packet_count_persistent_existing += (
1048+
extracted_pkts)
1049+
self.byte_count_persistent_existing += (
1050+
extracted_bytes)
10371051
self.clear_existing_rule_flag(me)
10381052
else:
10391053
raise RuntimeError("weird flow entry")
@@ -1048,6 +1062,15 @@ def stat_in_bucket(flow_stat, s):
10481062
self.packet_count_table + self.packet_count_persistent ) ) )
10491063
if not self.outstanding_switches:
10501064
self.log.debug("No outstanding switches; calling callbacks")
1065+
self.log.debug("*** Returning bucket %d counts.\n%s%s%s%s%s%s" % (
1066+
id(self),
1067+
"table counts: %d\n" % self.packet_count_table,
1068+
"perst. apply: %d\n" % self.packet_count_persistent_apply,
1069+
"perst. remov: %d\n" % self.packet_count_persistent_removed,
1070+
"perst. exist: %d\n" % self.packet_count_persistent_existing,
1071+
"perst. total: %d\n" % self.packet_count_persistent,
1072+
"bucket total: %d\n" % (self.packet_count_table +
1073+
self.packet_count_persistent)))
10511074
self.call_callbacks([(self.packet_count_table +
10521075
self.packet_count_persistent),
10531076
(self.byte_count_table +

pyretic/core/runtime.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def __init__(self, backend, main, path_main, kwargs, mode='interpreted',
124124
self.packet_in_time = 0
125125
self.num_packet_ins = 0
126126
self.update_dynamic_sub_pols()
127+
self.total_packets_removed = 0 # pkt count from flow removed messages
127128

128129
def verbosity_numeric(self,verbosity_option):
129130
numeric_map = { 'low': 1,
@@ -1405,6 +1406,10 @@ def str_convert_match(m):
14051406
self.log.debug("Got removed flow\n%s with counts %d %d" %
14061407
(str(match_entry), f['packet_count'],
14071408
f['byte_count']) )
1409+
if version > 0:
1410+
self.total_packets_removed += f['packet_count']
1411+
self.log.debug("Total packets removed: %d" %
1412+
self.total_packets_removed)
14081413
self.log.debug('Printing global structure for deleted rules:')
14091414
for k,v in self.global_outstanding_deletes.iteritems():
14101415
self.log.debug(str(k) + " : " + str(v))

0 commit comments

Comments
 (0)