Skip to content

Commit 8b52bbc

Browse files
committed
(send_kcidb.py) Optimize KCIDB bridge
After we switched to REST interface, we can afford bigger batches, also let's add long time pending optimizations, to reduce CPU use, and to allow events to process data naturally. Signed-off-by: Denys Fedoryshchenko <[email protected]>
1 parent 7e556c4 commit 8b52bbc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/send_kcidb.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ def _node_processed_recursively(self, node):
617617
def _find_unprocessed_node(self, chunksize):
618618
"""
619619
Search for 96h nodes that were not sent to KCIDB
620+
Also updated__lt is set to 5 minutes, so we give chance for events
620621
This is nodes in available/completed state, and where flag
621622
sent_kcidb is not set
622623
If we don't have anymore unprocessed nodes, we will wait for 5 minutes
@@ -630,6 +631,7 @@ def _find_unprocessed_node(self, chunksize):
630631
'state': 'done',
631632
'processed_by_kcidb_bridge': False,
632633
'created__gt': datetime.datetime.now() - datetime.timedelta(days=4),
634+
'updated__lt': datetime.datetime.now() - datetime.timedelta(minutes=5),
633635
'limit': chunksize,
634636
})
635637
except Exception as exc:
@@ -681,7 +683,7 @@ def _run(self, context):
681683
"""Main run loop that processes nodes and sends data to KCIDB"""
682684
self.log.info("Listening for events... Press Ctrl-C to stop.")
683685

684-
chunksize = 20
686+
chunksize = 500
685687
subscribe_retries = 0
686688
while True:
687689
is_hierarchy = False
@@ -720,9 +722,11 @@ def _run(self, context):
720722
# Submit batch
721723
# Sometimes we get too much data and exceed gcloud limits,
722724
# so we reduce the chunk size to 50 and try again
723-
chunksize = 5 if not self._submit_to_kcidb(batch, context) else 20
725+
chunksize = 50 if not self._submit_to_kcidb(batch, context) else 500
724726

725727
self._clean_caches()
728+
# sleep 1 second to avoid busy loop
729+
time.sleep(1)
726730

727731
return True
728732

0 commit comments

Comments
 (0)