diff options
| author | chenzizhan <[email protected]> | 2024-01-05 13:58:24 +0800 |
|---|---|---|
| committer | chenzizhan <[email protected]> | 2024-01-05 13:58:24 +0800 |
| commit | 4d97e5cb6b188a06eaa1fb1d1dd4b762d77e87f2 (patch) | |
| tree | c96fea9865a0a1ce6f62c24ee1af26e6730e4d7a /include | |
| parent | 185e3bfd2cf0c347ecdb4922390bf718a151c37f (diff) | |
fix: TSG-18335 fieldstat_easy_reset->fseasy_output_and_reset
Diffstat (limited to 'include')
| -rw-r--r-- | include/fieldstat/fieldstat_easy.h | 78 |
1 files changed, 6 insertions, 72 deletions
diff --git a/include/fieldstat/fieldstat_easy.h b/include/fieldstat/fieldstat_easy.h index 8b12780..d49470f 100644 --- a/include/fieldstat/fieldstat_easy.h +++ b/include/fieldstat/fieldstat_easy.h @@ -21,10 +21,6 @@ struct fieldstat_easy *fieldstat_easy_new(int max_thread_num, const char *name, */ void fieldstat_easy_free(struct fieldstat_easy *fse); /* - * reset the instance. Will fail and return -1 if fieldstat_easy_enable_auto_output is called, since the behavior is hard to define. -*/ -int fieldstat_easy_reset(struct fieldstat_easy *fse); -/* * enable auto output. both data of accumulated and delta will be output. * @param output_path: output file path. Should be identical to the one in python config. * @param interval_second: output interval in second. @@ -54,6 +50,12 @@ int fieldstat_easy_register_histogram(struct fieldstat_easy *fse, const char *na void fieldstat_easy_output(struct fieldstat_easy *fse, char **buff, size_t *buff_len); void fieldstat_easy_output_array(struct fieldstat_easy *fse, char ***json_objects, size_t *n_object); /* + Do fieldstat_easy_output_array and then reset the instance. + Will fail and return -1 if fieldstat_easy_enable_auto_output is called, since the behavior is hard to define. Return 0 if success. + The thread will be blocked until the output is finished. +*/ +int fieldstat_easy_output_array_and_reset(struct fieldstat_easy *fse, char ***json_objects, size_t *n_object); +/* * @brief let the value of counter metric of cell_id increase by `increment`. * @param thread_id: thread id. Must be in [0, max_thread_num). * @param metric_id: metric id, previously returned by fieldstat_register_counter. @@ -74,71 +76,3 @@ int fieldstat_easy_histogram_record(struct fieldstat_easy *fse, int thread_id, i #ifdef __cplusplus } #endif - - -/* -关于输出delta: -fs_write; -fs_accumulate; -fs_delta; - -一个在write上register的metric,同样会随merge进入accumulate,delta的metric 名字后面希望跟一个delta,但是因为它是切换过来的,而且最终要加到accumulate上,所以。。。 -delta的形成一定靠reset。 - -输出的时候,acc 和 delta的本来分别在两个json上,但是文件里只有一个json。 -最好提供一个exportPair 的接口,由json聚合。如果输出两个json,我还要读出来再写一套,更恶心了。 - -另外一个方法,干脆给histogram算差值,这样是不是更干净一点?从算法上讲,histogram没道理不能算差。 -然后就变成fs_write, fs_reading. 最终的输出是一个总量。 -这个方法总体很好,但是需要我在exporter上保存metric数据,依赖metric。光这一条就可以直接否了方案。 - -这个easy自己维护一套metric呢?查询到的histogram和counter都merge,然后改名,再merge进来。。。这个改名就特别莫名其妙,输出的东西当然要输出自己来搞。 -算了,调用两遍exporter得了,然后我把一个的加到另外一个上?这样的问题是我要用cjson来解,真的不要,太恶心了。。 - -还是搞个duo吧..? - -不行,因为我真的没办法保证acc 和 delta的cell一样,delta的cell是调用者来搞的, 太容易顺序错了。于是counter history 那套是必须的。 -不过传入delta而不是由exporter保留,这部分还是对的。如果还是想要这个history,那么exporter就还得是有状态的,不然总不能每次都拿delta重建一份。(感觉就重建一份吧) -算了,果然只能这样了。。 - -那么干脆每次都新来一个acc呢?我记录acc,合成acc,delta咋办?也不对。 -得得得得,算delta这个逃不掉了。 - -提供一个fieldstat减法怎么样?首先hll不支持减。另外我不希望动fs4的接口。 - - - ---------------------------------- plan1 --------------------------------- -改动最小,性能影响最大,所有的还都得搞两份 - -instance = new() -register_metric(i,"A"); -intance_delt -register_metric(i_delta, "A_delta"); -counter_incyby(instance, id, 1); -counter_incyby(instance_delta, id, 1); - - -dst = merge(instance); -dst_delta = merge(instance_delta); - -merge(dst, dst_delta) - - - ---------------------------------- plan2 --------------------------------- - // 最莫名其妙,而且merge 改起来容易出问题 -instance_delta = new() -incyby - -instance = merge_and_add_delta(instance_delta) // 新增接口 - - ----------------------------------- plan3 --------------------------------- -// 仅仅需要修改exporter,但是编码量比较大,选择这种。export只有一遍,而merge是每个线程一遍,还是慢export吧 -json_total = exporter_export_duo(acc, delta); // 新增接口 - - - ---------------------------------- plan4 --------------------------------- -enable-delta() -histogram_decode() -histogram_substract() -*/
\ No newline at end of file |
