From 903fd513e32a37e55aec0cfb4cf30e000680e0c3 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Sat, 1 Apr 2017 11:07:40 -0400 Subject: Clean up event log merge code Fix a decade-old ridiculous qsort function bug. Managed to subtract floating-point numbers as if they were integers, leading to manufactured time-paradoxes. That completely confuses g2, leading to the summary disappearance of entire tracks' worth of data at high zoom levels. Add a manual alignment tweak parameter to elog_merge, users can dial-out time paradoxes caused by NTP-grade clock synchronization. The event-logger has a precision of O(100ns), whereas NTP synchronization is O(1ms). Change-Id: I69dedabaa314f69f9df74ec9ee66e21e6c87f703 Signed-off-by: Dave Barach --- src/vppinfra/test_elog.c | 59 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-) (limited to 'src/vppinfra/test_elog.c') diff --git a/src/vppinfra/test_elog.c b/src/vppinfra/test_elog.c index 89905adb..1cf5ba1f 100644 --- a/src/vppinfra/test_elog.c +++ b/src/vppinfra/test_elog.c @@ -52,6 +52,8 @@ test_elog_main (unformat_input_t * input) f64 min_sample_time; char *dump_file, *load_file, *merge_file, **merge_files; u8 *tag, **tags; + f64 align_tweak; + f64 *align_tweaks; n_iter = 100; max_events = 100000; @@ -61,6 +63,7 @@ test_elog_main (unformat_input_t * input) load_file = 0; merge_files = 0; tags = 0; + align_tweaks = 0; min_sample_time = 2; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -83,6 +86,8 @@ test_elog_main (unformat_input_t * input) ; else if (unformat (input, "sample-time %f", &min_sample_time)) ; + else if (unformat (input, "align-tweak %f", &align_tweak)) + vec_add1 (align_tweaks, align_tweak); else { error = clib_error_create ("unknown input `%U'\n", @@ -102,9 +107,15 @@ test_elog_main (unformat_input_t * input) { uword i; elog_main_t *ems; - vec_clone (ems, merge_files); + /* Supply default tags as needed */ + if (vec_len (tags) < vec_len (ems)) + { + for (i = vec_len (tags); i < vec_len (ems); i++) + vec_add1 (tags, format (0, "F%d%c", i, 0)); + } + elog_init (em, max_events); for (i = 0; i < vec_len (ems); i++) { @@ -113,7 +124,10 @@ test_elog_main (unformat_input_t * input) goto done; if (i > 0) { - elog_merge (em, tags[0], &ems[i], tags[i]); + align_tweak = 0.0; + if (i <= vec_len (align_tweaks)) + align_tweak = align_tweaks[i - 1]; + elog_merge (em, tags[0], &ems[i], tags[i], align_tweak); tags[0] = 0; } } @@ -217,7 +231,8 @@ test_elog_main (unformat_input_t * input) #ifdef CLIB_UNIX if (dump_file) { - if ((error = elog_write_file (em, dump_file))) + if ((error = + elog_write_file (em, dump_file, 0 /* do not flush ring */ ))) goto done; } #endif @@ -246,6 +261,8 @@ main (int argc, char *argv[]) unformat_input_t i; int r; + clib_mem_init (0, 3ULL << 30); + unformat_init_command_line (&i, argv); r = test_elog_main (&i); unformat_free (&i); @@ -253,6 +270,42 @@ main (int argc, char *argv[]) } #endif +/** + * @brief GDB callable function: vl - Return vector length of vector + * + * @param *p - void - address of vector + * + * @return length - u32 + * + */ +u32 +vl (void *p) +{ + return vec_len (p); +} + +/** + * @brief GDB callable function: pe - call pool_elts - number of elements in a pool + * + * @param *v - void - address of pool + * + * @return number - uword + * + */ +#include +uword +pe (void *v) +{ + return (pool_elts (v)); +} + +#include +uword +he (void *v) +{ + return (hash_elts (v)); +} + /* * fd.io coding-style-patch-verification: ON * -- cgit 1.2.3-korg