简体   繁体   English

在Go中加快syscall

[英]Speeding up syscall in Go

I've been working on a vpn written in go and I'm starting to try to optimize the data flow. 我一直在研究用go编写的vpn,并且我开始尝试优化数据流。 From a cursory glance, the implementation code seems sound as there are no issues with memory leaking and CPU doesn't seem to be a constraint. 粗略地看,实现代码听起来不错,因为内存泄漏没有问题,CPU似乎也不是约束。

So I moved to pprof and the problem I am seeing is that most of the execution time is spent in syscall.Syscall. 所以我转到了pprof,我看到的问题是大部分执行时间都花在了syscall.Syscall上。 I did a 6 second profile of a running iperf throughput test and this is what I see: 我对正在运行的iperf吞吐量测试做了6秒的配置文件,这就是我看到的内容:

在此处输入图片说明

This test is being run with both the client and server inside of docker containers with the client getting a --link to the server. 正在使用docker容器内的客户端和服务器同时在docker容器内运行客户端和服务器的测试。 Running iperf on the base bridge networking yields around 40Gbit of throughput, iperf over this vpn impl over the top of the same, nets about 500Mbit. 在基础网桥网络上运行iperf可以产生大约40Gbit的吞吐量,而在该vpn隐喻之上的iperf可以达到大约500Mbit。

A simple htop shows that 3/4 of the time is spent in the system. 一个简单的htop显示系统中有3/4的时间被花费了。

I've tried a couple approaches to attempt speeding up the single-client case, but I can't seem to find a way to mitigate writing packets in a vpn server... NB: iperf uses full MTU-sized packets during its test which limits some obvious optimizations. 我已经尝试了几种方法来加快单客户端的速度,但是我似乎找不到一种减轻在vpn服务器中写入数据包的方法...注意:iperf在测试过程中使用了完整MTU大小的数据包这限制了一些明显的优化。

listing Syscall: 列出Syscall:

在此处输入图片说明

Not sure why this is showing the CMPQ is taking all the time, I'd think that should be attributed to SYSCALL. 不知道为什么这表明CMPQ一直在花时间,我认为应该归因于SYSCALL。

pprof is a process sampling profiler. pprof是一个过程采样分析器。 It finds that the Program Counter (PC) is often waiting for CMPQ to execute while the OS is executing. 它发现在OS执行期间,程序计数器(PC)经常等待CMPQ执行。

Speeding up syscall in Go 在Go中加快syscall

You can make the SYSCALL less often. 您可以减少SYSCALL频率。 You can improve the OS SYSCALL mechanism. 您可以改善OS SYSCALL机制。 You can improve the OS code that you asked the SYSCALL to execute. 您可以改进要求SYSCALL执行的OS代码。 You can use better hardware. 您可以使用更好的硬件。 And so on. 等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM