diff options
| author | luwenpeng <[email protected]> | 2023-06-01 17:24:05 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2023-06-01 17:24:05 +0800 |
| commit | f00ef6596352b4e39f32df1c8be55de1e1a7deec (patch) | |
| tree | 49c30c7914d239321544cc6065fdb96c4c1200c4 | |
| parent | 8afad45a4078dd36c1658cefd37ccfcbf1357a80 (diff) | |
perf: throughput_metrics_inc禁用原子操作,并改为inline
| -rw-r--r-- | common/include/tfe_packet_io_fs.h | 6 | ||||
| -rw-r--r-- | common/src/tfe_packet_io_fs.cpp | 6 |
2 files changed, 5 insertions, 7 deletions
diff --git a/common/include/tfe_packet_io_fs.h b/common/include/tfe_packet_io_fs.h index d05c992..6bea391 100644 --- a/common/include/tfe_packet_io_fs.h +++ b/common/include/tfe_packet_io_fs.h @@ -58,7 +58,11 @@ struct packet_io_fs *packet_io_fs_create(const char *profile); void packet_io_fs_destory(struct packet_io_fs *handle); void packet_io_fs_dump(struct packet_io_fs *handle); -void throughput_metrics_inc(struct throughput_metrics *iterm, uint64_t n_pkts, uint64_t n_bytes); +void inline throughput_metrics_inc(struct throughput_metrics *iterm, uint64_t n_pkts, uint64_t n_bytes) +{ + iterm->n_bytes += n_bytes; + iterm->n_pkts += n_pkts; +} #ifdef __cpluscplus } diff --git a/common/src/tfe_packet_io_fs.cpp b/common/src/tfe_packet_io_fs.cpp index 0ac23bd..42427e5 100644 --- a/common/src/tfe_packet_io_fs.cpp +++ b/common/src/tfe_packet_io_fs.cpp @@ -136,12 +136,6 @@ static const char *stat_map[] = * throughput_metrics ******************************************************************************/ -void throughput_metrics_inc(struct throughput_metrics *iterm, uint64_t n_pkts, uint64_t n_bytes) -{ - __atomic_fetch_add(&iterm->n_bytes, n_bytes, __ATOMIC_RELAXED); - __atomic_fetch_add(&iterm->n_pkts, n_pkts, __ATOMIC_RELAXED); -} - struct packet_io_fs *packet_io_fs_create(const char *profile) { int value=0; |
