Trending: Add multiprocessing, remove archiving 01/21001/4
authorTibor Frank <tifrank@cisco.com>
Thu, 1 Aug 2019 10:24:08 +0000 (12:24 +0200)
committerTibor Frank <tifrank@cisco.com>
Thu, 1 Aug 2019 11:19:47 +0000 (13:19 +0200)
Change-Id: I67cfde7dfc9b81fca3ae102b43f6defafe88f689
Signed-off-by: Tibor Frank <tifrank@cisco.com>
resources/tools/presentation/input_data_files.py
resources/tools/presentation/input_data_parser.py
resources/tools/presentation/requirements.txt
resources/tools/presentation/specification_CPTA.yaml

index 892dfe2..15d7d02 100644 (file)
@@ -219,15 +219,15 @@ def download_and_unzip_data_file(spec, job, build, pid, log):
     else:
         return False
 
     else:
         return False
 
-    if spec.configuration.get("archive-inputs", True):
-        if spec.input["file-name"].endswith(".gz"):
-            if "docs.fd.io" in url:
-                execute_command("gzip --decompress --keep --force {0}".
-                                format(new_name))
-            else:
-                rename(new_name, new_name[:-3])
+    if spec.input["file-name"].endswith(".gz"):
+        if "docs.fd.io" in url:
+            execute_command("gzip --decompress --keep --force {0}".
+                            format(new_name))
+        else:
+            rename(new_name, new_name[:-3])
+            if spec.configuration.get("archive-inputs", True):
                 execute_command("gzip --keep {0}".format(new_name[:-3]))
                 execute_command("gzip --keep {0}".format(new_name[:-3]))
-            build["file-name"] = new_name[:-3]
+        build["file-name"] = new_name[:-3]
 
     if new_name.endswith(".zip"):
         if is_zipfile(new_name):
 
     if new_name.endswith(".zip"):
         if is_zipfile(new_name):
index 37532c8..9c0e380 100644 (file)
@@ -23,7 +23,6 @@ import multiprocessing
 import os
 import re
 import resource
 import os
 import re
 import resource
-import objgraph
 import pandas as pd
 import logging
 
 import pandas as pd
 import logging
 
@@ -1189,10 +1188,13 @@ class InputData(object):
 
         return checker.data
 
 
         return checker.data
 
-    def _download_and_parse_build(self, job, build, repeat, pid=10000):
+    def _download_and_parse_build(self, pid, data_queue, job, build, repeat):
         """Download and parse the input data file.
 
         :param pid: PID of the process executing this method.
         """Download and parse the input data file.
 
         :param pid: PID of the process executing this method.
+        :param data_queue: Shared memory between processes. Queue which keeps
+            the result data. This data is then read by the main process and used
+            in further processing.
         :param job: Name of the Jenkins job which generated the processed input
             file.
         :param build: Information about the Jenkins build which generated the
         :param job: Name of the Jenkins job which generated the processed input
             file.
         :param build: Information about the Jenkins build which generated the
@@ -1200,6 +1202,7 @@ class InputData(object):
         :param repeat: Repeat the download specified number of times if not
             successful.
         :type pid: int
         :param repeat: Repeat the download specified number of times if not
             successful.
         :type pid: int
+        :type data_queue: multiprocessing.Manager().Queue()
         :type job: str
         :type build: dict
         :type repeat: int
         :type job: str
         :type build: dict
         :type repeat: int
@@ -1280,6 +1283,14 @@ class InputData(object):
                                          format(full_name, repr(err))))
         logs.append(("INFO", "  Done."))
 
                                          format(full_name, repr(err))))
         logs.append(("INFO", "  Done."))
 
+        result = {
+            "data": data,
+            "state": state,
+            "job": job,
+            "build": build
+        }
+        data_queue.put(result)
+
         for level, line in logs:
             if level == "INFO":
                 logging.info(line)
         for level, line in logs:
             if level == "INFO":
                 logging.info(line)
@@ -1292,7 +1303,8 @@ class InputData(object):
             elif level == "WARNING":
                 logging.warning(line)
 
             elif level == "WARNING":
                 logging.warning(line)
 
-        return {"data": data, "state": state, "job": job, "build": build}
+        logging.info("Memory allocation: {0:,d}MB".format(
+            resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1000))
 
     def download_and_parse_data(self, repeat=1):
         """Download the input data files, parse input data from input files and
 
     def download_and_parse_data(self, repeat=1):
         """Download the input data files, parse input data from input files and
@@ -1305,36 +1317,67 @@ class InputData(object):
 
         logging.info("Downloading and parsing input files ...")
 
 
         logging.info("Downloading and parsing input files ...")
 
+        work_queue = multiprocessing.JoinableQueue()
+        manager = multiprocessing.Manager()
+        data_queue = manager.Queue()
+        cpus = multiprocessing.cpu_count()
+
+        workers = list()
+        for cpu in range(cpus):
+            worker = Worker(work_queue,
+                            data_queue,
+                            self._download_and_parse_build)
+            worker.daemon = True
+            worker.start()
+            workers.append(worker)
+            os.system("taskset -p -c {0} {1} > /dev/null 2>&1".
+                      format(cpu, worker.pid))
+
         for job, builds in self._cfg.builds.items():
             for build in builds:
         for job, builds in self._cfg.builds.items():
             for build in builds:
+                work_queue.put((job, build, repeat))
+
+        work_queue.join()
+
+        logging.info("Done.")
+        logging.info("Collecting data:")
+
+        while not data_queue.empty():
+            result = data_queue.get()
+
+            job = result["job"]
+            build_nr = result["build"]["build"]
+            logging.info("  {job}-{build}".format(job=job, build=build_nr))
 
 
-                result = self._download_and_parse_build(job, build, repeat)
-                build_nr = result["build"]["build"]
+            if result["data"]:
+                data = result["data"]
+                build_data = pd.Series({
+                    "metadata": pd.Series(
+                        data["metadata"].values(),
+                        index=data["metadata"].keys()),
+                    "suites": pd.Series(data["suites"].values(),
+                                        index=data["suites"].keys()),
+                    "tests": pd.Series(data["tests"].values(),
+                                       index=data["tests"].keys())})
 
 
-                if result["data"]:
-                    data = result["data"]
-                    build_data = pd.Series({
-                        "metadata": pd.Series(
-                            data["metadata"].values(),
-                            index=data["metadata"].keys()),
-                        "suites": pd.Series(data["suites"].values(),
-                                            index=data["suites"].keys()),
-                        "tests": pd.Series(data["tests"].values(),
-                                           index=data["tests"].keys())})
+                if self._input_data.get(job, None) is None:
+                    self._input_data[job] = pd.Series()
+                self._input_data[job][str(build_nr)] = build_data
 
 
-                    if self._input_data.get(job, None) is None:
-                        self._input_data[job] = pd.Series()
-                    self._input_data[job][str(build_nr)] = build_data
+                self._cfg.set_input_file_name(
+                    job, build_nr, result["build"]["file-name"])
 
 
-                    self._cfg.set_input_file_name(
-                        job, build_nr, result["build"]["file-name"])
+            self._cfg.set_input_state(job, build_nr, result["state"])
 
 
-                self._cfg.set_input_state(job, build_nr, result["state"])
+            logging.info("Memory allocation: {0:,d}MB".format(
+                resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1000))
 
 
-                logging.info("ru_maxrss = {0}".format(
-                    resource.getrusage(resource.RUSAGE_SELF).ru_maxrss))
+        del data_queue
 
 
-                logging.info(objgraph.most_common_types())
+        # Terminate all workers
+        for worker in workers:
+            worker.terminate()
+            worker.join()
 
         logging.info("Done.")
 
 
         logging.info("Done.")
 
index 6ada198..66a993d 100644 (file)
@@ -8,4 +8,3 @@ numpy==1.16.4
 pandas==0.24.2
 plotly==3.3.0
 PTable==0.9.2
 pandas==0.24.2
 plotly==3.3.0
 PTable==0.9.2
-objgraph==3.4.1
index c98a51a..4015ebc 100644 (file)
     # 3n-hsw
     plot-performance-trending-all-3n-hsw:
       csit-vpp-perf-mrr-daily-master:
     # 3n-hsw
     plot-performance-trending-all-3n-hsw:
       csit-vpp-perf-mrr-daily-master:
-        start: 720
+        start: 670
         end: "lastCompletedBuild"
         skip:
         end: "lastCompletedBuild"
         skip:
-#          - 672
-#          - 673
-#          - 674
-#          - 675
-#          - 676
-#          - 677
-#          - 678
-#          - 679
-#          - 680
-#          - 688
-#          - 689
-#          - 690
-#          - 694
-#          - 695
+          - 672
+          - 673
+          - 674
+          - 675
+          - 676
+          - 677
+          - 678
+          - 679
+          - 680
+          - 688
+          - 689
+          - 690
+          - 694
+          - 695
           - 726
           - 749
           - 750
           - 726
           - 749
           - 750
           - 797
           - 798
           - 799
           - 797
           - 798
           - 799
-          - 800 #
           - 801 #
           - 802 #
           - 803 #
           - 801 #
           - 802 #
           - 803 #
 
     plot-performance-trending-vpp-3n-hsw:
       csit-vpp-perf-mrr-daily-master:
 
     plot-performance-trending-vpp-3n-hsw:
       csit-vpp-perf-mrr-daily-master:
-        start: 720
+        start: 670
         end: "lastCompletedBuild"
         skip:
         end: "lastCompletedBuild"
         skip:
-#          - 672
-#          - 673
-#          - 674
-#          - 675
-#          - 676
-#          - 677
-#          - 678
-#          - 679
-#          - 680
-#          - 688
-#          - 689
-#          - 690
-#          - 694
-#          - 695
+          - 672
+          - 673
+          - 674
+          - 675
+          - 676
+          - 677
+          - 678
+          - 679
+          - 680
+          - 688
+          - 689
+          - 690
+          - 694
+          - 695
           - 726
           - 749
           - 750
           - 726
           - 749
           - 750
           - 797
           - 798
           - 799
           - 797
           - 798
           - 799
-          - 800 #
           - 801 #
           - 802 #
           - 803 #
           - 801 #
           - 802 #
           - 803 #
     # 3n-skx
     plot-performance-trending-all-3n-skx:
       csit-vpp-perf-mrr-daily-master-3n-skx:
     # 3n-skx
     plot-performance-trending-all-3n-skx:
       csit-vpp-perf-mrr-daily-master-3n-skx:
-        start: 450
+        start: 420
         end: "lastCompletedBuild"
         skip:
         end: "lastCompletedBuild"
         skip:
-#          - 423
-#          - 424
-#          - 425
-#          - 426
-#          - 427
-#          - 428
-#          - 429
-#          - 430
-#          - 440
-#          - 444
-#          - 446
+          - 423
+          - 424
+          - 425
+          - 426
+          - 427
+          - 428
+          - 429
+          - 430
+          - 440
+          - 444
+          - 446
           - 480
           - 481
           - 499
           - 480
           - 481
           - 499
           - 547
           - 548
           - 549
           - 547
           - 548
           - 549
-          - 550 #
           - 551 #
           - 552 #
           - 553 #
           - 551 #
           - 552 #
           - 553 #
 
     plot-performance-trending-vpp-3n-skx:
       csit-vpp-perf-mrr-daily-master-3n-skx:
 
     plot-performance-trending-vpp-3n-skx:
       csit-vpp-perf-mrr-daily-master-3n-skx:
-        start: 450
+        start: 420
         end: "lastCompletedBuild"
         skip:
         end: "lastCompletedBuild"
         skip:
-#          - 423
-#          - 424
-#          - 425
-#          - 426
-#          - 427
-#          - 428
-#          - 429
-#          - 430
-#          - 440
-#          - 444
-#          - 446
+          - 423
+          - 424
+          - 425
+          - 426
+          - 427
+          - 428
+          - 429
+          - 430
+          - 440
+          - 444
+          - 446
           - 480
           - 481
           - 499
           - 480
           - 481
           - 499
           - 547
           - 548
           - 549
           - 547
           - 548
           - 549
-          - 550 #
           - 551 #
           - 552 #
           - 553 #
           - 551 #
           - 552 #
           - 553 #
     # 2n-skx
     plot-performance-trending-all-2n-skx:
       csit-vpp-perf-mrr-daily-master-2n-skx:
     # 2n-skx
     plot-performance-trending-all-2n-skx:
       csit-vpp-perf-mrr-daily-master-2n-skx:
-        start: 450
+        start: 420
         end: "lastCompletedBuild"
         skip:
         end: "lastCompletedBuild"
         skip:
-#          - 423
-#          - 424
-#          - 425
-#          - 426
-#          - 427
-#          - 428
-#          - 429
-#          - 430
-#          - 431
-#          - 441
-#          - 444
+          - 423
+          - 424
+          - 425
+          - 426
+          - 427
+          - 428
+          - 429
+          - 430
+          - 431
+          - 441
+          - 444
           - 477
           - 500
           - 501
           - 477
           - 500
           - 501
 
     plot-performance-trending-vpp-2n-skx:
       csit-vpp-perf-mrr-daily-master-2n-skx:
 
     plot-performance-trending-vpp-2n-skx:
       csit-vpp-perf-mrr-daily-master-2n-skx:
-        start: 450
+        start: 420
         end: "lastCompletedBuild"
         skip:
         end: "lastCompletedBuild"
         skip:
-#          - 423
-#          - 424
-#          - 425
-#          - 426
-#          - 427
-#          - 428
-#          - 429
-#          - 430
-#          - 431
-#          - 441
-#          - 444
+          - 423
+          - 424
+          - 425
+          - 426
+          - 427
+          - 428
+          - 429
+          - 430
+          - 431
+          - 441
+          - 444
           - 477
           - 500
           - 501
           - 477
           - 500
           - 501
 
     # 3n-hsw
     csit-vpp-perf-mrr-daily-master:
 
     # 3n-hsw
     csit-vpp-perf-mrr-daily-master:
-      start: 720  # 670
+      start: 670
       end: "lastCompletedBuild"
       skip:
       end: "lastCompletedBuild"
       skip:
-#        - 672
-#        - 673
-#        - 674
-#        - 675
-#        - 676
-#        - 677
-#        - 678
-#        - 679
-#        - 680
-#        - 688
-#        - 689
-#        - 690
-#        - 694
-#        - 695
+        - 672
+        - 673
+        - 674
+        - 675
+        - 676
+        - 677
+        - 678
+        - 679
+        - 680
+        - 688
+        - 689
+        - 690
+        - 694
+        - 695
         - 726
         - 749
         - 750
         - 726
         - 749
         - 750
         - 797
         - 798
         - 799
         - 797
         - 798
         - 799
-        - 800 #
         - 801 #
         - 802 #
         - 803 #
         - 801 #
         - 802 #
         - 803 #
 
     # 3n-skx
     csit-vpp-perf-mrr-daily-master-3n-skx:
 
     # 3n-skx
     csit-vpp-perf-mrr-daily-master-3n-skx:
-      start: 450  # 420
+      start: 420
       end: "lastCompletedBuild"
       skip:
       end: "lastCompletedBuild"
       skip:
-#        - 423
-#        - 424
-#        - 425
-#        - 426
-#        - 427
-#        - 428
-#        - 429
-#        - 430
-#        - 440
-#        - 444
-#        - 446
+        - 423
+        - 424
+        - 425
+        - 426
+        - 427
+        - 428
+        - 429
+        - 430
+        - 440
+        - 444
+        - 446
         - 480
         - 481
         - 499
         - 480
         - 481
         - 499
         - 547
         - 548
         - 549
         - 547
         - 548
         - 549
-        - 550 #
         - 551 #
         - 552 #
         - 553 #
         - 551 #
         - 552 #
         - 553 #
 
     # 2n-skx
     csit-vpp-perf-mrr-daily-master-2n-skx:
 
     # 2n-skx
     csit-vpp-perf-mrr-daily-master-2n-skx:
-      start: 450
+      start: 420
       end: "lastCompletedBuild"
       skip:
       end: "lastCompletedBuild"
       skip:
-#        - 423
-#        - 424
-#        - 425
-#        - 426
-#        - 427
-#        - 428
-#        - 429
-#        - 430
-#        - 431
-#        - 441
-#        - 444
+        - 423
+        - 424
+        - 425
+        - 426
+        - 427
+        - 428
+        - 429
+        - 430
+        - 431
+        - 441
+        - 444
         - 477
         - 500
         - 501
         - 477
         - 500
         - 501