Measuring arrival time on your server
How to measure when shreds reach your own server: take the timestamp in the kernel, keep the clock honest, compare each shred against a reference and report the whole distribution.
Decide what you compare against#
An arrival time means nothing alone. It becomes useful when you compare it with a reference, so pick that first:
- Another source on the same server. Feed two streams into one machine, for example two plans or two sellers, each on its own port, and compare the time each one delivered the same shred. Both timestamps come from one clock, so the clock's offset from true time cancels out. This is the cleanest test.
- The first shred seen per slot. Across every source you receive, record the earliest datagram for each slot. Each source's gap to that first sighting shows how often it leads.
- Your RPC node's slot events. The
slotsUpdatesSubscribeWebSocket method emits afirstShredReceivedevent per slot with a Unix timestamp in milliseconds, taken on the node. The Solana docs mark that subscription as unstable.slotSubscribesends a notification when the node processes a new slot; stamp it on arrival. Both events come from the node's own view of the network, so they tell you how a feed compares with what your node sees, not with the leader.
A slot lasts a fraction of a second and leaders take turns on a published schedule (see slots and leaders), so collect over many slots and many leaders before you draw conclusions.
Take the timestamp in the kernel#
Reading the clock in your program after recvfrom returns adds the time the datagram waited in the socket queue and the time your thread waited to be scheduled. Under load that wait can be larger than the effect you want to see. Linux can stamp each datagram earlier, and hand the stamp to you with the data:
SO_TIMESTAMPNSreturns astruct timespecwith nanosecond resolution, taken fromCLOCK_REALTIME, in a control message onrecvmsg. It cannot be combined withSO_TIMESTAMPon the same socket.SO_TIMESTAMPINGtakes a bitmap of flags.SOF_TIMESTAMPING_RX_SOFTWAREstamps the packet just after the driver hands it to the kernel receive stack.SOF_TIMESTAMPING_RX_HARDWAREasks the network card to stamp it, if the card and driver support that.
This C receiver enables SO_TIMESTAMPNS and prints, per datagram, the slot and index from the common header, the kernel time, and how much later user space read the clock:
1/* rxts.c: print kernel and user-space receive times for each datagram */2#define _GNU_SOURCE3#include <arpa/inet.h>4#include <stdint.h>5#include <stdio.h>6#include <stdlib.h>7#include <string.h>8#include <sys/socket.h>9#include <time.h>10#include <unistd.h>1112static int64_t ns(struct timespec t) { return (int64_t)t.tv_sec * 1000000000 + t.tv_nsec; }1314int main(int argc, char **argv) {15int port = argc > 1 ? atoi(argv[1]) : 9000;16int fd = socket(AF_INET, SOCK_DGRAM, 0);17int on = 1;18setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPNS, &on, sizeof on);1920struct sockaddr_in addr = { .sin_family = AF_INET, .sin_port = htons(port) };21addr.sin_addr.s_addr = htonl(INADDR_ANY);22if (bind(fd, (struct sockaddr *)&addr, sizeof addr) < 0) { perror("bind"); return 1; }2324unsigned char buf[1232];25char ctrl[CMSG_SPACE(sizeof(struct timespec))];26for (;;) {27struct iovec iov = { buf, sizeof buf };28struct msghdr msg = { .msg_iov = &iov, .msg_iovlen = 1,29.msg_control = ctrl, .msg_controllen = sizeof ctrl };30ssize_t len = recvmsg(fd, &msg, 0);31struct timespec user;32clock_gettime(CLOCK_REALTIME, &user);33if (len < 77) continue; /* shorter than slot + index */3435int64_t kernel_ns = 0;36for (struct cmsghdr *c = CMSG_FIRSTHDR(&msg); c; c = CMSG_NXTHDR(&msg, c))37if (c->cmsg_level == SOL_SOCKET && c->cmsg_type == SCM_TIMESTAMPNS) {38struct timespec k;39memcpy(&k, CMSG_DATA(c), sizeof k);40kernel_ns = ns(k);41}4243uint64_t slot; uint32_t index;44memcpy(&slot, buf + 65, 8); /* little-endian on x86_64 and arm64 */45memcpy(&index, buf + 73, 4);46printf("slot=%llu index=%u variant=0x%02x kernel_ns=%lld user_minus_kernel_ns=%lld\n",47(unsigned long long)slot, index, buf[64], (long long)kernel_ns,48(long long)(ns(user) - kernel_ns));49fflush(stdout);50}51}
gcc -Wall -O2 -o rxts rxts.c./rxts
The same in Python, which has no named constant for the option, so the snippet falls back to its value on x86_64 and arm64 Linux. It prints one plain line per datagram, slot index variant kernel_ns, which the comparison step below reads. Pass the port as the first argument when you run two copies side by side:
1import socket2import struct3import sys45SO_TIMESTAMPNS = getattr(socket, "SO_TIMESTAMPNS", 35) # 35 on x86_64 and arm64 Linux6port = int(sys.argv[1]) if len(sys.argv) > 1 else 900078sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)9sock.setsockopt(socket.SOL_SOCKET, SO_TIMESTAMPNS, 1)10sock.bind(("0.0.0.0", port))1112while True:13data, ancdata, _flags, _peer = sock.recvmsg(1232, socket.CMSG_SPACE(16))14if len(data) < 77:15continue # too short for slot and index, e.g. a text datagram16kernel_ns = None17for level, ctype, cdata in ancdata:18if level == socket.SOL_SOCKET and ctype == SO_TIMESTAMPNS:19sec, nsec = struct.unpack("qq", cdata[:16])20kernel_ns = sec * 1_000_000_000 + nsec21slot, index = struct.unpack_from("<QI", data, 65)22if kernel_ns is None:23continue # no kernel timestamp on this datagram24print(slot, index, f"{data[64]:#04x}", kernel_ns, flush=True)
Printing every line is fine for a test run. For long runs, write binary records or aggregate in memory, since a slow writer makes the socket queue grow and can drop packets.
Hardware timestamps#
With SO_TIMESTAMPING, the stamps arrive in a struct scm_timestamping with three slots. Software stamps go in ts[0] and hardware stamps in ts[2]:
1#include <linux/errqueue.h> /* struct scm_timestamping */2#include <linux/net_tstamp.h> /* SOF_TIMESTAMPING_* */34int flags = SOF_TIMESTAMPING_RX_SOFTWARE | SOF_TIMESTAMPING_SOFTWARE;5/* card stamps instead: SOF_TIMESTAMPING_RX_HARDWARE | SOF_TIMESTAMPING_RAW_HARDWARE, read ts[2] */6setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPING, &flags, sizeof flags);78/* after recvmsg, for the control message with cmsg_type == SCM_TIMESTAMPING: */9struct scm_timestamping ts;10memcpy(&ts, CMSG_DATA(c), sizeof ts);11/* ts.ts[0]: software stamp, ts.ts[2]: hardware stamp (zero when none) */
Hardware stamps need more than the socket flag. Run ethtool -T <interface> to see what the card supports, and enable receive stamping on the device, which needs admin rights. A hardware stamp comes from the card's own clock, so keep that clock disciplined to system time (chrony can use it as a refclock PHC source) before you compare it with anything else.
Keep the clock in sync#
If both sides of a comparison come from the same host, as in option 1, the clock's absolute error cancels. It only has to run steadily. If you compare against a timestamp made on another machine, such as an RPC node's firstShredReceived, the offset between the two clocks adds straight into every result.
- chrony (NTP). Run
chronyc trackingand readSystem time(the current offset between chrony's clock and the system clock) andRMS offset(a long-term average of the offset). Record both with your results. chrony normally corrects the clock by slewing it gradually rather than stepping it, but a step at startup can still happen, so let it settle before you start. - Hardware timestamping of NTP. The chrony
hwtimestampdirective makes the card stamp NTP packets, which removes kernel and driver delays from the offset chrony measures. It works best when the server side also uses hardware stamps. - PTP. Where your provider offers a PTP time source, a PTP client can discipline the card clock to it, and the system clock can then follow the card clock. Record the offsets it reports alongside your results.
Pair shreds and compute deltas#
Identify a shred by slot, index and type (data or coding): a data shred and a coding shred can share an index. Keep the first arrival of each key per source, then subtract. This script reads two logs in the format the Python receiver prints:
1import statistics2import sys345def first_seen(path):6"""Read 'slot index variant kernel_ns' lines; keep the earliest time per shred."""7seen = {}8with open(path) as f:9for line in f:10parts = line.split()11if len(parts) != 4 or not parts[3].isdigit():12continue # skip lines without a kernel timestamp13slot, index, variant, t = parts14kind = "code" if int(variant, 16) & 0xF0 in (0x40, 0x60, 0x70) or variant == "0x5a" else "data"15key = (int(slot), int(index), kind)16seen[key] = min(seen.get(key, int(t)), int(t))17return seen181920a, b = first_seen(sys.argv[1]), first_seen(sys.argv[2])21common = a.keys() & b.keys()22deltas_us = sorted((a[k] - b[k]) / 1000 for k in common) # negative: feed A was earlier23cuts = statistics.quantiles(deltas_us, n=100)24print(f"shreds on both: {len(common)} only A: {len(a.keys() - b.keys())} only B: {len(b.keys() - a.keys())}")25print(f"A earlier on {sum(d < 0 for d in deltas_us) / len(deltas_us):.1%} of shared shreds")26for p in (1, 10, 50, 90, 99):27print(f"percentile {p:>2}: A minus B = {cuts[p - 1]:9.1f} us")
1python3 rxts.py 9000 > a.log &2python3 rxts.py 9001 > b.log &3# collect for a long period, stop both receivers, then:4python3 compare.py a.log b.log
Your clock is lying goes further into chrony, PTP and cloud time services. To keep the timestamped data for later analysis, backtesting with captured shreds covers recording it.
Report a distribution, not one number#
Network delay has a long tail, and an average hides it. For each comparison, report:
- the percentiles of the difference, at least the median, the 90th and the 99th, plus a histogram;
- the share of shreds where each source arrived first;
- shreds seen on one source only, since loss on either side changes the picture;
- how long you collected and how many slots it covered, ideally hours across many leaders;
- your setup: software or hardware stamps, the chrony or PTP state, and where the server sits.
Check for drops on your own host before you trust the numbers. A full receive buffer discards datagrams, a discarded shred never reaches your log, and the counters and buffer settings in Linux sockets and buffers show whether that happened.
Comparing our two plans#
We publish no latency figure for either plan. The difference depends on your server's location and route, which is why this page exists. Delivery paths explains what differs between the direct and the relayed path. Run the same receiver, on the same machine, against each one, and compare the distributions. Where Solana latency comes from covers the parts of the path you cannot change. Back to the docs home.
Sources#
- Linux man-pages: socket(7), SO_TIMESTAMP and SO_TIMESTAMPNS (checked 2026-11-17)
- Linux kernel docs: Timestamping (checked 2026-11-17)
- chrony docs: chronyc tracking (checked 2026-11-17)
- chrony docs: chrony.conf (hwtimestamp, refclock PHC) (checked 2026-11-17)
- Solana docs: slotsUpdatesSubscribe (checked 2026-11-17)
- Solana docs: slotSubscribe (checked 2026-11-17)