Posts

Showing posts with the label linux技术 零拷贝

Valorant requires a restart or loads slowly when entering the game. What can I do? I have an idea.

Valorant is a free first -person tactical shooting game developed by Riot Games, which combines the exact system of arms shooting and heroism. Players will be transformed into agents and will compete for target points using team collaboration, tactical layout and skills cooperation 5V5 offensive and defense stroke. The game has a low economic system and high competitiveness. Before each game start, buy weapons and armor according to tactical needs and use a combination of heroic skills to create the benefits of the battlefield. Its solid ballistic mechanism and map design require players for accurate purposes and tactical decision -making. At the same time, the rich character pool and skill combination give the game a strategic depth. If you have the problems you need to restart or slowly load while playing a "Varorant", try the following systematic solution: Network environment optimization is the main solution. Because valante servers can be introduced abroad, physical dist...

Linux管道到底能有多快,如何大幅提升IO性能?

Image
本文将对一个通过管道写入和读取数据的测试程序进行反复优化,以此研究 Unix 管道在 Linux 中的实现方式。 我们从一个吞吐量约为 3.5GiB/s 的简单程序开始,并逐步将其性能提升 20 倍。性能提升通过使用 Linux 的 perf tooling 分析程序加以确认,代码可从GitHub上获得(https://github.com/bitonic/pipes-speed-test)。 管道测试程序性能图 本文的灵感来自于阅读一个高度优化的 FizzBuzz 程序。在我的笔记本电脑上,该程序以大约 35GiB/s 的速度将输出推送到一个管道中。我们的第一个目标是达到这个速度,并会说明优化过程中每一步骤。之后还将增加一个 FizzBuzz 中不需要的额外性能改进措施,因为瓶颈实际上是计算输出,而不是 IO,至少在我的机器上是这样。 我们将按以下步骤进行: 首先是一个管道基准测试的慢版本; 说明管道内部如何实现,以及为什么从中读写会慢; 说明如何利用vmsplice和splice系统调用,绕过一些(但不是全部!)缓慢环节; 说明Linux分页,以及使用huge pages实现一个快速版本; 用忙循环代替轮询以进行最后的优化; 总结 第4步是 Linux 内核中最重要的部分,因此即使你熟悉本文中讨论的其他主题,也可能对它感兴趣。对于不熟悉相关主题的读者,我们假设你只了解 C 语言的基本知识。 挑战第一个慢版本 我们先按照 StackOverflow 的发帖规则,来测试传说中的 FizzBuzz 程序的性能: % ./fizzbuzz | pv >/dev/null 422GiB 0:00:16 [36.2GiB/s] pv 指“pipe viewer”,是一种用于测量流经管道的数据吞吐量的简便工具。所示为 fizzbuzz 以 36GiB/s 的速率产生输出。 fizzbuzz 将输出写入与二级缓存一样大的块中,以在廉价访问内存和最小化 IO 开销之间取得良好平衡。 在我的机器上,二级缓存为 256KiB。本文中还是输出 256KiB 的块,但不做任何“计算”。我们本质上是想测量出程序写入具有合理缓冲区大小的管道的吞吐量上限。 fizzbuzz 使用 pv 测量速度,而我们的设置会略有不同:我们将在管道的两端执行程序,这样就可以完全控制从管道中推拉数据所涉...