From 03840f364af3fff331fd8fe33b408e6489f0b5d2 Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Fri, 25 Mar 2022 11:07:50 +0100 Subject: [PATCH 01/18] Implemented HitVector::mostly_clear, that keeps N elements in the vector --- src/common/reduction/EventBuilder2D.cpp | 19 ++++++++++--------- src/common/reduction/EventBuilder2D.h | 2 +- src/common/reduction/HitVector.h | 8 ++++++++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/common/reduction/EventBuilder2D.cpp b/src/common/reduction/EventBuilder2D.cpp index 0e6d874b6..65dde8f8f 100644 --- a/src/common/reduction/EventBuilder2D.cpp +++ b/src/common/reduction/EventBuilder2D.cpp @@ -37,16 +37,17 @@ void EventBuilder2D::flush() { matcher.matched_events.clear(); sort_chronologically(HitsX); - ClustersX.cluster(HitsX); - ClustersX.flush(); + ClustererX.cluster(HitsX); + // Clusterer flushes when time gap between hits is large enough, no need to force it between packets + // ClustererX.flush(); sort_chronologically(HitsY); - ClustersY.cluster(HitsY); - ClustersY.flush(); + ClustererY.cluster(HitsY); + // ClustererY.flush(); - matcher.insert(PlaneX, ClustersX.clusters); - matcher.insert(PlaneY, ClustersY.clusters); - matcher.match(true); + matcher.insert(PlaneX, ClustererX.clusters); + matcher.insert(PlaneY, ClustererY.clusters); + matcher.match(false); auto &e = matcher.matched_events; Events.insert(Events.end(), e.begin(), e.end()); @@ -55,7 +56,7 @@ void EventBuilder2D::flush() { } void EventBuilder2D::clear() { - HitsX.clear(); - HitsY.clear(); + HitsX.mostly_clear(20); + HitsY.mostly_clear(20); } diff --git a/src/common/reduction/EventBuilder2D.h b/src/common/reduction/EventBuilder2D.h index f75f705a0..c6cb72c59 100644 --- a/src/common/reduction/EventBuilder2D.h +++ b/src/common/reduction/EventBuilder2D.h @@ -37,7 +37,7 @@ class EventBuilder2D { HitVector HitsX, HitsY; // \todo parametrize - GapClusterer ClustersX{timegap, coordgap}, ClustersY{timegap, coordgap}; + GapClusterer ClustererX{timegap, coordgap}, ClustererY{timegap, coordgap}; // \todo parametrize GapMatcher matcher{latency, PlaneX, PlaneY}; diff --git a/src/common/reduction/HitVector.h b/src/common/reduction/HitVector.h index 121041158..8acd988a5 100644 --- a/src/common/reduction/HitVector.h +++ b/src/common/reduction/HitVector.h @@ -126,6 +126,14 @@ template > class MyVector { Vec.clear(); reserve(MinReserveCount); } + + void mostly_clear(unsigned long keep_n_elements){ + if (Vec.size() > keep_n_elements){ + std::vector(Vec.end()-keep_n_elements, Vec.end()).swap(Vec); + reserve(MinReserveCount); + } + } + void resize(size_type sz) { Vec.resize(sz); } void resize(size_type sz, const value_type &c) { Vec.resize(sz, c); } }; From fcbdb4467f08424922fbc1094dc8faa3e68e789a Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Fri, 25 Mar 2022 13:55:53 +0100 Subject: [PATCH 02/18] experimenting with clusterer flushing --- src/common/reduction/EventBuilder2D.cpp | 4 ++-- src/modules/cspec/CSPECBase.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/reduction/EventBuilder2D.cpp b/src/common/reduction/EventBuilder2D.cpp index 65dde8f8f..bb9258245 100644 --- a/src/common/reduction/EventBuilder2D.cpp +++ b/src/common/reduction/EventBuilder2D.cpp @@ -56,7 +56,7 @@ void EventBuilder2D::flush() { } void EventBuilder2D::clear() { - HitsX.mostly_clear(20); - HitsY.mostly_clear(20); + HitsX.clear(); + HitsY.clear(); } diff --git a/src/modules/cspec/CSPECBase.cpp b/src/modules/cspec/CSPECBase.cpp index 58a253fe2..5511ab4a1 100644 --- a/src/modules/cspec/CSPECBase.cpp +++ b/src/modules/cspec/CSPECBase.cpp @@ -85,7 +85,7 @@ CSPECBase::CSPECBase(BaseSettings const &settings, Stats.create("readouts.tof_neg", Counters.TimeStats.TofNegative); Stats.create("readouts.prevtof_count", Counters.TimeStats.PrevTofCount); Stats.create("readouts.prevtof_neg", Counters.TimeStats.PrevTofNegative); - Stats.create("readouts.tof_toolarge", Counters.TOFErrors); + Stats.create("readouts.tof_toolarge", Counters.TOFErrors); //move this to events.tof_toolarge // Clustering stats From 95a7107d0d51a4d3a0c8f18dd7e1f4c440631837 Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Wed, 30 Mar 2022 11:29:26 +0200 Subject: [PATCH 03/18] Clustering changes, and addition of efustatstocsv to store efustats in easier format to compare runs --- src/common/reduction/EventBuilder2D.cpp | 14 ++++--- src/common/reduction/EventBuilder2D.h | 4 +- .../cspec/test/CSPECInstrumentTest.cpp | 1 + utils/efushell/efustatstocsv.py | 37 +++++++++++++++++++ 4 files changed, 50 insertions(+), 6 deletions(-) create mode 100755 utils/efushell/efustatstocsv.py diff --git a/src/common/reduction/EventBuilder2D.cpp b/src/common/reduction/EventBuilder2D.cpp index bb9258245..6bfa210d1 100644 --- a/src/common/reduction/EventBuilder2D.cpp +++ b/src/common/reduction/EventBuilder2D.cpp @@ -38,12 +38,9 @@ void EventBuilder2D::flush() { sort_chronologically(HitsX); ClustererX.cluster(HitsX); - // Clusterer flushes when time gap between hits is large enough, no need to force it between packets - // ClustererX.flush(); sort_chronologically(HitsY); ClustererY.cluster(HitsY); - // ClustererY.flush(); matcher.insert(PlaneX, ClustererX.clusters); matcher.insert(PlaneY, ClustererY.clusters); @@ -52,11 +49,18 @@ void EventBuilder2D::flush() { auto &e = matcher.matched_events; Events.insert(Events.end(), e.begin(), e.end()); - clear(); + clearHits(); } -void EventBuilder2D::clear() { +void EventBuilder2D::clearHits() { HitsX.clear(); HitsY.clear(); } +void EventBuilder2D::clearClusters() { + ClustererX.flush(); + ClustererY.flush(); +} + + + diff --git a/src/common/reduction/EventBuilder2D.h b/src/common/reduction/EventBuilder2D.h index c6cb72c59..01cda306a 100644 --- a/src/common/reduction/EventBuilder2D.h +++ b/src/common/reduction/EventBuilder2D.h @@ -30,7 +30,9 @@ class EventBuilder2D { void flush(); - void clear(); + void clearHits(); + + void clearClusters(); void setTimeBox(uint32_t TimeBoxValue) { TimeBoxSize = TimeBoxValue; } diff --git a/src/modules/cspec/test/CSPECInstrumentTest.cpp b/src/modules/cspec/test/CSPECInstrumentTest.cpp index 731926603..51407a3c7 100644 --- a/src/modules/cspec/test/CSPECInstrumentTest.cpp +++ b/src/modules/cspec/test/CSPECInstrumentTest.cpp @@ -630,6 +630,7 @@ TEST_F(CSPECInstrumentTest, BadEventLargeTimeSpan) { cspec->processReadouts(); for (auto &builder : cspec->builders) { builder.flush(); + builder.clearClusters(); cspec->generateEvents(builder.Events); } diff --git a/utils/efushell/efustatstocsv.py b/utils/efushell/efustatstocsv.py new file mode 100755 index 000000000..79cfaa419 --- /dev/null +++ b/utils/efushell/efustatstocsv.py @@ -0,0 +1,37 @@ +#!/usr/bin/python + +from EFUMetrics import Metrics +import argparse +import csv + +parser = argparse.ArgumentParser() +parser.add_argument("-i", metavar='ipaddr', help = "server ip address (default 127.0.0.1)", + type = str, default = "127.0.0.1") +parser.add_argument("-p", metavar='port', help = "server tcp port (default 8888)", + type = int, default = 8888) +parser.add_argument("-v", help = "Dump stats in format suitable for verifymetrics.py", action = 'store_true') +parser.add_argument("-f", type=str, default="efustats.csv", help="Filename to save csv file under") + +args = parser.parse_args() + +print("") +metrics = Metrics(args.i, args.p) + +res = metrics._get_efu_command("STAT_GET_COUNT") +numstats = int(res.split()[1]) +print("Available stats ({}):".format(numstats)) +verify = "" +stats_dict = {} +for statnum in range(1, numstats + 1): + res = metrics._get_efu_command("STAT_GET " + str(statnum)) + verify = verify + str(res.split()[1]) + ":" + str(res.split()[2]) + " " + stats_dict[res.split()[1].decode('utf-8')] = res.split()[2].decode('utf-8') + +print(stats_dict) +with open(args.f, 'w') as csvfile: + for key in stats_dict.keys(): + csvfile.write("%s, %s\n" % (key, stats_dict[key])) + +if args.v: + print(verify) + From 8c8d2bfd76533f7c655493dc14378cd5973ec4f6 Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Thu, 31 Mar 2022 09:28:28 +0200 Subject: [PATCH 04/18] Benchmarking --- src/common/reduction/test/CMakeLists.txt | 5 +++++ src/common/reduction/test/HitVectorBenchmark.cpp | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/common/reduction/test/HitVectorBenchmark.cpp diff --git a/src/common/reduction/test/CMakeLists.txt b/src/common/reduction/test/CMakeLists.txt index 621240680..abdbe3f3e 100644 --- a/src/common/reduction/test/CMakeLists.txt +++ b/src/common/reduction/test/CMakeLists.txt @@ -27,3 +27,8 @@ set(ChronoMergerTest_SRC ChronoMergerTest.cpp ) create_test_executable(ChronoMergerTest) + +set(HitVectorBenchmark_SRC + HitVectorBenchmark.cpp + ) + create_benchmark_executable(HitVectorBenchmark) \ No newline at end of file diff --git a/src/common/reduction/test/HitVectorBenchmark.cpp b/src/common/reduction/test/HitVectorBenchmark.cpp new file mode 100644 index 000000000..44cca37ea --- /dev/null +++ b/src/common/reduction/test/HitVectorBenchmark.cpp @@ -0,0 +1,16 @@ +#include +#include + + +static void BM_pushback_hits(benchmark::State& state){ + HitVector hits; + for (auto _ : state){ + Hit hit; + hit.coordinate = 50; + hit.weight = 50; + hit.time = 50; + hits.push_back(hit); + } +} + +BENCHMARK(BM_pushback_hits); From 2dddddcfd18c2d37fb55eed698a25b3cf1f6549e Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Wed, 27 Apr 2022 10:20:34 +0200 Subject: [PATCH 05/18] update benchmark test --- Jenkinsfile | 9 ++++++++- src/common/reduction/test/HitVectorBenchmark.cpp | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bf7913ef1..18a01c26c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -318,11 +318,18 @@ if (env.CHANGE_ID) { checkout scm unstash 'event-formation-unit-centos7.tar.gz' sh "tar xzvf event-formation-unit-centos7.tar.gz" - sh "ls -R" sh """ export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:./event-formation-unit/lib/ python3 -u ./integrationtest/integrationtest.py """ } // stage } // node + node('benchmarktest'){ + stage('Benchmark Test'){ + checkout scm + unstash 'event-formation-unit-centos7.tar.gz' + sh "tar xzvf event-formation-unit-centos7.tar.gz" + sh "./benchmarks/HitVectorBenchmark" + } + } } // if diff --git a/src/common/reduction/test/HitVectorBenchmark.cpp b/src/common/reduction/test/HitVectorBenchmark.cpp index 44cca37ea..2737b8c05 100644 --- a/src/common/reduction/test/HitVectorBenchmark.cpp +++ b/src/common/reduction/test/HitVectorBenchmark.cpp @@ -2,7 +2,7 @@ #include -static void BM_pushback_hits(benchmark::State& state){ +static void BM_pushback_hits(benchmark::State &state){ HitVector hits; for (auto _ : state){ Hit hit; @@ -12,5 +12,5 @@ static void BM_pushback_hits(benchmark::State& state){ hits.push_back(hit); } } - BENCHMARK(BM_pushback_hits); +BENCHMARK_MAIN(); From e718cc6aa6a02ef1e3a82f692c6580f84a07c541 Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Wed, 27 Apr 2022 15:41:46 +0200 Subject: [PATCH 06/18] Added performance test for cspec and loki --- Jenkinsfile | 11 ++- .../integrationtest.json | 0 {integrationtest => test}/integrationtest.py | 52 ++--------- test/performancetest.json | 17 ++++ test/performancetest.py | 89 +++++++++++++++++++ test/testutils.py | 62 +++++++++++++ 6 files changed, 182 insertions(+), 49 deletions(-) rename {integrationtest => test}/integrationtest.json (100%) rename {integrationtest => test}/integrationtest.py (63%) create mode 100644 test/performancetest.json create mode 100644 test/performancetest.py create mode 100644 test/testutils.py diff --git a/Jenkinsfile b/Jenkinsfile index 18a01c26c..961e40bf4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -320,16 +320,19 @@ if (env.CHANGE_ID) { sh "tar xzvf event-formation-unit-centos7.tar.gz" sh """ export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:./event-formation-unit/lib/ - python3 -u ./integrationtest/integrationtest.py + python3 -u ./test/integrationtest.py """ } // stage } // node - node('benchmarktest'){ - stage('Benchmark Test'){ + node('performancetest'){ + stage('Performance Test'){ checkout scm unstash 'event-formation-unit-centos7.tar.gz' sh "tar xzvf event-formation-unit-centos7.tar.gz" - sh "./benchmarks/HitVectorBenchmark" + sh """ + export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:./event-formation-unit/lib/ + python3 -u ./test/performancetest.py + """ } } } // if diff --git a/integrationtest/integrationtest.json b/test/integrationtest.json similarity index 100% rename from integrationtest/integrationtest.json rename to test/integrationtest.json diff --git a/integrationtest/integrationtest.py b/test/integrationtest.py similarity index 63% rename from integrationtest/integrationtest.py rename to test/integrationtest.py index 1bf0c1799..b3c3b76fd 100644 --- a/integrationtest/integrationtest.py +++ b/test/integrationtest.py @@ -3,6 +3,7 @@ import time import sys import os +from testutils import run_efu, run_data_generator, get_metrics sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) from utils.efushell.EFUMetrics import Metrics @@ -16,49 +17,9 @@ def compare_pair(x, y, operator): raise Exception(f"invalid operator {operator}") -def run_efu(test, efu): - print("Running EFU") - efu_command = f"{efu}/bin/efu --det {efu}/modules/{test['Module']}.so --nohwcheck --file {test['Config']} --region 0 --graphite 127.0.0.1" - print(efu_command) - efu_process = subprocess.Popen( - f"exec {efu_command}", - shell=True, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) - - # waiting for EFU start up to finish (estimated 5 seconds is enough time) - # checking if the EFU is still running after start up - time.sleep(5) - poll = efu_process.poll() - if poll is not None: - out, errs = efu_process.communicate() - print(out) - print(errs) - raise Exception(f"Running efu with command {efu_command} failed") - return efu_process - - -def run_data_generator(test, efu): - print("Running Data Generator") - generator_process = subprocess.Popen( - f"{efu}/generators/{test['Generator']} -a {test['Packets']} -o 50 -t {test['Throttle']}", - shell=True, - ) - exit_code = generator_process.wait() - if exit_code != 0: - raise Exception(f"Artififial generator {test['Generator']} failed") - return generator_process - - def check_stats(test): print("Getting EFU Stats") - try: - metrics = Metrics("127.0.0.1", 8888) - metrics.get_all_metrics(metrics.get_number_of_stats()) - except: - # socket errors can happen when attempting to get metrics if grafana connection is hanging - raise Exception("failed to get metrics") + metrics = get_metrics() for stats_test in test['StatsTestList']: actual_stat = metrics.return_metric(f"efu.{test['Module']}.0.{stats_test[0]}") @@ -115,17 +76,18 @@ def check_kafka(test): def run_tests(): efu = "./event-formation-unit" + efu = "./build" - with open('./integrationtest/integrationtest.json') as f: + with open('./test/integrationtest.json') as f: data = json.load(f) for test in data['Tests']: create_kafka_topic(test['KafkaTopic']) - efu_process = run_efu(test, efu) + efu_process = run_efu(efu, test['Module'], test['Config']) try: - run_data_generator(test, efu) + run_data_generator(efu, test['Generator'], test['Packets'], test['Throttle']) time.sleep(1) - run_data_generator(test, efu) + run_data_generator(efu, test['Generator'], test['Packets'], test['Throttle']) check_stats(test) check_kafka(test) efu_process.kill() diff --git a/test/performancetest.json b/test/performancetest.json new file mode 100644 index 000000000..faeb16e4c --- /dev/null +++ b/test/performancetest.json @@ -0,0 +1,17 @@ +{ + "Tests": + [ + { + "Module": "loki", + "Config": "./src/modules/loki/configs/STFCTestII.json", + "Generator": "loki_udp_generated", + "InitThrottle": 1 + }, + { + "Module": "cspec", + "Config": "./src/modules/cspec/configs/LET.json", + "Generator": "let_udp_generated", + "InitThrottle": 1 + } + ] +} diff --git a/test/performancetest.py b/test/performancetest.py new file mode 100644 index 000000000..3aa2dce76 --- /dev/null +++ b/test/performancetest.py @@ -0,0 +1,89 @@ +import json +import subprocess +import time +import sys +import os +from testutils import run_efu, run_data_generator_timed, get_metrics + +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) +from utils.efushell.EFUMetrics import Metrics + + +def get_stat(stat_name): + return get_stats([stat_name])[stat_name] + + +def get_stats(stat_name_list): + metrics = get_metrics() + stats = {} + for stat_name in stat_name_list: + stats[stat_name] = metrics.return_metric(stat_name) + return(stats) + +def efu_handles_data(efu, generator, module, throttle, packets_dropped): + time_s = 30 + readouts_per_packet = 100 + run_data_generator_timed(efu, generator, throttle, readouts_per_packet, time_s) + time.sleep(5) + new_packets_dropped = get_stat(f"efu.{module}.0.receive.dropped") + if new_packets_dropped != packets_dropped: + return new_packets_dropped - packets_dropped + else: + return 0 + +def assess_performance(efu, generator, module, throttle): + time_s = 30 + readouts_per_packet = 100 + stat_name_list = [f"efu.{module}.0.receive.packets", f"efu.{module}.0.readouts.count", f"efu.{module}.0.events.count"] + stats = get_stats(stat_name_list) + run_data_generator_timed(efu, generator, throttle, readouts_per_packet, time_s) + new_stats = get_stats(stat_name_list) + for stat_name in stat_name_list: + stats[stat_name] = (new_stats[stat_name] - stats[stat_name]) / time_s + print(f"the following stats are per second, calculated over {time_s} seconds") + print(stats) + + + +def bisect_throttle_settings(efu, generator, module, throttle): + packets_dropped = 0 + min_throttle = 0 + max_throttle = 1000 + for x in range(10): + packets_dropped = efu_handles_data(efu, generator, module, throttle, packets_dropped) + if packets_dropped==0: + print(f"Passed at throttle: {throttle}") + max_throttle = throttle + throttle = (throttle + min_throttle) / 2 + else: + print(f"Failed at throttle: {throttle}") + min_throttle = throttle + throttle = (throttle + max_throttle) / 2 + print(f"New throttle to test: {throttle}") + print(f"Min throttle: {min_throttle}, Max throttle: {max_throttle}") + if((max_throttle - min_throttle) < 1): + break + print(f"Best throttle achieved: {max_throttle}") + best_passing_throttle = max_throttle + return best_passing_throttle + +def run_performance_test(): + efu = "./event-formation-unit" + efu = "./build" + + with open('./test/performancetest.json') as f: + data = json.load(f) + + for test in data['Tests']: + efu_process = run_efu(efu, test['Module'], test['Config']) + try: + best_throttle = bisect_throttle_settings(efu, test['Generator'], test['Module'], test['InitThrottle']) + assess_performance(efu, test['Generator'], test['Module'], best_throttle) + except: + efu_process.kill() + raise + efu_process.kill() + time.sleep(5) + +if __name__ == "__main__": + run_performance_test() \ No newline at end of file diff --git a/test/testutils.py b/test/testutils.py new file mode 100644 index 000000000..104418d58 --- /dev/null +++ b/test/testutils.py @@ -0,0 +1,62 @@ +import subprocess +import time +import sys +import os + +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) +from utils.efushell.EFUMetrics import Metrics + +def run_efu(efu, module, config): + print("Running EFU") + efu_command = f"{efu}/bin/efu --det {efu}/modules/{module}.so --nohwcheck --file {config} --region 0 --graphite 127.0.0.1" + print(efu_command) + efu_process = subprocess.Popen( + f"exec {efu_command}", + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + + # waiting for EFU start up to finish (estimated 5 seconds is enough time) + # checking if the EFU is still running after start up + time.sleep(5) + poll = efu_process.poll() + if poll is not None: + out, errs = efu_process.communicate() + print(out) + print(errs) + raise Exception(f"Running efu with command {efu_command} failed") + return efu_process + + +def run_data_generator(efu, generator, packets, throttle): + print("Running Data Generator") + generator_process = subprocess.Popen( + f"{efu}/generators/{generator} -a {packets} -o 50 -t {int(throttle)}", + shell=True, + ) + exit_code = generator_process.wait() + if exit_code != 0: + raise Exception(f"Artififial generator {generator} failed") + return generator_process + +def run_data_generator_timed(efu, generator, throttle, readouts_per_packet, time_s): + print("Running Data Generator") + generator_process = subprocess.Popen( + f"{efu}/generators/{generator} -l -o {readouts_per_packet} -t {int(throttle)}", + shell=True, + ) + time.sleep(time_s) + generator_process.kill() + return generator_process + +def get_metrics(): + print("Getting EFU Stats") + try: + metrics = Metrics("127.0.0.1", 8888) + metrics.get_all_metrics(metrics.get_number_of_stats()) + return metrics + except: + # socket errors can happen when attempting to get metrics if grafana connection is hanging + print("failed to get metrics") + raise From d4f7ad68285012630453638817e0fd05a489a2a7 Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Thu, 28 Apr 2022 15:31:02 +0200 Subject: [PATCH 07/18] Debugging --- src/common/reduction/EventBuilder2D.cpp | 11 +++++++---- src/common/reduction/EventBuilder2D.h | 2 +- src/common/reduction/clustering/GapClusterer.cpp | 4 ++-- src/common/reduction/clustering/GapClusterer2D.cpp | 4 ++-- src/common/reduction/matching/GapMatcher.cpp | 4 ++-- src/modules/freia/FreiaInstrument.cpp | 7 ++++--- src/modules/freia/test/FreiaInstrumentTest.cpp | 2 +- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/common/reduction/EventBuilder2D.cpp b/src/common/reduction/EventBuilder2D.cpp index 6bfa210d1..fff98df87 100644 --- a/src/common/reduction/EventBuilder2D.cpp +++ b/src/common/reduction/EventBuilder2D.cpp @@ -13,8 +13,8 @@ #include -// #undef TRC_LEVEL -// #define TRC_LEVEL TRC_L_INF +#undef TRC_LEVEL +#define TRC_LEVEL TRC_L_INF @@ -33,7 +33,7 @@ void EventBuilder2D::insert(Hit hit) { } } -void EventBuilder2D::flush() { +void EventBuilder2D::flush(bool full) { matcher.matched_events.clear(); sort_chronologically(HitsX); @@ -44,12 +44,15 @@ void EventBuilder2D::flush() { matcher.insert(PlaneX, ClustererX.clusters); matcher.insert(PlaneY, ClustererY.clusters); - matcher.match(false); + matcher.match(full); auto &e = matcher.matched_events; Events.insert(Events.end(), e.begin(), e.end()); clearHits(); + if(full){ + clearClusters(); + } } void EventBuilder2D::clearHits() { diff --git a/src/common/reduction/EventBuilder2D.h b/src/common/reduction/EventBuilder2D.h index 01cda306a..6c4943db8 100644 --- a/src/common/reduction/EventBuilder2D.h +++ b/src/common/reduction/EventBuilder2D.h @@ -28,7 +28,7 @@ class EventBuilder2D { // \todo pass by rvalue? void insert(Hit hit); - void flush(); + void flush(bool full = false); void clearHits(); diff --git a/src/common/reduction/clustering/GapClusterer.cpp b/src/common/reduction/clustering/GapClusterer.cpp index a8b7a06e3..6bf99cbf5 100644 --- a/src/common/reduction/clustering/GapClusterer.cpp +++ b/src/common/reduction/clustering/GapClusterer.cpp @@ -9,8 +9,8 @@ #include #include -// #undef TRC_LEVEL -// #define TRC_LEVEL TRC_L_DEB +#undef TRC_LEVEL +#define TRC_LEVEL TRC_L_DEB GapClusterer::GapClusterer(uint64_t max_time_gap, uint16_t max_coord_gap) : AbstractClusterer(), max_time_gap_(max_time_gap), diff --git a/src/common/reduction/clustering/GapClusterer2D.cpp b/src/common/reduction/clustering/GapClusterer2D.cpp index 9b7eda409..b7c192cc2 100644 --- a/src/common/reduction/clustering/GapClusterer2D.cpp +++ b/src/common/reduction/clustering/GapClusterer2D.cpp @@ -8,8 +8,8 @@ #include #include -// #undef TRC_LEVEL -// #define TRC_LEVEL TRC_L_DEB +#undef TRC_LEVEL +#define TRC_LEVEL TRC_L_DEB GapClusterer2D::GapClusterer2D(uint64_t max_time_gap, uint16_t max_coord_gap) : AbstractClusterer(), max_time_gap_(max_time_gap), max_coord_gap_(max_coord_gap) {} diff --git a/src/common/reduction/matching/GapMatcher.cpp b/src/common/reduction/matching/GapMatcher.cpp index 3244c27bb..ee696e288 100644 --- a/src/common/reduction/matching/GapMatcher.cpp +++ b/src/common/reduction/matching/GapMatcher.cpp @@ -11,8 +11,8 @@ // #include // #include -// #undef TRC_LEVEL -// #define TRC_LEVEL TRC_L_DEB +#undef TRC_LEVEL +#define TRC_LEVEL TRC_L_DEB void GapMatcher::set_minimum_time_gap(uint64_t minimum_time_gap) { minimum_time_gap_ = minimum_time_gap; diff --git a/src/modules/freia/FreiaInstrument.cpp b/src/modules/freia/FreiaInstrument.cpp index f597ed988..acdf9eefd 100644 --- a/src/modules/freia/FreiaInstrument.cpp +++ b/src/modules/freia/FreiaInstrument.cpp @@ -15,8 +15,8 @@ #include #include -// #undef TRC_LEVEL -// #define TRC_LEVEL TRC_L_DEB +#undef TRC_LEVEL +#define TRC_LEVEL TRC_L_DEB namespace Freia { @@ -187,9 +187,10 @@ void FreiaInstrument::processReadouts(void) { void FreiaInstrument::generateEvents(std::vector &Events) { ESSReadout::ESSTime &TimeRef = ESSReadoutParser.Packet.Time; - + XTRACE(EVENT, DEB, "Number of events: %u", Events.size()); for (const auto &e : Events) { if (e.empty()) { + XTRACE(EVENT, DEB, "Empty event"); continue; } diff --git a/src/modules/freia/test/FreiaInstrumentTest.cpp b/src/modules/freia/test/FreiaInstrumentTest.cpp index 77b602578..a272ccb33 100644 --- a/src/modules/freia/test/FreiaInstrumentTest.cpp +++ b/src/modules/freia/test/FreiaInstrumentTest.cpp @@ -283,7 +283,7 @@ TEST_F(FreiaInstrumentTest, EventTOFError) { freia->processReadouts(); for (auto &builder : freia->builders) { - builder.flush(); + builder.flush(true); freia->generateEvents(builder.Events); } ASSERT_EQ(Res, 2); From 426576c84e50f64572d49d38cbd8b54f021189dd Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Thu, 28 Apr 2022 15:52:30 +0200 Subject: [PATCH 08/18] Bug fix, running builder.flush(true) does a full flush like original functionality, without a parameter/with the default of false, it keeps clusters between packets and adds to them if the first readout(s) in next packet belong there, or starts new clusters if time gap is large enough. --- src/common/reduction/EventBuilder2D.cpp | 13 +++++++------ src/common/reduction/EventBuilder2D.h | 4 ++-- src/modules/cspec/test/CSPECInstrumentTest.cpp | 17 ++++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/common/reduction/EventBuilder2D.cpp b/src/common/reduction/EventBuilder2D.cpp index fff98df87..01f412f42 100644 --- a/src/common/reduction/EventBuilder2D.cpp +++ b/src/common/reduction/EventBuilder2D.cpp @@ -33,7 +33,7 @@ void EventBuilder2D::insert(Hit hit) { } } -void EventBuilder2D::flush(bool full) { +void EventBuilder2D::flush(bool full_flush) { matcher.matched_events.clear(); sort_chronologically(HitsX); @@ -42,17 +42,18 @@ void EventBuilder2D::flush(bool full) { sort_chronologically(HitsY); ClustererY.cluster(HitsY); + if(full_flush){ + flushClusterers(); + } + matcher.insert(PlaneX, ClustererX.clusters); matcher.insert(PlaneY, ClustererY.clusters); - matcher.match(full); + matcher.match(full_flush); auto &e = matcher.matched_events; Events.insert(Events.end(), e.begin(), e.end()); clearHits(); - if(full){ - clearClusters(); - } } void EventBuilder2D::clearHits() { @@ -60,7 +61,7 @@ void EventBuilder2D::clearHits() { HitsY.clear(); } -void EventBuilder2D::clearClusters() { +void EventBuilder2D::flushClusterers() { ClustererX.flush(); ClustererY.flush(); } diff --git a/src/common/reduction/EventBuilder2D.h b/src/common/reduction/EventBuilder2D.h index 6c4943db8..d9cd86558 100644 --- a/src/common/reduction/EventBuilder2D.h +++ b/src/common/reduction/EventBuilder2D.h @@ -28,11 +28,11 @@ class EventBuilder2D { // \todo pass by rvalue? void insert(Hit hit); - void flush(bool full = false); + void flush(bool full_flush = false); void clearHits(); - void clearClusters(); + void flushClusterers(); void setTimeBox(uint32_t TimeBoxValue) { TimeBoxSize = TimeBoxValue; } diff --git a/src/modules/cspec/test/CSPECInstrumentTest.cpp b/src/modules/cspec/test/CSPECInstrumentTest.cpp index 51407a3c7..0a7d4b00a 100644 --- a/src/modules/cspec/test/CSPECInstrumentTest.cpp +++ b/src/modules/cspec/test/CSPECInstrumentTest.cpp @@ -441,7 +441,7 @@ TEST_F(CSPECInstrumentTest, GoodEvent) { ASSERT_EQ(counters.VMMStats.Readouts, 3); for (auto &builder : cspec->builders) { - builder.flush(); + builder.flush(true); cspec->generateEvents(builder.Events); } ASSERT_EQ(counters.Events, 1); @@ -465,7 +465,7 @@ TEST_F(CSPECInstrumentTest, BadMappingError) { ASSERT_EQ(counters.VMMStats.Readouts, 2); for (auto &builder : cspec->builders) { - builder.flush(); + builder.flush(true); cspec->generateEvents(builder.Events); } ASSERT_EQ(counters.Events, 0); @@ -511,7 +511,7 @@ TEST_F(CSPECInstrumentTest, NoEventGridOnly) { ASSERT_EQ(counters.VMMStats.Readouts, 2); for (auto &builder : cspec->builders) { - builder.flush(); + builder.flush(true); cspec->generateEvents(builder.Events); } ASSERT_EQ(counters.Events, 0); @@ -536,7 +536,7 @@ TEST_F(CSPECInstrumentTest, NoEventWireOnly) { ASSERT_EQ(counters.VMMStats.Readouts, 2); for (auto &builder : cspec->builders) { - builder.flush(); + builder.flush(true); cspec->generateEvents(builder.Events); } ASSERT_EQ(counters.Events, 0); @@ -576,7 +576,7 @@ TEST_F(CSPECInstrumentTest, BadEventLargeGridSpan) { ASSERT_EQ(counters.VMMStats.Readouts, 5); for (auto &builder : cspec->builders) { - builder.flush(); + builder.flush(true); cspec->generateEvents(builder.Events); } ASSERT_EQ(counters.Events, 0); @@ -593,7 +593,7 @@ TEST_F(CSPECInstrumentTest, NegativeTOF) { cspec->processReadouts(); for (auto &builder : cspec->builders) { - builder.flush(); + builder.flush(true); cspec->generateEvents(builder.Events); } @@ -611,7 +611,7 @@ TEST_F(CSPECInstrumentTest, HighTOFError) { cspec->processReadouts(); for (auto &builder : cspec->builders) { - builder.flush(); + builder.flush(true); cspec->generateEvents(builder.Events); } @@ -629,8 +629,7 @@ TEST_F(CSPECInstrumentTest, BadEventLargeTimeSpan) { cspec->processReadouts(); for (auto &builder : cspec->builders) { - builder.flush(); - builder.clearClusters(); + builder.flush(true); cspec->generateEvents(builder.Events); } From c431b68d826f4f944c3da3cfab0285b9e5e56410 Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Thu, 28 Apr 2022 16:52:49 +0200 Subject: [PATCH 09/18] Fixed directory --- test/integrationtest.py | 1 - test/performancetest.py | 1 - 2 files changed, 2 deletions(-) diff --git a/test/integrationtest.py b/test/integrationtest.py index b3c3b76fd..68cbe7c5a 100644 --- a/test/integrationtest.py +++ b/test/integrationtest.py @@ -76,7 +76,6 @@ def check_kafka(test): def run_tests(): efu = "./event-formation-unit" - efu = "./build" with open('./test/integrationtest.json') as f: data = json.load(f) diff --git a/test/performancetest.py b/test/performancetest.py index 3aa2dce76..46cd22997 100644 --- a/test/performancetest.py +++ b/test/performancetest.py @@ -69,7 +69,6 @@ def bisect_throttle_settings(efu, generator, module, throttle): def run_performance_test(): efu = "./event-formation-unit" - efu = "./build" with open('./test/performancetest.json') as f: data = json.load(f) From 59715a678868b1378b032169e240553ba6715222 Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Fri, 29 Apr 2022 09:31:23 +0200 Subject: [PATCH 10/18] Cross packet test --- .../cspec/test/CSPECInstrumentTest.cpp | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/modules/cspec/test/CSPECInstrumentTest.cpp b/src/modules/cspec/test/CSPECInstrumentTest.cpp index 0a7d4b00a..8f0d7f76e 100644 --- a/src/modules/cspec/test/CSPECInstrumentTest.cpp +++ b/src/modules/cspec/test/CSPECInstrumentTest.cpp @@ -142,6 +142,34 @@ std::vector GoodEvent { }; + +std::vector SplitEventA { + // First readout - plane Y - Grids + 0x00, 0x01, 0x14, 0x00, // Data Header - Ring 0, FEN 1 + 0x00, 0x00, 0x00, 0x00, // Time HI 0 s + 0x01, 0x00, 0x00, 0x00, // Time LO 1 tick + 0x00, 0x00, 0x00, 0x01, // ADC 0x100 + 0x00, 0x00, 0x02, 0x3C, // GEO 0, TDC 0, VMM 1, CH 60 + +}; + +std::vector SplitEventB { + // Second readout - plane Y - Grids + 0x00, 0x01, 0x14, 0x00, // Data Header - Ring 0, FEN 1 + 0x00, 0x00, 0x00, 0x00, // Time HI 0 s + 0x02, 0x00, 0x00, 0x00, // Time LO 2 tick + 0x00, 0x00, 0x00, 0x01, // ADC 0x100 + 0x00, 0x00, 0x02, 0x3D, // GEO 0, TDC 0, VMM 1, CH 61 + + // Third readout - plane X & Z - Wires + 0x00, 0x01, 0x14, 0x00, // Data Header, Ring 0, FEN 1 + 0x00, 0x00, 0x00, 0x00, // Time HI 0 s + 0x05, 0x00, 0x00, 0x00, // Time LO 5 ticks + 0x00, 0x00, 0x00, 0x01, // ADC 0x100 + 0x00, 0x00, 0x00, 0x3C, // GEO 0, TDC 0, VMM 0, CH 60 + +}; + std::vector BadEventMultipleWires { // First readout - plane Y - Grids 0x00, 0x01, 0x14, 0x00, // Data Header - Ring 0, FEN 1 @@ -639,6 +667,35 @@ TEST_F(CSPECInstrumentTest, BadEventLargeTimeSpan) { ASSERT_EQ(counters.ClustersNoCoincidence, 1); } +TEST_F(CSPECInstrumentTest, EventCrossPackets) { + makeHeader(cspec->ESSReadoutParser.Packet, SplitEventA); + + auto Res = cspec->VMMParser.parse(cspec->ESSReadoutParser.Packet); + counters.VMMStats = cspec->VMMParser.Stats; + + cspec->processReadouts(); + for (auto &builder : cspec->builders) { + builder.flush(); + cspec->generateEvents(builder.Events); + } + ASSERT_EQ(Res, 1); + + makeHeader(cspec->ESSReadoutParser.Packet, SplitEventB); + + Res = cspec->VMMParser.parse(cspec->ESSReadoutParser.Packet); + counters.VMMStats = cspec->VMMParser.Stats; + + cspec->processReadouts(); + for (auto &builder : cspec->builders) { + builder.flush(); + cspec->generateEvents(builder.Events); + } + + ASSERT_EQ(Res, 2); + ASSERT_EQ(counters.VMMStats.Readouts, 3); + ASSERT_EQ(counters.Events, 1); +} + int main(int argc, char **argv) { saveBuffer(ConfigFile, (void *)ConfigStr.c_str(), ConfigStr.size()); saveBuffer(BadConfigFile, (void *)BadConfigStr.c_str(), BadConfigStr.size()); From 5354576183ecaec2d421099368792029c5c2e495 Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Fri, 29 Apr 2022 09:33:42 +0200 Subject: [PATCH 11/18] Final packet sent needs to pass true parameter to builder.flush() so a full flush occurs, otherwise builder keeps clusters in case future packets contain relevant readouts. --- src/modules/cspec/test/CSPECInstrumentTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/cspec/test/CSPECInstrumentTest.cpp b/src/modules/cspec/test/CSPECInstrumentTest.cpp index 8f0d7f76e..58c8718c1 100644 --- a/src/modules/cspec/test/CSPECInstrumentTest.cpp +++ b/src/modules/cspec/test/CSPECInstrumentTest.cpp @@ -687,7 +687,7 @@ TEST_F(CSPECInstrumentTest, EventCrossPackets) { cspec->processReadouts(); for (auto &builder : cspec->builders) { - builder.flush(); + builder.flush(true); cspec->generateEvents(builder.Events); } From 7bd3442a32a28a005a13f98e2e344f0cb3154a0f Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Fri, 29 Apr 2022 09:50:16 +0200 Subject: [PATCH 12/18] Removed unnecessary mostly_clear function added to HitVector early on in this branch as an experimental approach to clustering over packets - not needed in the end --- src/common/reduction/HitVector.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/common/reduction/HitVector.h b/src/common/reduction/HitVector.h index 656aaacd0..0388411dc 100644 --- a/src/common/reduction/HitVector.h +++ b/src/common/reduction/HitVector.h @@ -127,13 +127,6 @@ template > class MyVector { reserve(MinReserveCount); } - void mostly_clear(unsigned long keep_n_elements){ - if (Vec.size() > keep_n_elements){ - std::vector(Vec.end()-keep_n_elements, Vec.end()).swap(Vec); - reserve(MinReserveCount); - } - } - void resize(size_type sz) { Vec.resize(sz); } void resize(size_type sz, const value_type &c) { Vec.resize(sz, c); } }; From 41fb625965e2ca8e4f02cc9c6ec7a20342a0ff71 Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Fri, 29 Apr 2022 10:14:35 +0200 Subject: [PATCH 13/18] New node name --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 961e40bf4..7fc4a6104 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -324,7 +324,7 @@ if (env.CHANGE_ID) { """ } // stage } // node - node('performancetest'){ + node('inttest'){ stage('Performance Test'){ checkout scm unstash 'event-formation-unit-centos7.tar.gz' From 64d42589202c9367e7ff362d754edb5067c30ada Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Fri, 29 Apr 2022 10:58:55 +0200 Subject: [PATCH 14/18] Fixed json name --- test/performancetest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/performancetest.json b/test/performancetest.json index faeb16e4c..f6d03cfeb 100644 --- a/test/performancetest.json +++ b/test/performancetest.json @@ -9,7 +9,7 @@ }, { "Module": "cspec", - "Config": "./src/modules/cspec/configs/LET.json", + "Config": "./src/modules/cspec/configs/let.json", "Generator": "let_udp_generated", "InitThrottle": 1 } From 7a5bc13b1595cedf32ec89d27b1244a74f3322c1 Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Fri, 29 Apr 2022 11:27:52 +0200 Subject: [PATCH 15/18] Refreshing kafka topic, in case messages already exist in topic --- test/integrationtest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/integrationtest.py b/test/integrationtest.py index 68cbe7c5a..a0f4d9cab 100644 --- a/test/integrationtest.py +++ b/test/integrationtest.py @@ -41,6 +41,10 @@ def check_stats(test): def create_kafka_topic(topic_name): + subprocess.Popen( + f"/ess/ecdc/kafka/kafka_2.13-2.8.0/bin/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic {topic_name}", + shell=True, + ).wait() subprocess.Popen( f"/ess/ecdc/kafka/kafka_2.13-2.8.0/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic {topic_name}", shell=True, From bf58d1eec492962ffd6b2a47a76fc71a98ea2950 Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Mon, 2 May 2022 11:08:46 +0200 Subject: [PATCH 16/18] Removed debug messages --- src/common/reduction/EventBuilder2D.cpp | 5 ++--- src/common/reduction/clustering/GapClusterer.cpp | 4 ++-- src/common/reduction/clustering/GapClusterer2D.cpp | 4 ++-- src/common/reduction/matching/GapMatcher.cpp | 4 ++-- src/modules/freia/FreiaInstrument.cpp | 4 ++-- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/common/reduction/EventBuilder2D.cpp b/src/common/reduction/EventBuilder2D.cpp index 01f412f42..15cfb4a71 100644 --- a/src/common/reduction/EventBuilder2D.cpp +++ b/src/common/reduction/EventBuilder2D.cpp @@ -13,9 +13,8 @@ #include -#undef TRC_LEVEL -#define TRC_LEVEL TRC_L_INF - +// #undef TRC_LEVEL +// #define TRC_LEVEL TRC_L_INF EventBuilder2D::EventBuilder2D() { matcher.set_minimum_time_gap(timegap); } diff --git a/src/common/reduction/clustering/GapClusterer.cpp b/src/common/reduction/clustering/GapClusterer.cpp index 6bf99cbf5..a8b7a06e3 100644 --- a/src/common/reduction/clustering/GapClusterer.cpp +++ b/src/common/reduction/clustering/GapClusterer.cpp @@ -9,8 +9,8 @@ #include #include -#undef TRC_LEVEL -#define TRC_LEVEL TRC_L_DEB +// #undef TRC_LEVEL +// #define TRC_LEVEL TRC_L_DEB GapClusterer::GapClusterer(uint64_t max_time_gap, uint16_t max_coord_gap) : AbstractClusterer(), max_time_gap_(max_time_gap), diff --git a/src/common/reduction/clustering/GapClusterer2D.cpp b/src/common/reduction/clustering/GapClusterer2D.cpp index b7c192cc2..9b7eda409 100644 --- a/src/common/reduction/clustering/GapClusterer2D.cpp +++ b/src/common/reduction/clustering/GapClusterer2D.cpp @@ -8,8 +8,8 @@ #include #include -#undef TRC_LEVEL -#define TRC_LEVEL TRC_L_DEB +// #undef TRC_LEVEL +// #define TRC_LEVEL TRC_L_DEB GapClusterer2D::GapClusterer2D(uint64_t max_time_gap, uint16_t max_coord_gap) : AbstractClusterer(), max_time_gap_(max_time_gap), max_coord_gap_(max_coord_gap) {} diff --git a/src/common/reduction/matching/GapMatcher.cpp b/src/common/reduction/matching/GapMatcher.cpp index ee696e288..3244c27bb 100644 --- a/src/common/reduction/matching/GapMatcher.cpp +++ b/src/common/reduction/matching/GapMatcher.cpp @@ -11,8 +11,8 @@ // #include // #include -#undef TRC_LEVEL -#define TRC_LEVEL TRC_L_DEB +// #undef TRC_LEVEL +// #define TRC_LEVEL TRC_L_DEB void GapMatcher::set_minimum_time_gap(uint64_t minimum_time_gap) { minimum_time_gap_ = minimum_time_gap; diff --git a/src/modules/freia/FreiaInstrument.cpp b/src/modules/freia/FreiaInstrument.cpp index acdf9eefd..c8cf43e85 100644 --- a/src/modules/freia/FreiaInstrument.cpp +++ b/src/modules/freia/FreiaInstrument.cpp @@ -15,8 +15,8 @@ #include #include -#undef TRC_LEVEL -#define TRC_LEVEL TRC_L_DEB +// #undef TRC_LEVEL +// #define TRC_LEVEL TRC_L_DEB namespace Freia { From 389e350f3eb152d48ce5c2f05ec912e5a727638a Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Wed, 4 May 2022 11:01:35 +0200 Subject: [PATCH 17/18] Fixed bug and renamed function --- test/performancetest.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/test/performancetest.py b/test/performancetest.py index 46cd22997..7ef7bc2d0 100644 --- a/test/performancetest.py +++ b/test/performancetest.py @@ -20,16 +20,14 @@ def get_stats(stat_name_list): stats[stat_name] = metrics.return_metric(stat_name) return(stats) -def efu_handles_data(efu, generator, module, throttle, packets_dropped): +def efu_drop_packets_check(efu, generator, module, throttle): time_s = 30 readouts_per_packet = 100 run_data_generator_timed(efu, generator, throttle, readouts_per_packet, time_s) time.sleep(5) new_packets_dropped = get_stat(f"efu.{module}.0.receive.dropped") - if new_packets_dropped != packets_dropped: - return new_packets_dropped - packets_dropped - else: - return 0 + return new_packets_dropped + def assess_performance(efu, generator, module, throttle): time_s = 30 @@ -50,8 +48,8 @@ def bisect_throttle_settings(efu, generator, module, throttle): min_throttle = 0 max_throttle = 1000 for x in range(10): - packets_dropped = efu_handles_data(efu, generator, module, throttle, packets_dropped) - if packets_dropped==0: + new_packets_dropped = efu_drop_packets_check(efu, generator, module, throttle) + if new_packets_dropped == packets_dropped: print(f"Passed at throttle: {throttle}") max_throttle = throttle throttle = (throttle + min_throttle) / 2 @@ -59,16 +57,19 @@ def bisect_throttle_settings(efu, generator, module, throttle): print(f"Failed at throttle: {throttle}") min_throttle = throttle throttle = (throttle + max_throttle) / 2 - print(f"New throttle to test: {throttle}") - print(f"Min throttle: {min_throttle}, Max throttle: {max_throttle}") + packets_dropped = new_packets_dropped if((max_throttle - min_throttle) < 1): break + print(f"New throttle to test: {throttle}") + print(f"Min throttle: {min_throttle}, Max throttle: {max_throttle}") + print(f"Packets dropped: {packets_dropped}") print(f"Best throttle achieved: {max_throttle}") best_passing_throttle = max_throttle return best_passing_throttle def run_performance_test(): efu = "./event-formation-unit" + efu = "./build" with open('./test/performancetest.json') as f: data = json.load(f) From ba595ed1bb2ccb37d80dd9f518950ea68cd1e4ab Mon Sep 17 00:00:00 2001 From: JennyLouise Date: Wed, 4 May 2022 13:57:58 +0200 Subject: [PATCH 18/18] Removed incorrect efu directory --- test/performancetest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/performancetest.py b/test/performancetest.py index 7ef7bc2d0..947990a9d 100644 --- a/test/performancetest.py +++ b/test/performancetest.py @@ -69,7 +69,6 @@ def bisect_throttle_settings(efu, generator, module, throttle): def run_performance_test(): efu = "./event-formation-unit" - efu = "./build" with open('./test/performancetest.json') as f: data = json.load(f)