2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Use the original threadid when sending a UDP packet to decrease probability of context switching

This commit is contained in:
Witold Kręcicki
2020-01-29 09:29:19 +01:00
parent c324230c6f
commit eb874608c1

View File

@@ -383,8 +383,16 @@ isc__nm_udp_send(isc_nmhandle_t *handle, isc_region_t *region, isc_nm_cb_t cb,
return (ISC_R_CANCELED);
}
/*
* If we're in netthread - send it directly
* If the original packet was received over a regular socket
* - send it over the same thread (assuming cpu affinity)
* Otherwise - use a random thread.
*/
if (isc__nm_in_netthread()) {
ntid = isc_nm_tid();
} else if (sock->type == isc_nm_udpsocket) {
ntid = sock->tid;
} else {
ntid = (int)isc_random_uniform(sock->nchildren);
}