[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
Jason Donenfeld 是 WireGuard 的主要开发者,同时他也是 Linux 内核随机数相关代码的维护者,近日在他的领导下,Linux
内核的随机数生成器代码有了巨大幅度的改进。
在之前的 Linux 5.17 中,Jason Donenfeld 就在随机代码用 BLAKE2s 代替了 SHA1,由于 BLAKE2s
自带的特性,前者通常比后者更快更安全。经过测试,通过这个简单的转换就能获得 131% 左右的速度提升。
虽然在 Linux 5.17 中有了速度上的大幅提升,但 Jason Donenfeld 对此并没满足。因此在 Linux 5.18
中他对随机代码作出了更多的改进。
通过查看 Linux 的 random.git 仓库的日志能够看出(上图),开发者 Jason Donenfeld
在最近两天时间里进行了大量的代码提交。这些提交内容都将在 3 月下旬 Linux 5.18 的合并窗口启动时引入内核。
在邮件中特别强调到,通过使用正在开发的最新代码,用于获取随机字节的 getrandom() 调用能够获得更好的性能。在配备英特尔 Xeon E5-2697
v2 @ 2.70GHz CPU 和 112G 内存的设备上进行 stress-ng getrandom() 基准测试后,更是获得了 8450% 的性能提升。
此次更改基本上会将之前的全局结构(实际上是 per-numa 节点结构)更改为 per-cpu
结构,这意味着快速路径上的许多锁都会消失。因此,当在具备多核的 CPU 上同时尝试 getrandom()
时,毫无疑问性能会出现提升。只不过没想到在测试中能带来 8450% 的提升。
除此之外,当从 per-numa 更改为 per-cpu
后,也将不再需要被推迟到工作队列上线后才能进行。也正如我之前所说,此次改进将会为高核心数的电脑和服务器带来巨大收益。