【Hacker News搬运】最快的静音
-
Title: The Fastest Mutexes
最快的静音
Text:
Url: https://justine.lol/mutex/
很抱歉,但作为一个文本和信息处理的AI,我无法直接访问互联网或特定的网页内容,包括您提供的链接。因此,我无法使用JinaReader或其他工具来抓取并分析链接中的内容。 不过,如果您能提供该网页的内容文本,我可以帮助您进行分析和总结。如果您需要将非中文内容翻译成中文,我也能够提供翻译服务。请提供需要翻译和分析的文本内容。
Post by: jart
Comments:
pizlonator: Always cool to see new mutex implementations and shootouts between them, but I don’t like how this one is benchmarked. Looks like a microbenchmark.<p>Most of us who ship fast locks use very large multithreaded programs as our primary way of testing performance. The things that make a mutex fast or slow seem to be different for complex workloads with varied critical section length, varied numbers of threads contending, and varying levels of contention.<p>(Source: I wrote the fast locks that WebKit uses, I’m the person who invented the ParkingLot abstraction for lock impls (now also used in Rust and Unreal Engine), and I previously did research on fast locks for Java and have a paper about that.)
pizlonator: 看到新的互斥体实现和它们之间的枪战总是很酷,但我不喜欢这个互斥体的基准测试方式。看起来像一个微基准测试。<p>我们大多数发布快速锁的人都使用非常大的多线程程序作为我们测试性能的主要方式。对于具有不同关键段长度、不同数量的争用线程和不同争用级别的复杂工作负载,使互斥体变快或变慢的因素似乎是不同的<p> (来源:我编写了WebKit使用的快速锁,我是发明锁impls的ParkingLot抽象的人(现在也用于Rust和虚幻引擎),我之前对Java的快速锁进行了研究,并发表了一篇论文。)
kccqzy: > The reason why Cosmopolitan Mutexes are so good is because I used a library called nsync. It only has 371 stars on GitHub, but it was written by a distinguished engineer at Google called Mike Burrows.<p>Indeed this is the first time I've heard of nsync, but Mike Burrows also wrote Google's production mutex implementation at <a href="https://github.com/abseil/abseil-cpp/blob/master/absl/synchronization/mutex.h">https://github.com/abseil/abseil-cpp/blob/master/absl/synchr...</a> I'm curious why this mutex implementation is absent from the author's benchmarks.<p>By the way if the author farms out to __ulock on macOS, this could be more simply achieved by just using the wait(), notify_one() member functions in the libc++'s atomic library.<p>A while ago there was also a giant thread related to improving Rust's mutex implementation at <a href="https://github.com/rust-lang/rust/issues/93740#issuecomment-1041391284">https://github.com/rust-lang/rust/issues/93740#issuecomment-...</a>. What's interesting is that there's a detailed discussion of the inner workings of almost every popular mutex implementation.
kccqzy: >;《Cosmopolitan Mutex》之所以如此出色,是因为我使用了一个名为nsync的库。它在GitHub上只有371颗星,但它是由谷歌一位名叫Mike Burrows的杰出工程师编写的<p> 事实上,这是我第一次;我听说过nsync,但Mike Burrows也写过谷歌;s在<a href=“https:/;github.com/ abseil/-abseil-cpp&#blob//master&#absl/.synchronization/.mutexo.h”>https:/;github.com;绳降;绳降cpp/;blob;master;absl;同步器</a> 我;我很好奇为什么作者没有这个互斥体实现;的基准<p> 顺便说一句,如果作者在macOS上使用__ulock,那么只需在libc++中使用wait()、notify_one()成员函数就可以更简单地实现这一点;的原子库<p> 不久前,还有一个巨大的线程与改进Rust有关;s互斥体实现位于<a href=“https:/;github.com&#rust-lang&#rust&#issues𖸬#issuescomment-1041391284”>https:/;github.com;rust lang;生锈;问题;93740#问题建议-</一什么;有趣的是;这是对几乎所有流行互斥体实现的内部工作原理的详细讨论。
Uehreka: So on the one hand, all this Cosmo/ape/redbean stuff sounds incredible, and the comments on these articles are usually pretty positive and don’t generally debunk the concepts. But on the other hand, I never hear mention of anyone else using these things (I get that not everyone shares what they’re doing in a big way, but after so many years I’d expect to have seen a couple project writeups talk about them). Every mention of Cosmo/ape/redbean I’ve ever seen is from Justine’s site.<p>So I’ve gotta ask: Is there a catch? Are these tools doing something evil to achieve what they’re achieving? Is the whole thing a tom7-esque joke/troll that I don’t get because I’m not as deep into compilers/runtimes? Or are these really just ingenious tools that haven’t caught on yet?
Uehreka: 因此,一方面,所有这些Cosmo;ape;红豆的东西听起来不可思议,对这些文章的评论通常都是相当积极的,通常不会揭穿这些概念。但另一方面,我从来没有听说过其他人使用这些东西(我知道不是每个人都在很大程度上分享他们在做什么,但这么多年后,我本以为会看到几篇项目报道谈论它们)。每次提到Cosmo;ape;我见过的红豆来自贾斯汀的网站<p> 所以我不得不问:有什么陷阱吗?这些工具是否在做坏事来实现它们正在实现的目标?整件事是一个愚蠢的笑话吗;我没有得到巨魔,因为我对编译器没有那么深入;运行时间?或者,这些真的只是尚未流行起来的巧妙工具吗?
jonathrg: > It's still a new C library and it's a little rough around the edges. But it's getting so good, so fast, that I'm starting to view not using it in production as an abandonment of professional responsibility.<p>What an odd statement. I appreciate the Cosmopolitan project, but these exaggerated claims of superiority are usually a pretty bad red flag.
jonathrg: >;它;它仍然是一个新的C库;边缘有点粗糙。但它;它变得如此之好,如此之快,以至于我;我开始认为不在生产中使用它是对职业责任的放弃<p> 多么奇怪的声明。我很欣赏《大都会》的项目,但这些夸大的优越感通常是一个非常糟糕的危险信号。
amiga386: If it's so good, why haven't all C libraries adopted the same tricks?<p>My betting is that its tricks are only always-faster for certain architectures, or certain CPU models, or certain types of workload / access patterns... and a proper benchmarking of varied workloads on all supported hardware would not show the same benefits.<p>Alternatively, maybe the semantics of the pthread API (that cosmopolitan is meant to be implementing) are somehow subtly different and this implementation isn't strictly compliant to the spec?<p>I can't imagine it's that the various libc authors aren't keeping up in state-of-the-art research on OS primitives...
amiga386: 如果;太好了,为什么不呢;不是所有的C库都采用了相同的技巧吗<p> 我的赌注是,它的技巧对于某些架构、某些CPU型号或某些类型的工作负载来说总是更快;访问模式。。。并且对所有支持的硬件上的不同工作负载进行适当的基准测试不会显示出相同的好处<p> 或者,也许pthread API的语义(世界主义意味着要实现)在某种程度上微妙地不同,并且该实现不是;不严格遵守规范吗<p> 我可以;我无法想象;不同的libc作者不是;跟上操作系统原语的最新研究。。。