dbworkload 0.8.3__tar.gz → 0.8.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dbworkload
3
- Version: 0.8.3
3
+ Version: 0.8.4
4
4
  Summary: Workload framework
5
5
  License: GPLv3+
6
6
  Author: Fabio Ghirardello
@@ -15,6 +15,7 @@ from threading import Thread
15
15
 
16
16
  import numpy as np
17
17
  import tabulate
18
+ from psutil import cpu_percent, virtual_memory
18
19
 
19
20
  import dbworkload.utils.common
20
21
  from dbworkload.cli.dep import ConnInfo
@@ -31,6 +32,7 @@ from dbworkload.cli.dep import ConnInfo
31
32
  DEFAULT_SLEEP = 3
32
33
  MAX_RETRIES = 3
33
34
  FREQUENCY = 10
35
+ STATS_BUFFER = 8
34
36
 
35
37
  FIFO = "dbworkload.pipe"
36
38
 
@@ -102,7 +104,7 @@ def signal_handler(sig, frame):
102
104
  sys.exit(1)
103
105
 
104
106
  force_exit = True
105
-
107
+
106
108
  # send the poison pill to each proc.
107
109
  # if dbworkload cannot graceful shutdown due
108
110
  # to processes being still in the init phase
@@ -190,8 +192,7 @@ def run(
190
192
  log_level: str,
191
193
  ):
192
194
  def gracefully_shutdown(by_keyinterrupt: bool = False):
193
-
194
- logger.info("Gracefully shutting down...")
195
+ logger.debug("Gracefully shutting down...")
195
196
 
196
197
  end_time = int(time.time())
197
198
  # _s = stats_received
@@ -208,7 +209,7 @@ def run(
208
209
  if x.is_alive():
209
210
  x.join()
210
211
 
211
- # Commenting the below as in theory there shouldn't be any stats that
212
+ # Commenting the below as in theory there shouldn't be any stats that
212
213
  # comes in *after* the PROC returns. That is, all threads send stats
213
214
  # when all threads are returned, then the supervisor returns.
214
215
  # while True:
@@ -384,10 +385,10 @@ def run(
384
385
  )
385
386
  supervisors[x].start()
386
387
 
387
- # report time happens 2 seconds after the stats are received.
388
+ # report time happens STATS_BUFFER seconds after the stats are received.
388
389
  # we add this buffer to make sure we get all the stats reports
389
390
  # from each thread before we aggregate and display
390
- report_time = start_time + FREQUENCY + 2
391
+ report_time = start_time + FREQUENCY + STATS_BUFFER
391
392
 
392
393
  returned_procs = 0
393
394
  active_connections = 0
@@ -488,7 +489,7 @@ def run(
488
489
  active_connections -= 1
489
490
  elif msg == "proc_returned":
490
491
  returned_procs += 1
491
- logger.info(f"Stopped processes: {returned_procs}/{procs} ")
492
+ logger.debug(f"Stopped processes: {returned_procs}/{procs} ")
492
493
  elif msg == "task_done":
493
494
  returned_threads += 1
494
495
  except queue.Empty:
@@ -512,11 +513,15 @@ def run(
512
513
  sys.exit(1)
513
514
 
514
515
  if time.time() >= report_time:
515
- # if stats_received != active_connections:
516
- # logger.warning("didn't receive all stats reports yet")
516
+ cpu_util = cpu_percent()
517
+ vmem = virtual_memory().percent
518
+ if stats_received != active_connections or cpu_util > 70 or vmem > 70:
519
+ logger.warning(
520
+ f"{stats_received=}, expected={active_connections}. CPU Util={cpu_util}%, Memory={vmem}%"
521
+ )
517
522
 
518
- # remove the 2 seconds added
519
- endtime = int(time.time()) - 2
523
+ # remove the STATS_BUFFER seconds added
524
+ endtime = int(time.time()) - STATS_BUFFER
520
525
 
521
526
  report = stats.calculate_stats(active_connections, endtime)
522
527
 
@@ -591,7 +596,7 @@ def run(
591
596
  report_time += FREQUENCY
592
597
 
593
598
  # pause briefly to prevent the loop from overheating the CPU
594
- time.sleep(.001)
599
+ time.sleep(0.001)
595
600
 
596
601
  gracefully_shutdown()
597
602
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dbworkload"
3
- version = "0.8.3"
3
+ version = "0.8.4"
4
4
  description = "Workload framework"
5
5
  authors = ["Fabio Ghirardello"]
6
6
  license = "GPLv3+"
File without changes
File without changes