Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
tavianator
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
7 ms
·
31.
▲
by
tavianator
2y ago
I don't think there are a thousand constant registers. I think the renamer just represents (reg, 10-bit offset) pairs rather than just registers. Also the problem affects SHL as well as SHLX, I didn't realize until just now.
32.
▲
by
tavianator
2y ago
ANDN is fast. The issue looks specific to shift counts. SHL is also slow.
33.
▲
by
tavianator
2y ago
It's possible to get gcc to generate sequences that would trigger this: https://godbolt.org/z/rYKqPxn7b
34.
▲
by
tavianator
2y ago
If it were a prediction/speculation thing, I would expect it to settle down long before 10,000 `SHLX`s are retired.
35.
▲
by
tavianator
2y ago
> How about trying "xor ecx, ecx; inc ecx"? Fast. But inc rcx is slow. > Or the even shorter "mov cl, 1"? Fast. > I suspect this is a width restriction in the bypass/forwarding network... I think we just f
36.
▲
by
tavianator
2y ago
One fun thing about this is that spilling+restoring the register will fix it, so if any kind of context switch happens (thread switch, page fault, interrupt, etc.), the register will get pushed to the stack and popped back from it, and the
37.
▲
by
tavianator
2y ago
> Practically speaking, is this sort of µop-dependent optimization implemented by compilers? I suspect this specific thing is not; I don't think many people were aware of this anomaly until this week. I doubt the compilers are mode
38.
▲
by
tavianator
2y ago
In general, if some recommendation from IEEE 754 (the floating-point standard) seems strange, its because someone like William Kahan thought about it in great detail and you'd be wise to follow it. https://en.wikipedia.org&#
39.
▲
by
tavianator
2y ago
You're cheating by using floating-point arguments; they should be integers: >>> x = 9007199254740990 >>> percent(x - 1, x) 99 But then again, >>> percent(10 * x - 1, 10 * x) 100
40.
▲
Rounding Percentages
(tavianator.com)
47 points
by
tavianator
2y ago
|
27 comments
41.
▲
by
tavianator
3y ago
At first I thought jcalvinowens meant they had actively tried to reproduce this bug for 100 machine hours, which would lend credence to "very very rare in practice". But in 100 machine hours of a typical workload doesn't rea
42.
▲
by
tavianator
3y ago
Thanks for pointing this out to me! I'll see if I can pre-render the syntax highlighting like I do with KaTeX and stuff. No reason to do that on the client.
43.
▲
by
tavianator
3y ago
Locks are perfectly usable in filesystem code, but test_and_set_bit()/wait_on_bit() has lower overhead, so they'll get used as an optimization. This function is called on every metadata read, so the improved performance/scal
44.
▲
by
tavianator
3y ago
The existing btrfs code does use a lock-free state machine for this, `eb->bflags`, that sort of mirrors regular page flags (hence `UPTODATE`, `DIRTY`, etc.). But Linux kernel APIs like test_bit(), set_bit(), clear_bit(), test_and_set_bit
45.
▲
by
tavianator
3y ago
I did it by hand with CSS: https://github.com/tavianator/tavianator.com/blob/main/src/2...
46.
▲
by
tavianator
3y ago
I like that idea, but it isn't really compatible with my fix. `bflags` still makes the same transitions, I just skip the actual read in the `UPTODATE | READING` case.
47.
▲
by
tavianator
3y ago
No, but I may have been missing some debugging CONFIGs. I was just using the stock Arch kconfig. I did submit a patch to add a WARN_ON() for this case: https://lore.kernel.org/linux-btrfs/d4a055317bdb8ecbd7e6d9bd... B
48.
▲
by
tavianator
3y ago
Do they run btrfs on top of dm-crypt? I suspect it's impossible to reproduce on a regular block device.
49.
▲
by
tavianator
3y ago
Perhaps they were thinking of https://github.com/karpathy/micrograd
50.
▲
by
tavianator
3y ago
Or maybe just iterated on until it gets more functionality? Linux has quite a large API surface, I'm not surprised it takes a while to replicate all of it.
51.
▲
by
tavianator
3y ago
Thanks for the heads up! It's fixed now.
52.
▲
by
tavianator
3y ago
From a quick test, about 5x faster: tavianator@tachyon $ cat bench.mjs #!/usr/bin/env node import { fdir } from "fdir"; console.log(new fdir().withFullPaths().crawl("/home/tavianat
53.
▲
by
tavianator
3y ago
`bfs` doesn't actually use io_uring yet, but it is planned. I'm not sure I'd say it's specifically optimized for finding multiple files at once either, I try to make it fast for many different use cases. There's t
54.
▲
by
tavianator
3y ago
The file got moved and renamed since then, it's here now: https://github.com/tavianator/bfs/blob/main/src/xspawn.h I'll fix the link, thanks
55.
▲
by
tavianator
3y ago
I think for anything more complicated than my examples, animations would be worse than your explicit interleavings. That said, I don't really think interleavings are the best way to show weak memory effects either, since they give the
56.
▲
by
tavianator
3y ago
I have been trying to come up with an efficient but simple and correct condition variable implementation based on futexes for the last couple days and it's surprisingly tricky.
57.
▲
by
tavianator
3y ago
Fixed, thanks!
58.
▲
by
tavianator
3y ago
> User space mutexes were in QNX over two decades ago Futexes were in Linux over two decades ago: https://www.kernel.org/doc/ols/2002/ols2002-pages-479-495.pd... :) And before that I believe glibc did some
59.
▲
by
tavianator
4y ago
Nope, a friend of mine messaged me that I was on the front page of HN! I'm busy with family for Easter so I can't reply to everything I want to, but I'll come back later
60.
▲
by
tavianator
4y ago
I wrote the SVGs by hand
More ›