🎈 perf(clock_gettime): COARSE to reduce overhead
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user