diff options
| author | yangwei <[email protected]> | 2024-08-01 03:00:27 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2024-08-12 15:45:50 +0800 |
| commit | a7837d6c93d8d49510ab1e05ee41250c5765bb98 (patch) | |
| tree | 94446d67a4cc7405b9cb522dbc8d1f08a9ef789a | |
| parent | 2ff76d6598dc809b3792658af19b913c51a65c0d (diff) | |
🎈 perf(clock_gettime): COARSE to reduce overhead
| -rw-r--r-- | src/packet/packet_craft.cpp | 2 | ||||
| -rw-r--r-- | src/packet_io/marsio_io.cpp | 2 | ||||
| -rw-r--r-- | src/times/times.cpp | 6 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/packet/packet_craft.cpp b/src/packet/packet_craft.cpp index e6ac39a..61bf0ac 100644 --- a/src/packet/packet_craft.cpp +++ b/src/packet/packet_craft.cpp @@ -37,7 +37,7 @@ static inline void calc_packet_fingerprint(struct fingerprint *finger) { #define RANGE(rand, start, end) (start + rand % (end - start + 1)) // [start, end] struct timespec time; - clock_gettime(CLOCK_MONOTONIC, &time); + clock_gettime(CLOCK_MONOTONIC_COARSE, &time); uint64_t random = 0x013579ABCDEF ^ time.tv_nsec; finger->ip_id = (uint16_t)(RANGE(random, 32767, 65535)); finger->ip_ttl = (uint8_t)(RANGE(random, 48, 120)); diff --git a/src/packet_io/marsio_io.cpp b/src/packet_io/marsio_io.cpp index 012db3b..9cfaa2b 100644 --- a/src/packet_io/marsio_io.cpp +++ b/src/packet_io/marsio_io.cpp @@ -297,7 +297,7 @@ int marsio_io_ingress(struct marsio_io *handle, uint16_t thr_idx, struct packet } pkt = &pkts[nr_parsed]; - memset(pkt, 0, sizeof(struct packet)); + //memset(pkt, 0, sizeof(struct packet)); packet_parse(pkt, data, len); metadata_from_mbuff_to_packet(mbuff, pkt); nr_parsed++; diff --git a/src/times/times.cpp b/src/times/times.cpp index be4cdec..70343c5 100644 --- a/src/times/times.cpp +++ b/src/times/times.cpp @@ -34,7 +34,7 @@ uint64_t stellar_get_monotonic_time_sec() { struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); + clock_gettime(CLOCK_MONOTONIC_COARSE, &now); return TIMESPEC_TO_SEC(now); } @@ -42,7 +42,7 @@ uint64_t stellar_get_monotonic_time_sec() uint64_t stellar_get_monotonic_time_msec() { struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); + clock_gettime(CLOCK_MONOTONIC_COARSE, &now); return TIMESPEC_TO_MSEC(now); } @@ -50,7 +50,7 @@ uint64_t stellar_get_monotonic_time_msec() uint64_t stellar_get_real_time_sec() { struct timespec now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_REALTIME_COARSE, &now); return TIMESPEC_TO_SEC(now); } |
