Skip to content

Instantly share code, notes, and snippets.

@ldelossa
Created November 28, 2026 03:48
Show Gist options
  • Select an option

  • Save ldelossa/7e7b28cfa52801bbb2ee05b1e3399d64 to your computer and use it in GitHub Desktop.

Select an option

Save ldelossa/7e7b28cfa52801bbb2ee05b1e3399d64 to your computer and use it in GitHub Desktop.
VinE performance analysis

A noticeable throughput increase in IPsec-enabled pod-to-pod traffic was observed as a result of the VinE implementation.

The initial assumption framed GSO as the likely factors in this performance increase, but the actual evidence and root cause were never discovered.

This performance analysis sets out to confirm that there is, in fact, a throughput increase and to determine its root cause.

Testing environment and terminology

Firstly, two base commits were identified for building the test Cilium images. Before VinE: Baseline commit f90fd95 After VinE: VinE commit 50322f0

Moving forward, we will simply refer to the pre-VinE cluster as before and the post-VinE cluster as after.

The chosen base commits demonstrate a minimum set of diffs between the legacy IPsec datapath and the initial but complete VinE IPsec datapath.

Two identical GKE clusters were configured, one deployed with the before image and the other deployed with the after image.

Detail
GKE mode / version Standard / 1.32.13-gke.3169000
Workers Two c4-standard-8 nodes per cluster
Node OS Ubuntu 24.04.5, Linux 6.8.0-1068-gke
CPU Intel Xeon Platinum 8581C
NIC gve 1.0.0 on ens3, MTU 1460
NIC offloads TSO, GSO and GRO on; ESP and UDP-tunnel segmentation off [fixed]
Both Cilium images are configured identically because VinE became the default IPsec datapath after implementation.
Helm Key Value on both clusters
routingMode / tunnelProtocol tunnel / vxlan
ipam.mode kubernetes
encryption.enabled / encryption.type true / ipsec
encryption.nodeEncryption false
encryption.ipsec.encryptedOverlay false
encryption.ipsec.secretName cilium-ipsec-keys
gke.enabled false
nodeinit.enabled true
nodeinit.reconfigureKubelet / removeCbrBridge true / true
cni.binPath /home/kubernetes/bin
MTU 0 (automatic; observed Pod route MTU 1333)
hubble.enabled / l7Proxy / envoy.enabled false / false / false
NOTE: GKE cloud detection is disabled so VXLAN tunnel mode can be enabled.

The same set of pods was used across both clusters for the performance analysis.

Pod Namespace Role
iperf-client vine-bench Runs the iperf3 client on one worker.
iperf-server vine-bench Listens on TCP port 5201 on the other worker.
vine-host-inspect vine-bench-monitor Runs host-side perf and packet captures for profiling and validation

Analysis

Throughput measurement

iperf3 was used to immediately demonstrate a substantial throughput difference between the before and after deployments.

The same command was run against both clusters.

iperf3 -c <server-pod-ip> -t 30 -O 5 -P 1
Flag Purpose
-c <server-pod-ip> Connect directly to the server Pod on another worker.
-t 30 Measure throughput for 30 seconds.
-O 5 Send for five warmup seconds before measurement.
-P 1 Use one TCP stream.
Both the server and client iperf3 pods are subjected to Cilium's IPsec encryption datapath under test.

Results

before cluster:

[  4] local 10.42.24.213 port 60754 connected to 10.42.25.201 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  4]   0.00-1.00   sec   271 MBytes  2.27 Gbits/sec  126    564 KBytes       (omitted)
[  4]   1.00-2.00   sec   220 MBytes  1.85 Gbits/sec    1    783 KBytes       (omitted)
[  4]   2.00-3.00   sec   222 MBytes  1.86 Gbits/sec    0    956 KBytes       (omitted)
[  4]   3.00-4.00   sec   223 MBytes  1.87 Gbits/sec    0   1.08 MBytes       (omitted)
[  4]   1.00-1.00   sec   301 MBytes  1.26 Gbits/sec    7   1.03 MBytes
[  4]   1.00-2.00   sec   326 MBytes  2.73 Gbits/sec    0   1.16 MBytes
[  4]   2.00-3.00   sec   324 MBytes  2.72 Gbits/sec    0   1.33 MBytes
[  4]   3.00-4.00   sec   327 MBytes  2.75 Gbits/sec    0   1.48 MBytes
[  4]   4.00-5.00   sec   329 MBytes  2.76 Gbits/sec   38   1.19 MBytes
[  4]   5.00-6.00   sec   330 MBytes  2.76 Gbits/sec    0   1.35 MBytes
[  4]   6.00-7.00   sec   315 MBytes  2.64 Gbits/sec   25   1.44 MBytes
[  4]   7.00-8.00   sec   324 MBytes  2.71 Gbits/sec   35   1.07 MBytes
[  4]   8.00-9.00   sec   314 MBytes  2.63 Gbits/sec    1   1.18 MBytes
[  4]   9.00-10.00  sec   285 MBytes  2.39 Gbits/sec    0   1.18 MBytes
[  4]  10.00-11.00  sec   321 MBytes  2.69 Gbits/sec    0   1.18 MBytes
[  4]  11.00-12.00  sec   319 MBytes  2.68 Gbits/sec    0   1.18 MBytes
[  4]  12.00-13.00  sec   319 MBytes  2.68 Gbits/sec    0   1.19 MBytes
[  4]  13.00-14.00  sec   323 MBytes  2.71 Gbits/sec    0   1.20 MBytes
[  4]  14.00-15.00  sec   326 MBytes  2.73 Gbits/sec    0   1.35 MBytes
[  4]  15.00-16.00  sec   327 MBytes  2.74 Gbits/sec   19   1.06 MBytes
[  4]  16.00-17.00  sec   323 MBytes  2.71 Gbits/sec   29   1.12 MBytes
[  4]  17.00-18.00  sec   318 MBytes  2.67 Gbits/sec    0   1.13 MBytes
[  4]  18.00-19.00  sec   319 MBytes  2.68 Gbits/sec    0   1.17 MBytes
[  4]  19.00-20.00  sec   331 MBytes  2.78 Gbits/sec    0   1.34 MBytes
[  4]  20.00-21.00  sec   330 MBytes  2.76 Gbits/sec    3   1.05 MBytes
[  4]  21.00-22.00  sec   330 MBytes  2.77 Gbits/sec    0   1.24 MBytes
[  4]  22.00-23.00  sec   327 MBytes  2.75 Gbits/sec    0   1.40 MBytes
[  4]  23.00-24.00  sec   326 MBytes  2.73 Gbits/sec    1   1.54 MBytes
[  4]  24.00-25.00  sec   327 MBytes  2.74 Gbits/sec   23   1.22 MBytes
[  4]  25.00-26.00  sec   322 MBytes  2.70 Gbits/sec    0   1.35 MBytes
[  4]  26.00-27.00  sec   303 MBytes  2.54 Gbits/sec  185   1.40 MBytes
[  4]  27.00-28.00  sec   306 MBytes  2.57 Gbits/sec  449   1.49 MBytes
[  4]  28.00-29.00  sec   327 MBytes  2.74 Gbits/sec   24   1.22 MBytes
[  4]  29.00-30.00  sec   326 MBytes  2.73 Gbits/sec    0   1.38 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  4]   0.00-30.00  sec  9.47 GBytes  2.71 Gbits/sec  839            sender
[  4]   0.00-30.00  sec  9.47 GBytes  2.71 Gbits/sec                  receiver

after cluster:

  4] local 10.20.144.117 port 43808 connected to 10.20.145.128 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  4]   0.00-1.00   sec   521 MBytes  4.36 Gbits/sec   58   1.31 MBytes       (omitted)
[  4]   1.00-2.00   sec   516 MBytes  4.33 Gbits/sec   30   1.17 MBytes       (omitted)
[  4]   2.00-3.00   sec   516 MBytes  4.33 Gbits/sec    1   1.42 MBytes       (omitted)
[  4]   3.00-4.00   sec   519 MBytes  4.36 Gbits/sec    9   1.27 MBytes       (omitted)
[  4]   1.00-1.00   sec   520 MBytes  2.18 Gbits/sec    0   1.36 MBytes
[  4]   1.00-2.00   sec   520 MBytes  4.37 Gbits/sec    9   1.22 MBytes
[  4]   2.00-3.00   sec   520 MBytes  4.36 Gbits/sec   31   1.04 MBytes
[  4]   3.00-4.00   sec   520 MBytes  4.36 Gbits/sec    0   1.31 MBytes
[  4]   4.00-5.00   sec   522 MBytes  4.38 Gbits/sec    3   1.16 MBytes
[  4]   5.00-6.00   sec   516 MBytes  4.32 Gbits/sec   16   1.01 MBytes
[  4]   6.00-7.00   sec   514 MBytes  4.31 Gbits/sec    4   1.28 MBytes
[  4]   7.00-8.00   sec   516 MBytes  4.33 Gbits/sec   25   1.10 MBytes
[  4]   8.00-9.00   sec   520 MBytes  4.36 Gbits/sec    0   1.37 MBytes
[  4]   9.00-10.00  sec   520 MBytes  4.37 Gbits/sec   28   1.20 MBytes
[  4]  10.00-11.00  sec   521 MBytes  4.37 Gbits/sec    0   1.46 MBytes
[  4]  11.00-12.00  sec   521 MBytes  4.37 Gbits/sec   35   1.31 MBytes
[  4]  12.00-13.00  sec   520 MBytes  4.36 Gbits/sec   22   1.13 MBytes
[  4]  13.00-14.00  sec   519 MBytes  4.36 Gbits/sec    0   1.39 MBytes
[  4]  14.00-15.00  sec   521 MBytes  4.37 Gbits/sec    2   1.25 MBytes
[  4]  15.00-16.00  sec   520 MBytes  4.36 Gbits/sec   21   1.06 MBytes
[  4]  16.00-17.00  sec   520 MBytes  4.36 Gbits/sec   10   1.33 MBytes
[  4]  17.00-18.00  sec   517 MBytes  4.34 Gbits/sec   11   1.20 MBytes
[  4]  18.00-19.00  sec   517 MBytes  4.33 Gbits/sec    0   1.45 MBytes
[  4]  19.00-20.00  sec   522 MBytes  4.38 Gbits/sec   17   1.29 MBytes
[  4]  20.00-21.00  sec   518 MBytes  4.35 Gbits/sec   12   1.12 MBytes
[  4]  21.00-22.00  sec   521 MBytes  4.37 Gbits/sec    0   1.38 MBytes
[  4]  22.00-23.00  sec   522 MBytes  4.38 Gbits/sec    1   1.22 MBytes
[  4]  23.00-24.00  sec   516 MBytes  4.33 Gbits/sec  487   1.41 MBytes
[  4]  24.00-25.00  sec   523 MBytes  4.39 Gbits/sec   24   1.25 MBytes
[  4]  25.00-26.00  sec   522 MBytes  4.38 Gbits/sec   21   1.07 MBytes
[  4]  26.00-27.00  sec   520 MBytes  4.36 Gbits/sec    0   1.35 MBytes
[  4]  27.00-28.00  sec   522 MBytes  4.38 Gbits/sec   28   1.17 MBytes
[  4]  28.00-29.00  sec   520 MBytes  4.36 Gbits/sec    0   1.43 MBytes
[  4]  29.00-30.00  sec   524 MBytes  4.39 Gbits/sec   43   1.29 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  4]   0.00-30.00  sec  15.2 GBytes  4.36 Gbits/sec  850            sender
[  4]   0.00-30.00  sec  15.2 GBytes  4.36 Gbits/sec                  receiver

The VinE implementation improves throughput by a large ~60% on average.

This result is highly reproducible.

UDP and ESP hardware offloads are disabled on both clusters.

This leads us to believe that this performance increase is solely attributable to the change in datapath.

Legacy VS VinE Datapath

Before analyzing the performance improvement further, a review of both the legacy and the new VinE datapath is useful.

Legacy:

flowchart LR
   subgraph POD["Pod netns"]
	   APP["Pod application"] --> PV["Pod-side veth"]
   end

   subgraph HOST["Sender host netns"]
	   HV["Host-side veth<br/>bpf_lxc"]
	   MARK["IPsec mark"]
	   XFRM["Linux routing<br/>-><br/>XFRM encryption"]
	   HBPF["Cilium host-side BPF"]
	   VX["VXLAN device"]
	   ENCAP["VXLAN encapsulation"]
	   NIC["eth0 transmit"]

	   HV --> MARK --> XFRM --> HBPF
	   HBPF -->|eBPF redirect| VX
	   VX --> ENCAP --> NIC
   end

   subgraph WIRE["Underlay / on wire"]
	   FORMAT["UDP/VXLAN carrying ESP"]
   end

   PV --> HV
   NIC --> FORMAT
Loading

The legacy datapath performs XFRM encryption prior to VXLAN encapsulation.

VinE:

flowchart LR
   subgraph POD["Pod netns"]
	   APP["Pod application"] --> PV["Pod-side veth"]
   end

   subgraph HOST["Sender host netns"]
	   HV["Host-side veth<br/>bpf_lxc"]
	   VX["VXLAN device"]
	   ENCAP["VXLAN encapsulation"]
	   PRE["eth0 TC egress<br/>before transmission"]
	   HAIRPIN["IPsec mark<br/>redirect to cilium_net ingress"]
	   XFRM["Linux forwarding<br/>XFRM encryption"]
	   NIC["eth0 transmit"]

	   HV -->|eBPF redirect| VX
	   VX --> ENCAP --> PRE --> HAIRPIN --> XFRM --> NIC
   end

   subgraph WIRE["Underlay / on wire"]
	   FORMAT["ESP carrying encrypted VXLAN"]
   end

   PV --> HV
   NIC --> FORMAT
Loading

VinE takes a somewhat novel approach to achieve VXLAN encapsulation prior to XFRM encryption.

The VXLAN encapsulation is performed first; native routing will naturally attempt to egress the packet toward its next hop, and Cilium's datapath will redirect the VXLAN egress packet back into the ingress path for XFRM evaluation.

Finding the bottleneck

When this performance improvement was discovered, the immediate thought was that GSO processing played a role; however, no formal investigation was performed.

While GSO is a likely factor here, it's worth taking a holistic look at the kernel's performance and investigating it in a top-down manner.

The perf tool is used to capture which kernel functions are executed during the same iperf3 tests above, and this is performed on the before and after clusters.

perf is run from the vine-host-inspect containers on each node:

client perf record -a -e cycles -F 99 -g -o "/tmp/perf" -- sleep 40

The first report is shown without child aggregation and with a kallsyms file pulled directly from each cluster's node.

perf report --no-children --sort dso,symbol --kallsyms kallsyms.txt

before:

# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 9K of event 'cycles'
# Event count (approx.): 157867823332
#
# Overhead  Shared Object                                           Symbol                                                      IPC   [IPC Coverage]
# ........  ......................................................  ..........................................................  ....................
#
    11.20%  [nf_tables]                                             [k] nft_do_chain                                            -      -            
            |
            ---nft_do_chain
               |          
               |--9.71%--nft_do_chain_ipv4
               |          nf_hook_slow
               |          |          
               |          |--7.60%--__ip_local_out
               |          |          |          
               |          |          |--4.63%--ip_local_out
               |          |          |          |          
               |          |          |           --4.62%--iptunnel_xmit
               |          |          |                     udp_tunnel_xmit_skb
               |          |          |                     vxlan_xmit_one
               |          |          |                     vxlan_xmit
               |          |          |                     dev_hard_start_xmit
               |          |          |                     __dev_queue_xmit
               |          |          |                     __bpf_redirect
               |          |          |                     skb_do_redirect
               |          |          |                     __dev_queue_xmit
               |          |          |                     neigh_hh_output
               |          |          |                     ip_finish_output2
               |          |          |                     __ip_finish_output
               |          |          |                     ip_finish_output
               |          |          |                     ip_output
               |          |          |                     xfrm_output_resume
               |          |          |                     xfrm_output_gso.isra.0
               |          |          |                     xfrm_output
               |          |          |                     __xfrm4_output
               |          |          |                     xfrm4_output
               |          |          |                     ip_forward_finish
               |          |          |                     ip_forward
               |          |          |                     ip_rcv
               |          |          |                     __netif_receive_skb_one_core
               |          |          |                     __netif_receive_skb
               |          |          |                     process_backlog
               |          |          |                     __napi_poll
               |          |          |                     net_rx_action
               |          |          |                     handle_softirqs
               |          |          |                     |          
               |          |          |                     |--2.90%--run_ksoftirqd
               |          |          |                     |          smpboot_thread_fn
               |          |          |                     |          kthread
               |          |          |                     |          ret_from_fork
               |          |          |                     |          ret_from_fork_asm
               |          |          |                     |          
               |          |          |                      --1.70%--__do_softirq

after:

# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 10K of event 'cycles'
# Event count (approx.): 143775239922
#
# Overhead  Shared Object                                    Symbol                                               IPC   [IPC Coverage]
# ........  ...............................................  ...................................................  ....................
#
     9.01%  [aesni_intel]                                    [k] key_128_enc_update                               -      -            
            |
            ---key_128_enc_update

     8.86%  [nf_tables]                                      [k] nft_do_chain                                     -      -            
            |
            ---nft_do_chain
               |          
               |--7.15%--nft_do_chain_ipv4
               |          nf_hook_slow
               |          |          
               |          |--5.27%--__ip_local_out
               |          |          |          
               |          |           --5.07%--xfrm_output_resume
               |          |                     xfrm_output_gso.isra.0
               |          |                     xfrm_output
               |          |                     __xfrm4_output
               |          |                     xfrm4_output
               |          |                     ip_forward_finish
               |          |                     ip_forward
               |          |                     ip_rcv
               |          |                     __netif_receive_skb_one_core
               |          |                     __netif_receive_skb
               |          |                     process_backlog
               |          |                     __napi_poll
               |          |                     net_rx_action
               |          |                     handle_softirqs
               |          |                     |          
               |          |                      --4.69%--__irq_exit_rcu
               |          |                                irq_exit_rcu
               |          |                                |          
               |          |                                 --4.66%--common_interrupt
               |          |                                           asm_common_interrupt
               |          |                                           |          
               |          |                                            --4.54%--cpuidle_enter_state
               |          |                                                      cpuidle_enter
               |          |                                                      call_cpuidle
               |          |                                                      cpuidle_idle_call
               |          |                                                      do_idle
               |          |                                                      cpu_startup_entry
               |          |                                                      start_secondary
               |          |                                                      secondary_startup_64_no_verify
               |          |          

Comparing both the before and after profiles, our attention is immediately drawn to the amount of time spent in the iptunnel_xmit / vxlan_xmit path.

If we dig into the child aggregate view, we see an even cleaner signal.

before:

   35.34%     0.19%  [vxlan]  [.] vxlan_xmit              -      -                                  ▒
   - 35.15% vxlan_xmit                                                                               ▒
      - 35.13% vxlan_xmit_one                                                                        ▒
         - 29.54% udp_tunnel_xmit_skb                                                                ▒

after:

-    1.29%     0.03%  [vxlan]  [.] vxlan_xmit              -      -                                  ▒
   - 1.26% vxlan_xmit                                                                                ▒
      - 1.26% vxlan_xmit_one                                                                         ▒
         + 1.06% udp_tunnel_xmit_skb

As a sanity check, a bpftrace script is used to count the total number of vxlan_xmit invocations keyed by the source IP address.

The script runs during an abbreviated iperf3 test of 10 seconds on both clusters.

!/usr/bin/env bpftrace

kprobe:vxlan_xmit
{
    @total_calls = count();
    $skb = (struct sk_buff *)arg0;
    if ($skb->protocol == 0x0008) {
        $ip = (struct iphdr *)((uint64)$skb->head + $skb->network_header);
        if ($ip->version == 4 && $ip->ihl >= 5) {
            @ipv4_by_src[ntop($ip->saddr)] = count();
        } else {
            @invalid_ipv4_header = count();
        }
    } else {
        @non_ipv4 = count();
    }
}

interval:s:20
{
    exit();
}

before:

@ipv4_by_src[10.42.24.70]: 2429692
@total_calls: 2429696

after:

@ipv4_by_src[10.20.144.117]: 82184
@total_calls: 82185

In the before cluster, 10.42.24.70 is the cilium_host address on the client worker; in the after cluster, 10.20.144.117 is the iperf-client pod IP.

In the VinE path, we are doing ~96% fewer vxlan_xmit invocations.

GSO implications

In both the legacy and the VinE datapaths, XFRM performs GSO segmentation.

However, GSO segmentation happens at very different locations between both paths.

Legacy:
 TCP GSO skb
   -> XFRM segments it into N skbs
   -> each skb is encrypted as ESP
   -> each ESP skb goes through vxlan_xmit
	  (tunnel lookup, encapsulation, local output, etc.)
VinE:
 TCP GSO skb
   -> one vxlan_xmit on the still-large skb
   -> XFRM's GSO path produces N encapsulated segments
   -> each segment is encrypted as ESP
   -> each segment egresses 

The bottleneck in the legacy path emerges because every GSO segment is subjected to the vxlan_xmit path.

This path performs the entire VXLAN encapsulation pipeline, including tunnel lookup and tunnel metadata parsing, VNI identification, header creation and copying, etc.

Contrast this with the VinE datapath, where a GSO super packet moves from pod egress -> vxlan encapsulation -> egress device redirect -> xfrm output and is finally GSO segmented.

Summary

The legacy datapath forced GSO segmentation immediately after pod egress and within the XFRM output path.

This caused GSO super packets to be segmented, and each individual segment to be redirected into the vxlan_xmit path, causing a fan-out of complexity.

Each segment needed the VXLAN encapsulation pipeline to be applied: looking up tunnel info, parsing tunnel metadata, etc.

In the VinE datapath, GSO segmentation is deferred until just before egressing the node.

This allowed a single GSO super packet to be VXLAN encapsulated and pushed through the host stack up until final XFRM output processing.

In addition to a huge reduction in packets moving through the stack, once the GSO packet arrives at the XFRM-initiated GSO segmentation routine, the generic UDP tunnel segmentation routine is invoked. Broadly speaking, the GSO routine simply copies the VXLAN header into the segment and updates checksums.

This results in a faster datapath and explains the increase in throughput.

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