9 ms·
Summary: Mostly syscalls and mmap do the same things just substituting a page fault for a syscall to get to kernel mode, but… In user space her code is using AV
by jws 6y ago
Summary: Mostly syscalls and mmap do the same things just substituting a page fault for a syscall to get to kernel mode, but… In user space her code is using AVX optimized memory copy instructions which are not accessible in kernel mode yielding a significant speed up.
Bonus summary: She didn’t use the mmapped data in place in order to make a more apples-to-apples comparison. If you can use the data in place then you will get even better performance.
- anaisbetts 6y ago*She, not he
- jws 6y agoThanks. Curse this language. I just want to refer to people! It’s simple encapsulation and abstraction. I shouldn’t have to care about implementation details irrelevant to the context.
- deleted 6y ago[deleted]
- ryanianian 6y ago"They" is an acceptable gender-neutral pronoun.
- FentanylFloyd 6y agoit's an idiotic newspeakism, lol it's well enough that 'you' can be both singular and plural, we don't need another one
- kortilla 6y agoAcceptable to some, still not frequent enough though to be normalized.
- deleted 6y ago[deleted]
- lolc 6y agoI don't even notice it anymore.
- itamarst 6y agoIt's been used since the time of Jane Austen (by Jane Austen, in fact), it's perfectly normal: https://pemberley.com/janeinfo/austheir.html https://pemberley.com/janeinfo/austheir.html
- jhgb 6y agoCuriously, the page you've linked explains that it isn't normal to use it in this case: "can only be used with a morphologically and syntactically singular antecedent when what it refers to is semantically collective and/or generic and/or indefinite and/or unknown".
- DonHopkins 6y agoThen please help normalize it, instead of worrying about hurting the illiterate feelings of those who find it unacceptable.
- DonHopkins 6y agoAnd it's not even as tricky and nuanced as the rules about "this" in JavaScript! https://john-dugan.com/this-in-javascript/ https://john-dugan.com/this-in-javascript/
- cpach 6y agoHow about “they”…?
- throw_away 6y agosingular they is the generalization you're looking for
- jws 6y agoI'm old enough that "they" is not singular, it is a grammatical error punishable by red ink and deducted points.
- Spivak 6y agoBut the usage of they to refer a single person is older than anyone alive if that makes you feel better about sticking it to your picky grade school teachers.
- jfk13 6y agoSo is the use of "he" to refer to an individual of unspecified gender. (The OED quotations for sense 2(b) "In anaphoric reference to a singular noun or pronoun of undetermined gender" go back to at least 1200AD.)
- microtherion 6y agoYou're older than William Shakespeare? There's not a man I meet but doth salute me As if I were their well-acquainted friend
- staticassertion 6y agoDoubtful. > According to the third edition, The New Fowler's Modern English Usage (edited by Burchfield and published in 1996) singular they has not only been widely used by good writers for centuries, but is now generally accepted, except by some conservative grammarians, including the Fowler of 1926, who, it is argued, ignored the evidence: https://en.wikipedia.org/wiki/Singular_they https://en.wikipedia.org/wiki/Singular_they Elsewhere in the article you'll find dates like: 1375, 1382, 1400, 1489, 1759, etc, and references to these by Fowler's https://en.wikipedia.org/wiki/A_Dictionary_of_Modern_English_Usage https://en.wikipedia.org/wiki/A_Dictionary_of_Modern_English... Anyone arguing against singular 'they' may as well be arguing for a gender neutral 'he' - an argument lost over a century ago by virtually any modern English standard.
- jfim 6y agoYou can use "the author" or refer to the article or paper. [name of paper] mentions that X is faster than Y. The author suggests the cause of the speed up is Z, while we believe it is W.
- damudel 6y agoDon't worry about it. Some people lose their marbles because they think females get erased when male language is used. Just erase both genders and you'll be fine. Use singular they.
- usrnm 6y agoJust a nitpick: "Alexandra" is the female version of the name "Alexander" in Russian, so it's a "she", not "he".
- andi999 6y agoAnd 'Sasha' the nickname of 'Alexander'.... man who can think this up, this is like you were calling 'Richard' 'Dick'.
- tucnak 6y agoSasha is universally applied to both males and females, although to be fair, in Russian, it's culturally much acceptable to call Alexander Sasha in any context whatsoever, whereas Sasha as–in female Alexandra is reserved for informal communication. Disclaimer: I speak Russian.
- LudwigNagasena 6y agoSasha is an informal version for both genders, I don’t think there is any difference. Source: I am Russian
- eps 6y agoSasha is derived from Alexander via its dimunitive, but obsolete form - Aleksashka - shortned to Sashka, further simplified to Sasha as per established name format of Masha (Maria), Dasha (Daria), Pasha (Pavel, Paul), Glasha (Glafira), Natasha (Natalia), etc.
- spockz 6y agoWhy doesn’t the kernel have access to AVX optimised memory copy instructions?
- jws 6y agoThe size of the state required to be saved and restored on each system call makes it a losing proposition.
- PaulDavisThe1st 6y agoEach context switch, not syscall.
- topspin 6y agoThe kernel does have access to these instructions. It is a deliberate choice by kernel developers not to use them in the case discussed here. In other cases the kernel does use such instructions.
- jiggawatts 6y agoStupid question: Does the entire AVX state need to be saved and restored for a memcpy routine? It seems like it would be sufficient to save at most a couple of registers for a tight copy loop...
- R0b0t1 6y agoThe bonus is what makes this writeup silly. I've always seen mmap presented as a way to reduce copies. If you're not using it for that, then yes, it's not a given it will be faster.
- scaramanga 6y agoYes, the test is sort of a strange one because the read test is reading directly in to the final destination wheras mmap is not and doing a redundant copy instead. So it's not your typical "eliminate a copy and go faster" usage of mmap. What it actually seems to be comparing is whether its faster if the copy happens in the kernel, in the read() system call, or whether it's faster in userspace. The results are puzzling because I would expect the kernel to be faster since it would incur no page-faults to access the pages from page cache since those ought to fall under the page-global mappings, or, at least, be in the kernels linear ram map which use 1GB pages (edit: in either case, not incur faults for demand map/demand load). But maybe that's no longer the case in a post-spectre world? So I think actually it's a test of "does AVX go enough-faster to outweigh the costs of the extra-pagefaults incurred by copying from a user-space mapping which has not been prefaulted" Sounds like the answer is yes (which still surprises me). And I expect if they MAP_POPULATE it would pull even further ahead...
- scaramanga 6y agoYes, 1,167 pagefaults for the read() version and 66,704 pagefaults for the mmap() version. With MAP_POPULATE it's back down to 1,167 faults and it goes a bit faster. My libc is using rep/mov, same as the kernel, however. So I can't conclude that AVX memcpy is the win. From the profile of readsyscall version I see this: 42.12% fa [kernel.kallsyms] [k] copy_user_enhanced_fast_string 14.45% fa [kernel.kallsyms] [k] syscall_exit_to_user_mode 11.00% fa [kernel.kallsyms] [k] find_get_entry 6.28% fa [kernel.kallsyms] [k] syscall_return_via_sysret 5.14% fa [kernel.kallsyms] [k] entry_SYSCALL_64 nearly 15% of the time is spent on a single verw instruction. Spectre mitigations. When I reboot with mitigations=off, sure enough, the difference goes away and read() and mmap() perform identically. What OP has discovered is that spectre mitigations make syscalls enough slower than pagefaults that what used to be a slower way to do things is now faster. If you want the mmap version to perform faster when spectre mitigations are off, you need to use MAP_POPULATE.