Comments (2)
Zero copy would be a big improvement to the current implemention, but I don't think it is ready in tokio as mentioned in this issue tokio-rs/tokio#2438
from realm.
Yup, zero-copy is of much significance, it would become a regret if Realm does not support this feature.
Tokio has its own difficulties, we could not expect Tokio to provide zero-copy APIs in the short term. But in our case, the problem could be simplified, making it possible to write a Tokio-based zero-copy API on our own.
Our async task is just to proxy 2 TCP connection, we never use buffers across tasks. If we create a buffer(pipe) within the task, we could make sure that the pipe is always valid during the async operation. When the task is finished or cancelled, the pipe will be dropped as normal.
Moreover, we could count the left bytes in the pipe, and limit the max read/write bytes when calling splice
. This ensures that the pipe will never block, and we no longer need to poll the pipe, waiting for its readable/writeable event.
Given the inner fd of tokio::TcpStream
has been registered to the event loop, the only thing we need to do is:
- wait the inner fd of
TcpStream
to become readable - splice fd1 -> pipe_write_half
- wait the inner fd of another
TcpStream
to become writeable - splice pipe_read_half -> fd2
Actually I have did this a few days ago(0abbf2b bin). I added these codes to relay.rs
directly. I think the better approach is to encapsulate the pipe into a struct, and impl Drop trait
for it, so that the pipe could be dropped automatically.
from realm.
Related Issues (20)
- 可否一个端口转发到两个地址
- 端口转发出现大量的CLOSE-WAIT HOT 2
- 增加限速功能 HOT 1
- 相同配置,中转机正常,落地机报错 HOT 2
- 请问是否有可能加入Reality协议支持
- Releases中的windows-msvc文件为空 HOT 1
- feature request: add service manager support HOT 1
- feature request: easy advanced multi-port mapping HOT 1
- network.zero_copy is a great feature, why is it not supported anymore HOT 1
- Is it possible to add a command-line function to check whether the syntax and parameters of the configuration file are correct. HOT 3
- 【feature request】TCP端口复用,SNI分流
- tls can add specify encryption suite?
- 请问哪个参数支持故障转移 HOT 2
- realm + wireguard HOT 1
- Request to set default tcp keepalive interval HOT 6
- 通过realm转发后无法实现NAT1 HOT 11
- realm+dnsproxy DOH HOT 2
- TLS SNI proxy HOT 5
- 配置文件运行失败 HOT 1
- DNS resolve runs when not required HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from realm.