HNHacker News
TopNewBestAskShowJobs

newpavlov

1,056 karma · joined January 13, 2021

submissionscomments
newpavlov··on Committing to Rust in the Kernel
>Changing C interfaces will often have implications for the Rust code and may break it; somebody will the have to fix the problems. Torvalds said that, for now, breaking the Rust code is permissible, but that will change at some point in the future.

I think this is the main technical change needed from the Linux kernel. It needs a layer of quasi-stable well documented subsystem APIs, which ideally would be "inherently safe" or at least have clear safe usage contracts. And it's fine for these interfaces to have relaxed stability guarantees in the early (pre-1.0, if you will) experimental stages. Changing them would involve more work and synchronization (C maintainers would not be able to quickly "refactor" these parts), but it's a familiar problem for many large projects.

It's the only reasonable point from the infamous tantrum by Ted Ts'o during the Rust for filesystems talk, everything else, to put it mildly, was a really disappointing behavior from a Linux subsystem maintainer.

newpavlov··on Linus Torvalds muses about maintainer gray hairs and the next 'King of Linux'
You forgot about the third option: specify "stable" and properly documented API boundaries in relevant subsystems. Developers of Rust drivers would have to rely only on those APIs, in turn, if subsystem maintainers want to change those APIs, they would have to synchronize it with Rust developers.

The problem is that some subsystem maintainers do not want to even properly document existing APIs (sic!) and want to reserve the right to willy-nilly hack some changes into "their" subsystems without discussing it with other stakeholders.

newpavlov··on C2y Proposal: Essential Effects for C
Types usually describe values. Compilers use types to prove various things about possible values, like their size, alignment, valid bit patterns, etc.

Effects describe code. For example, a "panic" effect states that function may trigger panic/exception during its execution. In other words, existence or absence of an effect is a function property. You can view effects as special types which are used only for functions (to be slightly more precise, signature + effects form function type), but you would need to use a slightly more advanced notion of type system which includes subtyping, e.g. function "panic fn(u32) -> u64" can be used in place of "panic io fn(u32) -> u64".

newpavlov··on How the Hourglass Won
I think truncating packets would make live of application developers significantly harder since it breaks the nice atomic property and requires development of ad-hoc feedback protocols which account for potentially truncated packets. Smaller MTUs are also more likely on the last mile, so dropping a packet and sending an error packet back would result in less "useless" global traffic.

I guess it may be both, IP packet header could contain a flag depending on which data will be either truncated, or dropped with an error packet sent back.

newpavlov··on How the Hourglass Won
Yes, you are right. I completely forgot about ICMP Packet Too Big messages since they are effectively not used in practice for application-level stuff. One minor difference between it and the behavior desired by me is that the error packet would be sent directly to an application port (one of the reasons why it would be nice for IP packets to contain source/destination ports), making it possible to conveniently process it. IIUC even assuming PTB messages are reliably delivered, we would need some kind of OS help (and additional APIs) to process them properly.
newpavlov··on How the Hourglass Won
I think IP has two main issues: fragmentation and TCP.

Possibility of fragmentation means that we can not rely on "atomicity" of IP packets. We have to limit ourselves to conservative MTU sizes if we want reasonable performance on possibly unreliable networks. And there are security considerations as well. It would've been great if IP supported a reliable way to do MTU discovery (e.g. by replying with a special "error" packet containing MTU size) or had specified a bigger guaranteed MTU size (ideally, 2^16 bytes).

Finally, ossification of the TCP protocol is a well known problem. Ideally, we would have only IP packets with included source and destination ports, while TCP would be a QUIC-like protocol opaque for "dumb pipe" network hardware.

newpavlov··on Computer scientists prove that heat destroys quantum entanglement
>one which tips the scales of everything at every level towards a specific outcome

According to the SD, this is nothing more than an artifact of splitting an entagled system into an "observer" and an "observed" parts. The linked video covers this part relatively well, the "randomness" of quantum measurment is nothing more than an artifact of artificial split of the Universe done by humans.

newpavlov··on Computer scientists prove that heat destroys quantum entanglement
It's not a some sort of particle conspiracy. The idea is not so different from the Laplace's demon. We have an initial state of the Universe at the moment of Big Bang (a PRNG seed, if you will) and a set of differential equations (QM is not different in this regard). Theoretically, it allows the demon to predict everything in the Universe. The wave nature of QM equations introduces a certain quirk to it, but, effectively, with your example the breakfast was already "preordained" at the moment of the Universe creation.

Surprisingly, this idea makes many physicists very umcomfortable and they start to object to SD using philosophical arguments about "free will".

newpavlov··on Computer scientists prove that heat destroys quantum entanglement
It's no different from any other interpretation.
newpavlov··on Computer scientists prove that heat destroys quantum entanglement
I would say it differently. Suprdeterminism opposes to the deeply ingrained assumption that we can design experiments in a way which removes influence of a measurement apparatus (including experementators themselves) on the measured process.
newpavlov··on Computer scientists prove that heat destroys quantum entanglement
There is a very important and often forgotten caveat to the Bell's inequalities: it covers local hidden states. If we are to assume that measurement and particle creation apparatuses are entangled with each other (after all, they had plenty of opportunities since the big bang), then we have a global hidden state and the quantum measurment randomness becomes a simple artifact of removing global state from the picture. This interpretation of QM is usually called "superdeterminism" and, personally, I like it much more than the black vodoo measurement magic with collapsing wave functions or creation of whole new worlds on each tiny measurement. This video can be a good introduction to this topic: https://youtube.com/watch?v=dEaecUuEqfc (don't mind the clickbaity title, the video itself is good)
newpavlov··on Box64 and RISC-V in 2024: What It Takes to Run the Witcher 3 on RISC-V
There is also a middle ground of requiring to pad 16/48-bit sequences with 16-bit NOP to align them to 32 bits. I agree that at this time it's not clear whether the C extension is a good idea or not (same with the V extension).
newpavlov··on Box64 and RISC-V in 2024: What It Takes to Run the Witcher 3 on RISC-V
Another argument against the C extension is that it uses a big chunk of the opcode space, which may be better used for other extensions with 32-bit instructions.
newpavlov··on Box64 and RISC-V in 2024: What It Takes to Run the Witcher 3 on RISC-V
The handling of misaligned loads/stores in RISC-V is also can be considered a disappointing point: https://github.com/riscv/riscv-isa-manual/issues/1611 It oozes with preferring convenience of hardware developers and "flexibility" over making practical guarantees needed by software developers. It looks like the MIPS patent on misaligned load/store instructions has played its negative role. The patent expired in 2019, but it seems we are stuck with the current status quo nevertheless.
newpavlov··on Einstein and his peers were resistant to black holes
Are you talking about the Hawking-Penrose theorems? Have you read the Kerr paper?
newpavlov··on Einstein and his peers were resistant to black holes
>The simplest way to see this is to realize that Kerr's statement that if a theory predicts singularities, the theory is wrong, is something that virtually all physicists who work in GR agree with!

Maybe it was my misfortune, but the university professor who taught me GR thought that singularities are "real", so this anecdote (sadly) disproves your absolutist opinion. And there are heaps of real papers from real scientists which seriously discuss potential consequences of having "real" singularities. And if we'll take a look at the pop-sci coverage, it's orders of magnitude worse... Just see the Veritasium video linked in the other comment.

newpavlov··on Einstein and his peers were resistant to black holes
A very simplified idea is that the denser you get, the slower time flows (for an "outside" observer). So while for an "inner" observer density rises "fast" to the point of singularity, for an "outside" observer time just freezes inside the forming black hole. Finally, if there is a way for black holes to "evaporate" (e.g. Hawking radiation), the "inner" observer will be able to observe shrinking black hole.
newpavlov··on Einstein and his peers were resistant to black holes
Plenty of physicists are still "resistant" to the idea of black holes having a real singularity. The recent Kerr paper [0] only adds fuel to this resistance with its hilarious statement "Faith, not science!" about singularity proponents.

[0]: https://arxiv.org/abs/2312.00841

newpavlov··on Making Sense of Acquire-Release Semantics
For a more in-depth understanding, I recommend reading "Rust Atomics and Locks": https://marabos.nl/atomics/ It uses Rust for examples, but it more or less applicable to C/C++ as well.
newpavlov··on Coroutines and effects
Yeah, the whole blog post reads like "if you worked too much with a hammer, everything starts looking like a nail". In other words, it puts the cart before the horse.

Effects is a MUCH more general and powerful technique than coroutines. An effect system can help greatly with implementing a coroutine system (instead of dealing with the unfortunate type-level hack Rust uses), but trying to implement an effect system on top of a coroutine system will give you a very limited emulation in the best case and another incoherent mess in the worst.

It would've been really great if Rust had a proper effect system, but it's very hard to introduce it into an existing language similarly to how you can not easily introduce borrow checker to C/C++. The messy "keyword generics" proposals only serve as a good demonstration for this. So we probably have to wait for Rust 2 or a different successor language.

newpavlov··on Systemd replacing ELF dependencies with dlopen
sshd should not have used libsystemd in the first place for the trivial notification. And the ifunc stuff is its own security nightmare. Papering over this by dlopen-ing some libs in libsystemd does not address the deeper issues.
newpavlov··on OpenBSD 7.5
Lack of stable syscall ABI is what stops me. It can be only done by OS developers.
newpavlov··on OpenBSD 7.5
I do not dispute that it made sense during early days of UNIX. But today we write system software for these operating systems in many languages other than C. Maybe it's time to reconsider the dominant libc position instead of reinforcing it further?

Linux has successfully paved the way and demonstrated its practicality. Yes, it made certain unfortunate mistakes along the way, but OpenBSD (or any other OS) can learn from those and provide a better solution.

newpavlov··on Easy Mode Rust
In this particular case, I think it's distros who make life hard for themselves by trying to force a square peg into a round hole. Cargo supports vendoring quite well, so, in my opinion, distros should simply vendor all dependencies of a Rust application into its package together with Cargo.lock file.

It may cause some amount of duplication across all packages, but the final amount is arguably will be quite small when measured in MB. Also new release of an upstream crate may cause several updates of downstream packages even if downstream apps did not release new versions, but distros are not known for quick updates either way, so it should not be a big issue.

newpavlov··on OpenBSD 7.5
Honestly, I think that making libc THE system interface is a mistake. Ok, I understand issues with the Linux approach of exposing raw syscalls (though it works well enough in practice and ossification could be amended by some kind of syscall versioning scheme), but why in the world can't you introduce libsystem/libsyscall/libopenbsd which would contain only "syscall" functions? Why do you need all the C junk in a library for talking with OS?
newpavlov··on Why choose async/await over threads?
Sigh... It gets tiring to hear about embedded from async/await advocates as if it's a unique advantage of the model. Fibers and similar mechanisms are used routinely in embedded world as demonstrated by various RTOSes.

Fibers are built on yielding execution to someone else, which is implemented trivially on embedded targets. Arguably, in a certain sense, fibers can be even better suited for embedded since they allow preemption of task by interrupts at any moment with interrupts being processed by another task, while with async/await you have to put event into queue and continue execution of previously executed future.

newpavlov··on Why choose async/await over threads?
Yes, it's what I wrote about in the last paragraph. If you can compute maximum stack size of a function, then you can avoid dynamic allocation with fibers as well (you also could provide stack size manually, but it would break horribly if the provided number is wrong). You are right that such implementations do not exist right now, but I think it's technically feasible, as demonstrated by tools such as https://github.com/japaric/cargo-call-stack The main stumbling block here is FFI, historically shared libraries do not have any annotations about stack usage, so functions with bounded stack usage would not be able to use even libc.
newpavlov··on Why choose async/await over threads?
https://github.com/Xudong-Huang/may

The project has some serious restrictions and unsound footguns (e.g. around TLS), but otherwise it's usable enough. There are also a number of C/C++ libraries, but I can not comment on those.

newpavlov··on Why choose async/await over threads?
In my opinion, by default fibers should use "full" stacks, i.e. a reasonable amount of unpopulated memory pages (e.g. 2 MiB) with guard page. Effectively, the same stack which we use for threads. It should eliminate all issues about interfacing with external code. But it obviously has performance implications, especially for very small tasks.

Further, on top of this we can then develop spawning tasks which would use parent's stack. It would require certain language development to allow computing maximum stack usage bound of functions. Obviously, such computation would mean that programmers have to take additional restrictions on their code (such as disallowing recursion, alloca, and calling external functions without attributing stack usage), but compilers already routinely compute stack usage of functions, so for pure Rust code it should be doable.

>It can get really complicated, for example, when C code gets called from one fiber and wants to then resume another.

It's a weird example. How would a C library know about fiber runtime used in Rust?

>Yielding fibers are a bit like the 'goto' of the concurrency world - whenever you call a method, you don't know if as a side effect it may cause your processing to pause, and if when it continues the state of the world has changed.

I find this argument funny. Why don't you have the same issue with preemptive multitasking? We live with exactly this "issue" in the threading world just fine. Even worse, we can not even rely on "critical sections", thread's execution can be preempted at ANY moment.

As for `await` keyword, in almost all cases I find it nothing more than a visual noise. It does not provide any practically useful information for programmer. How often did you wonder when writing threading-based code about whether function does any IO or not?

newpavlov··on Why choose async/await over threads?
Fibers and async/await are backed by the same OS APIs, they can achieve more or less the same latency. The main advantage of async/await (or to be more precise stackless coroutines) is that they require less memory for task stacks since tasks can reuse executor's stack for non-persistent part of their stack (i.e. stack variables which do not cross yield points). It has very little to do with latency. At most you can argue that executor's stack stays in CPU cache, which reduces amount of cache misses a bit.

Stackless coroutines also make it easier to use parent's stack for its children stacks. But IMO it's only because compilers currently do not have tools to communicate maximum stack usage bound of functions to programming languages.

← PreviousPage 4 of 7Next →