Readit News logoReadit News
OskarS commented on How to stop Linux threads cleanly   mazzo.li/posts/stopping-l... · Posted by u/signa11
loeg · 2 months ago
If you can swing it (don't need to block on IO indefinitely), I'd suggest just the simple coordination model.

  * Some atomic bool controls if the thread should stop or not;
  * The thread doesn't make any unbounded wait syscalls;
  * And the thread uses pthread_cond_wait (or equivalent C++ std wrappers) in place of sleeping while idle.
To kill the thread, set the stop flag and cond_signal the condvar. (Under the hood on Linux, this uses futex.)

OskarS · 2 months ago
The tricky part is really point 2 there, that can be harder than it looks (e.g. even simple file I/O can be network drives). Async IO can really shine here, though it’s not exactly trivial designing async cancelletion either.
OskarS commented on How to stop Linux threads cleanly   mazzo.li/posts/stopping-l... · Posted by u/signa11
harvie · 2 months ago
while (true) { if (stop) { break; } }

If there only was a way to stop while loop without having to use extra conditional with break...

OskarS · 2 months ago
Feel free to read the article before commenting.
OskarS commented on Deterministic multithreading is hard (2024)   factorio.com/blog/post/ff... · Posted by u/adtac
btown · 2 months ago
Paper link (2011): https://people.cs.umass.edu/~emery/pubs/dthreads-sosp11.pdf

> DTHREADS works by exploding multithreaded applications into multiple processes, with private, copy-on-write mappings to shared memory... Experimental results show that DTHREADS substantially outperforms a state-of-the-art deterministic runtime system, and for a majority of the benchmarks evaluated here, matches and occasionally exceeds the performance of pthreads.

OskarS · 2 months ago
Never heard of this, I’m really interested in digging into this paper. Thank you both for the tip!
OskarS commented on Beliefs that are true for regular software but false when applied to AI   boydkane.com/essays/boss... · Posted by u/beyarkay
vladms · 2 months ago
> Any programming or mathematical question has several correct answers.

Huh? If I need to sort the list of integer number of 3,1,2 in ascending order the only correct answer is 1,2,3. And there are multiple programming and mathematical questions with only one correct answer.

If you want to say "some programming and mathematical questions have several correct answers" that might hold.

OskarS · 2 months ago
No, but if you phrase it like "there are multiple correct answers to the question 'I have a list of integers, write me a computer program that sorts it'", that is obviously true. There's an enormous variety of different computer programs that you can write that sorts a list.
OskarS commented on HTTP3 Explained   http3-explained.haxx.se... · Posted by u/weinzierl
wongarsu · 2 months ago
I'd even go as far as claiming that on reliable wired connections (like between cloudflare and your backend) HTTP/2 is superior to HTTP/3. Choosing HTTP/3 for that part of the journey would be a downgrade
OskarS · 2 months ago
Is the protocol inherently inferior in situations like that, or is this because we've spent decades optimizing for TCP and building into kernels and hardware? If we imagine a future where QUIC gets that kind of support, will it still be a downgrade?
OskarS commented on Python 3.14 is here. How fast is it?   blog.miguelgrinberg.com/p... · Posted by u/pjmlp
lucb1e · 2 months ago
I take it this is supposed to be the equivalent of fib(40), which ran on the author's system in Pyπ in 6.59 seconds and apparently on yours, with Raku, in 0.21?

Do you have the same hardware as the author or should one of you run the other's variant to make this directly comparable?

OskarS · 2 months ago
No, this is very much not the same. The Raku version is like writing this in Python:

    def fibonacci():
        a, b = 0, 1

        while True:
            yield a
            a, b = b, a+b
And taking the 40th element. It's not comparable at all to the benchmark, that's deliberately an extremely slow method of calculating fibonacci numbers for the purpose of the benchmark. For this version, it's so fast that the time is dominated by the time needed to start up and tear down the interpreter.

OskarS commented on Thoughts on the Word Spec in Rust   tritium.legal/blog/word... · Posted by u/piker
skywal_l · 2 months ago
Andrew Kelley (author of zig) has a nice talk about programming without pointers allowing ultra fast serialize/deserialization. [0]

And then you have things like cap'n'proto if you want to control your memory layout. [1]

But for "productivity" files, you are essentially right. Portability and simplicity of the format is probably what matters.

[0]: https://www.hytradboi.com/2025/05c72e39-c07e-41bc-ac40-85e83...

[1]: https://capnproto.org/

OskarS · 2 months ago
That is true, cap’n proto and flatbuffers are excellent realizations of this basic concept. But that’s very different thing from what the commenter is talking about Word doing in the 90s, of just memory-mapping the internal data structures and be done with it.
OskarS commented on Nobel Prize in Literature 2025: László Krasznahorkai   nobelprize.org/prizes/lit... · Posted by u/PikelEmi
zpeti · 2 months ago
Considering the amount of threats and hate jewish people with no connection get about Israel vs Palestine, you don't think there's at least some legitimacy for his position?

Considering there was literally just an attack on a UK synagogue by an arab, after which many people protested on the side of the attacker in London, you don't think there's a tiny legitimacy to his views?

Of course this is a rhetorical question, because your obviously don't think his views has legitimacy.

OskarS · 2 months ago
Your argument is that it’s not ok to think of all Jewish people as a monolithic group, and therefore his statement where he considered all arabs as a monolithic group is ”legitimate”? Seriously?

Just like it’s not ok to see all jews as part of the same murderous conspiracy, it’s not ok to see all arabs as part of one either.

OskarS commented on Thoughts on the Word Spec in Rust   tritium.legal/blog/word... · Posted by u/piker
amelius · 2 months ago
The original Word format was a literal dump of a part of the data segment of the Word process. Basically like an mmapped file. Super fast. It is a pity that modern languages and their runtimes do not allow data structures to be saved like that.
OskarS · 2 months ago
You can absolutely save data like that, it's just that it's a terrible idea. There are obvious portability concerns issues: little-endian vs. big endian, 32-bit vs. 64-bit, struct padding, etc.

Essentially, this system works great if you know the exact hardware and compiler toolchain, and you never expect to upgrade it with things that might break memory layout. Obviously this does not hold for Word: it was written originally in a 32-bit world and now we live in a 64-bit one, MSVC has been upgraded many times, etc. There's also address space concern: if you embed your pointers, are you SURE that you're always going to be able to load them in the same place in the address space?

The overhead of deserialization is very small with a properly written file format, it's nowhere near worth the sacrifice in portability. This is not why Word is slow.

OskarS commented on Way past its prime: how did Amazon get so rubbish?   theguardian.com/technolog... · Posted by u/sandebert
sandebert · 2 months ago
For me it's problematic though. Sometimes I want some small gadget, and I just can't find it elsewhere. The other day I wanted a female-female connector for network cables and I couldn't find it on my Swedish go-to place for tech stuff, Kjell&Co. Instantly found lots of alternatives on Amazon.
OskarS · 2 months ago
Yeah, I do this on occassion as well, but I aleays try the Swedish retailers first, and only go to Amazon when I can’t find whatever I’m looking for. It’s pretty rare I have to go to Amazon.

It’s rough, because you know that it will probably be cheaper and delivered faster from Amazon, at the moment it is probably the most consumer friendly place to buy. But you know once the honeymoom is over and all the Swedish retailers are gone, it’s just going to devolve to garbage. Support your non-Amazon retailers!

u/OskarS

KarmaCake day8027September 4, 2016View Original