Skip to content

[RFC] Hand an RPC off on the last packet of a batch - #154

Open
breakertt wants to merge 1 commit into
PlatformLab:mainfrom
breakertt:feat/handoff-at-batch-end
Open

breakertt wants to merge 1 commit into
PlatformLab:mainfrom
breakertt:feat/handoff-at-batch-end

Conversation

@breakertt

Copy link
Copy Markdown
Contributor

This is an RFC, as in the upstream Linux kernel community, it is more for comments.

homa_dispatch_pkts holds the RPC lock while it gives a batch of packets of one RPC to homa_data_pkt. But homa_data_pkt hands the RPC off on the first packet of the batch. The woken thread sets APP_NEEDS_LOCK while SoftIRQ still has packets of that batch, so SoftIRQ releases the lock and waits for the thread.

This patch hands the RPC off after homa_data_pkt queues the last packet of its batch (skb->next is NULL), and homa_rpc_alloc_server no longer hands off. A batch of one packet is handed off as before.

cp_node on two CloudLab xl170 nodes (SMT, turbo and C-states off). Two loads of each module, interleaved, and 5 runs per load. kops is the median of each load. The other columns are server counters:

receive path load main 07ce63e kops patch kops change RPC lock waits per 1000 DATA packets homa_softirq ns per DATA packet
NAPI and SoftIRQ on core 0 (no RPS) 8 KB, 100 in flight 184.64, 184.45 202.40, 201.70 +9.5 % 215 → 16 476 → 396
64 KB, 20 in flight 15.87, 15.79 16.60, 16.56 +4.7 % 137 → 31 358 → 298
hijack_tcp, NAPI and SoftIRQ on cores 0 and 1 (2 RX queues, no RPS) 64 KB, 20 in flight 27.89, 27.88 28.98, 28.96 +3.9 % 124 → 34 334 → 283
Gen2, NAPI on core 0, SoftIRQ on other cores 64 KB, 20 in flight 22.33, 22.28 22.30, 22.26 -0.1 % 87 → 28 360 → 327
  • With every receive path, the patch removes 68 % to 92 % of the lock waits. It also removes 9.0 % to 16.9 % of the homa_softirq time per packet. In the first row, 199 fewer waits per 1000 packets save 80 ns per packet, about 400 ns per wait.
  • The saved SoftIRQ time turns into throughput when SoftIRQ runs on the core that does NAPI and that core is the bottleneck. When RPS is off, SoftIRQ runs on the NAPI core: Homa's SoftIRQ steering needs the RFS flow table. RSS puts the packets of one address pair on one queue (with hijack_tcp, of one port pair).
  • With Gen2, SoftIRQ runs on other cores, which are not the bottleneck, and throughput does not change.

Reproduction, all cp_node commands and the raw logs: https://github.com/breakertt/HomaModule/tree/feat-artifact/handoff-at-batch-end

* homa_dispatch_pkts holds the RPC lock while it processes a batch of
  packets for one RPC, but homa_data_pkt handed the RPC off on the first
  packet of the batch (homa_rpc_alloc_server did so even before the
  packet was queued). The woken thread then asked for the RPC lock while
  SoftIRQ still needed it, so SoftIRQ released the lock in the middle of
  the batch and waited to get it back.
* Now homa_data_pkt hands the RPC off after it queues the last packet of
  its batch (skb->next is NULL, read before the packet is queued), and
  homa_rpc_alloc_server no longer hands off. A batch of one packet is
  handed off as before.
@johnousterhout

Copy link
Copy Markdown
Member

Thanks for the PR and the performance measurements. I like the fix, except for its location. Adding the check of skb->next in homa_data_pkt is information leakage: that function doesn't currently know anything about batches of packets. Can you move the code to homa_dispatch_pkts, which does know about batches? For example, I think it might fit well next to the call to homa_grant_check_rpc.

BTW, the original reason for calling homa_rpc_handoff in homa_rpc_alloc_server was to reduce the number of acquisitions of the socket lock: that function already has to acquire the lock for other reasons, and the idea was to invoke homa_rpc_handoff while still holding the socket (otherwise it would have to be acquired again later). However, at some point it seems that lock usage in homa_rpc_alloc_server changed so that it releases the socket lock and then homa_rpc_handoff acquires it again. Thus the motivation for calling homa_rpc_handoff in homa_rpc_alloc_server no longer exists (and it was somewhat ugly and information-leaky to have it there). So I'm glad to get rid of that, particularly since it doesn't seem to hurt performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants