Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PoC/example pure uring based UDP client and server #88

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xv-ian-c
Copy link
Contributor

Note

This is probably not for merging, more of a PoC.

Description

These are not fully featured and are basically the bare minimum to get a working pair of UDP client and server.

This builds on #87 since in this use case the allocations showed up in the flamegraphs and it was trivial to reuse buffers for both inside and outside I/O

This uses just 8 slots for rx of each of inside and outside traffic. Using any more degrades performance (I think because things get punted to iou-wrk threads instead of completing inline).

Motivation and Context

By building a pure I/O based event loop the hope was to cut out all the overhead relating to the use of async and make it possible to focus purely on the I/O bottlenecks.

How Has This Been Tested?

I ran some iperf tests using the containerized environment and also ran some speedtests with two machines directly connected with a cross over test against a nearby speedtest server.

iperf results were marginal/in the noise, speedtest results improved from ~1.4G/sec download to 1.6G/sec and ~700M/sec upload to 1.2G/sec. The latency was roughly halved though.

@xv-ian-c xv-ian-c requested a review from a team as a code owner September 26, 2024 07:37
@xv-ian-c xv-ian-c force-pushed the CVPN-1221-native-uring-udp-examples branch 5 times, most recently from eb21339 to b8bf495 Compare September 26, 2024 08:16
Copy link

github-actions bot commented Sep 26, 2024

Code coverage summary for 55bbabe:

Filename                                                     Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lightway-app-utils/src/args/cipher.rs                              7                 7     0.00%           2                 2     0.00%           6                 6     0.00%           0                 0         -
lightway-app-utils/src/args/connection_type.rs                     7                 7     0.00%           2                 2     0.00%           6                 6     0.00%           0                 0         -
lightway-app-utils/src/args/duration.rs                           10                10     0.00%           7                 7     0.00%          15                15     0.00%           0                 0         -
lightway-app-utils/src/args/ip_map.rs                             11                11     0.00%           3                 3     0.00%          15                15     0.00%           0                 0         -
lightway-app-utils/src/args/logging.rs                            20                20     0.00%           4                 4     0.00%          18                18     0.00%           0                 0         -
lightway-app-utils/src/connection_ticker.rs                       44                 4    90.91%          17                 2    88.24%         156                 5    96.79%           0                 0         -
lightway-app-utils/src/dplpmtud_timer.rs                          70                 7    90.00%          22                 4    81.82%         282                11    96.10%           0                 0         -
lightway-app-utils/src/event_stream.rs                             6                 0   100.00%           3                 0   100.00%          13                 0   100.00%           0                 0         -
lightway-app-utils/src/iouring.rs                                154               133    13.64%          23                14    39.13%         304               276     9.21%           0                 0         -
lightway-app-utils/src/metrics.rs                                 18                18     0.00%          18                18     0.00%          36                36     0.00%           0                 0         -
lightway-app-utils/src/sockopt/ip_mtu_discover.rs                 23                23     0.00%           4                 4     0.00%          93                93     0.00%           0                 0         -
lightway-app-utils/src/sockopt/ip_pktinfo.rs                       4                 4     0.00%           1                 1     0.00%          16                16     0.00%           0                 0         -
lightway-app-utils/src/tun.rs                                     82                82     0.00%          22                22     0.00%          84                84     0.00%           0                 0         -
lightway-app-utils/src/utils.rs                                    8                 8     0.00%           1                 1     0.00%           9                 9     0.00%           0                 0         -
lightway-client/src/args.rs                                       33                33     0.00%          31                31     0.00%          31                31     0.00%           0                 0         -
lightway-client/src/io/inside/tun.rs                              42                42     0.00%           7                 7     0.00%          47                47     0.00%           0                 0         -
lightway-client/src/io/outside/tcp.rs                             48                48     0.00%          10                10     0.00%          44                44     0.00%           0                 0         -
lightway-client/src/io/outside/udp.rs                             59                59     0.00%          12                12     0.00%          59                59     0.00%           0                 0         -
lightway-client/src/keepalive.rs                                 277                49    82.31%          56                 8    85.71%         372                26    93.01%           0                 0         -
lightway-client/src/lib.rs                                       186               186     0.00%          20                20     0.00%         272               272     0.00%           0                 0         -
lightway-client/src/main.rs                                       47                47     0.00%           6                 6     0.00%         174               174     0.00%           0                 0         -
lightway-core/src/borrowed_bytesmut.rs                            87                 1    98.85%          24                 0   100.00%         196                 1    99.49%           0                 0         -
lightway-core/src/builder_predicates.rs                           20                10    50.00%           4                 2    50.00%          32                16    50.00%           0                 0         -
lightway-core/src/cipher.rs                                       10                 0   100.00%           4                 0   100.00%          14                 0   100.00%           0                 0         -
lightway-core/src/connection.rs                                  475               235    50.53%          48                19    60.42%         655               279    57.40%           0                 0         -
lightway-core/src/connection/builders.rs                          62                22    64.52%          17                 6    64.71%         217                48    77.88%           0                 0         -
lightway-core/src/connection/dplpmtud.rs                         767                90    88.27%          69                 1    98.55%         950                11    98.84%           0                 0         -
lightway-core/src/connection/fragment_map.rs                     139                11    92.09%          29                 0   100.00%         292                 7    97.60%           0                 0         -
lightway-core/src/connection/io_adapter.rs                       149                17    88.59%          42                 5    88.10%         319                23    92.79%           0                 0         -
lightway-core/src/connection/key_update.rs                        23                 7    69.57%           5                 0   100.00%          38                19    50.00%           0                 0         -
lightway-core/src/context.rs                                      93                25    73.12%          26                 7    73.08%         199                40    79.90%           0                 0         -
lightway-core/src/context/ip_pool.rs                               7                 3    57.14%           1                 0   100.00%           6                 0   100.00%           0                 0         -
lightway-core/src/context/server_auth.rs                          14                11    21.43%           4                 3    25.00%          24                20    16.67%           0                 0         -
lightway-core/src/io.rs                                            3                 3     0.00%           3                 3     0.00%          10                10     0.00%           0                 0         -
lightway-core/src/lib.rs                                           9                 6    33.33%           4                 1    75.00%          18                 9    50.00%           0                 0         -
lightway-core/src/metrics.rs                                       7                 7     0.00%           5                 5     0.00%          13                13     0.00%           0                 0         -
lightway-core/src/packet.rs                                       27                 7    74.07%           4                 1    75.00%          30                 6    80.00%           0                 0         -
lightway-core/src/plugin.rs                                       70                 8    88.57%          25                 5    80.00%         162                 9    94.44%           0                 0         -
lightway-core/src/utils.rs                                       111                19    82.88%          26                 0   100.00%         184                11    94.02%           0                 0         -
lightway-core/src/version.rs                                      49                 0   100.00%          24                 0   100.00%          94                 0   100.00%           0                 0         -
lightway-core/src/wire.rs                                        154                19    87.66%          39                 0   100.00%         263                 2    99.24%           0                 0         -
lightway-core/src/wire/auth_failure.rs                             9                 1    88.89%           3                 0   100.00%          19                 0   100.00%           0                 0         -
lightway-core/src/wire/auth_request.rs                           152                12    92.11%          37                 0   100.00%         290                 0   100.00%           0                 0         -
lightway-core/src/wire/auth_success_with_config_ipv4.rs           69                 4    94.20%          13                 0   100.00%         145                 0   100.00%           0                 0         -
lightway-core/src/wire/data.rs                                    21                 1    95.24%           7                 0   100.00%          43                 0   100.00%           0                 0         -
lightway-core/src/wire/data_frag.rs                               47                 1    97.87%          19                 0   100.00%          94                 0   100.00%           0                 0         -
lightway-core/src/wire/ping.rs                                    24                 3    87.50%           8                 0   100.00%          69                 0   100.00%           0                 0         -
lightway-core/src/wire/pong.rs                                    15                 2    86.67%           5                 0   100.00%          34                 0   100.00%           0                 0         -
lightway-core/src/wire/server_config.rs                           20                 2    90.00%           5                 0   100.00%          44                 0   100.00%           0                 0         -
lightway-server/src/args.rs                                       30                30     0.00%          28                28     0.00%          28                28     0.00%           0                 0         -
lightway-server/src/connection.rs                                 50                50     0.00%          23                23     0.00%         107               107     0.00%           0                 0         -
lightway-server/src/connection_manager.rs                        101               101     0.00%          33                33     0.00%         211               211     0.00%           0                 0         -
lightway-server/src/connection_manager/connection_map.rs          90                 9    90.00%          27                 2    92.59%         274                 9    96.72%           0                 0         -
lightway-server/src/io/inside/tun.rs                              28                28     0.00%           8                 8     0.00%          33                33     0.00%           0                 0         -
lightway-server/src/io/outside/tcp.rs                             46                46     0.00%           8                 8     0.00%          46                46     0.00%           0                 0         -
lightway-server/src/io/outside/udp.rs                            133               133     0.00%          17                17     0.00%         237               237     0.00%           0                 0         -
lightway-server/src/io/outside/udp/cmsg.rs                        47                16    65.96%          14                 5    64.29%         233                56    75.97%           0                 0         -
lightway-server/src/ip_manager.rs                                 82                25    69.51%          19                 4    78.95%         254                28    88.98%           0                 0         -
lightway-server/src/ip_manager/ip_pool.rs                         83                 2    97.59%          28                 0   100.00%         249                 0   100.00%           0                 0         -
lightway-server/src/lib.rs                                        94                94     0.00%          11                11     0.00%         133               133     0.00%           0                 0         -
lightway-server/src/main.rs                                       54                54     0.00%           6                 6     0.00%         164               164     0.00%           0                 0         -
lightway-server/src/metrics.rs                                    79                77     2.53%          70                68     2.86%         178               174     2.25%           0                 0         -
lightway-server/src/statistics.rs                                 56                24    57.14%           9                 4    55.56%         104                42    59.62%           0                 0         -
uring-udp-client/src/main.rs                                     137               137     0.00%          17                17     0.00%         347               347     0.00%           0                 0         -
uring-udp-server/src/main.rs                                     161               161     0.00%          19                19     0.00%         404               404     0.00%           0                 0         -
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                           5060              2312    54.31%        1108               489    55.87%        9508              3786    60.18%           0                 0         -

✅ Region coverage 54% passes
✅ Line coverage 60% passes

@xv-ian-c xv-ian-c force-pushed the CVPN-1221-borrowed-buffers branch from cbd1014 to ef59f7e Compare September 26, 2024 08:20
@xv-ian-c xv-ian-c force-pushed the CVPN-1221-native-uring-udp-examples branch 2 times, most recently from 3d6d4d1 to daafa1a Compare September 26, 2024 08:33
Base automatically changed from CVPN-1221-borrowed-buffers to main September 30, 2024 07:14
These are not fully featured and are basically the bare minimum to get a
working pair of UDP client and server.

By building a pure I/O based event loop the hope was to cut out all the
overhead relating to the use of async and make it possible to focus purely on
the I/O bottlenecks.
@xv-ian-c xv-ian-c force-pushed the CVPN-1221-native-uring-udp-examples branch from daafa1a to 55bbabe Compare September 30, 2024 08:15
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.

1 participant