mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-08-07 04:59:49 +00:00
perf(wasi): optimize data plane and extend host ABI to v3 (#2455)
Overhaul the WASI guest data plane for throughput and add the host capabilities it relies on. The externally driven Tokio runtime now runs its timer pre-turn only when a tracked deadline has expired, and all WASI-reachable timers (STUN, port mapping, WebClient, UDP flow cleanup) go through the portable time facade so conditional timer driving cannot starve them. Data plane: - Move read/write deadlines onto TCP and UDP resources with one ABI setter per direction, reuse a single expiration timer per resource, and drop timeout arguments from the four hot data-plane submissions (ABI v3). Checked absolute instants treat unrepresentable finite timeouts as unbounded instead of panicking. - Batch host traffic: vectored TCP frame writes combine queued slices into one host operation, and reads request a bounded 64 KiB while retaining excess bytes in the stream buffer. - Complete TCP writes inside the guest with cancellation-safe writes, reporting the completed prefix before honoring cancellation or timeout so hosts never replay bytes. - Repoll smoltcp egress immediately on zero poll delay, enlarge virtual UDP receive queues to 128 KiB payload with 128 metadata slots, and bound UDP session receive buffers to 8 KiB plus one byte while keeping oversized-datagram detection. Host integration: - Add optional algorithm-neutral AEAD seal/open imports with the ring backend as fallback, and pin the ring AES-128-GCM wire vector so the Go host stays interoperable. - Forward instance events to hosts through one best-effort, synchronous, non-blocking import. - Add a repository-owned build entry point for the Go host artifact: Binaryen 131 at -O4 with cached, SHA-256-verified official archives.
This commit is contained in:
@@ -12,8 +12,9 @@ use easytier_core::socket::{
|
||||
use easytier_core::socket::{
|
||||
SocketContext,
|
||||
udp::{
|
||||
MAX_UDP_SESSION_DATAGRAM_SIZE, UdpBindOptions, UdpSocketDatagram, UdpSocketPurpose,
|
||||
UdpSocketRecvMeta, UdpSocketSendMeta, VirtualUdpSocket, VirtualUdpSocketFactory,
|
||||
MAX_UDP_DATAGRAM_SIZE, MAX_UDP_SESSION_DATAGRAM_SIZE, UdpBindOptions, UdpSocketDatagram,
|
||||
UdpSocketPurpose, UdpSocketRecvMeta, UdpSocketSendMeta, VirtualUdpSocket,
|
||||
VirtualUdpSocketFactory,
|
||||
},
|
||||
};
|
||||
use tokio::net::UdpSocket;
|
||||
@@ -111,6 +112,17 @@ impl VirtualUdpSocket for RuntimeUdpSocket {
|
||||
|
||||
#[cfg(unix)]
|
||||
async fn recv_datagram(&self) -> std::io::Result<UdpSocketDatagram> {
|
||||
let (payload, remote_addr, dst_ip) =
|
||||
udp_src::recv_datagram_with_dst_ip(&self.socket, MAX_UDP_DATAGRAM_SIZE).await?;
|
||||
Ok(UdpSocketDatagram {
|
||||
payload,
|
||||
remote_addr,
|
||||
meta: UdpSocketRecvMeta { dst_ip },
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
async fn recv_session_datagram(&self) -> std::io::Result<UdpSocketDatagram> {
|
||||
let (payload, remote_addr, dst_ip) =
|
||||
udp_src::recv_datagram_with_dst_ip(&self.socket, MAX_UDP_SESSION_DATAGRAM_SIZE).await?;
|
||||
Ok(UdpSocketDatagram {
|
||||
@@ -265,7 +277,7 @@ mod tests {
|
||||
|
||||
let datagram = tokio::time::timeout(
|
||||
std::time::Duration::from_secs(1),
|
||||
runtime_socket.recv_datagram(),
|
||||
runtime_socket.recv_session_datagram(),
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
|
||||
Reference in New Issue
Block a user