HNHacker News
TopNewBestAskShowJobs

clausecker

335 karma · joined September 13, 2023

submissionscomments
clausecker··on Breaking the sorting barrier for directed single-source shortest paths
The current meta game is the use of contraction hierarchies. Basically, you sinplify the network into hubs connected by trunk lines and then refine the routing close to start and destination.
clausecker··on I hacked my washing machine
Bosch and Siemens is the same company (BSH, Bosch Siemens Home Appliances).
clausecker··on Show HN: Luna Rail – Treating night trains as a spatial optimization problem
The Snälltåget goes from Stockholm to Berlin almost daily and from Berlin you can take a daily Nightjet to Zurich. Not sure what you are missing.
clausecker··on The length of file names in early Unix
One generation of the BSD FFS had a 64 B limit. May have been only 2.11BSD though.
clausecker··on Prepare(): a new API proposal for process creation
UNIX famously uses fork+exec to create processes, a simple API that is nevertheless quite tricky to use correctly and that comes with a bunch of problems. The alternative, spawn, as used by VMS, Windows NT and recently POSIX, fixes many of these issues but it overly complex and makes it hard to add new features.

prepare() is a proposed API to simplify process creation. When calling prepare(), the current thread enters “preparation state.” That means, a nascent process is created and the current thread is moved to the context of this process, but without changing memory maps (this is similar to how vfork() works). Inside the nascent process, you can configure the environment as desired and then call prep_execve() to execute a new program. On success, prep_execve() leaves preparation state, moving the current thread back to the parent's process context and returns (!) the pid of the now grownup child. You can also use prep_exit() to abort the child without executing a new process, it similarly returns the pid of the now zombified child.

Here's an example for executing a child with stdout redirected to /dev/null:

int stfu(char prog, char argv[]) { if (prepare(NULL) == -1) return (-1);

    int fd = open("/dev/null", O_WRONLY);
    if (fd == -1) {
        return (prep_exit(1));
    }

    dup2(fd, 1);
    close(fd);

    int pid = prep_execve(prog, argv, environ);
    if (pid == -1) {
        return (prep_exit(1));
    }

    return (pid);
}

The key advantage of this API is that it has completely linear control flow like spawn, while preserving the flexible builder-pattern provided by fork+exec. No double-return shenanigans like with fork and execve. And because the nascent process shares memory with the parent, it's possible to communicate failure to execute and similar stuff using simple variables.

clausecker··on Show HN: Berlin Swapfest – Electronics flea market
Same here. What a shame.
clausecker··on Broken legs and ankles heal better if you walk on them within weeks
I wonder if this phenomenon was part of the reason why Küntscher's intramedullary nailing was so effective at speeding up the recovery from broken legs.
clausecker··on Ask HN: What commit message conventions do you follow?
I usually use the one we use in the FreeBSD project, which is to have the subject be of the form "component: action".
clausecker··on Compiling Array Languages for SIMD [pdf]
I had originally planned something like this for my PhD thesis, but found out that I'm in way over my head. So I scaled down my ambitions a little.

Array languages and SIMD are a match made in heaven. This should be the paradigm of choice for high-performance programming, but it's unfortunately pretty obscure.

clausecker··on Bicameral, Not Homoiconic
Another language with this property is FORTH, which has many surprising similarities with LISP. I like to call it “LISP, but the other way round.” It usues RPN instead of PN, stacks/arrays instead of lists, and is procedural instead of functional.
clausecker··on Lies we tell ourselves to keep using Golang (2022)
if err != nil { return err; } is an antipattern. Codifying it through builtin constructs does not change this, but instead encourages such poor error handling. That's why try sucks.
clausecker··on Lies we tell ourselves to keep using Golang (2022)
Yes and that syntax sucks.
clausecker··on Lies we tell ourselves to keep using Golang (2022)
I dislike sum-type based error handling. It is annoying syntactically and only really doable with lots of high-level combinators, which in turn hinder debuggability.
clausecker··on The history of Unix's ioctl and signal about window sizes
This stuff sucks because if the application forgets to turn it back off, the terminal pukes random control characters into your shell every time the window is resized.
clausecker··on Limitations of Frame Pointer Unwinding
The “function prologue is at least 8 bytes long” bit only applies if CET is used. If it is not used, the endbr64 instruction is not emitted and the prologue is only 4 bytes long.
clausecker··on Limitations of Frame Pointer Unwinding
Yeah, compilers are already pretty close to the limit of what is possible, unless your code is unusually poorly written.
clausecker··on The history of Unix's ioctl and signal about window sizes
Correct, that was one of the concerns. Note that tcsetwinsize() is mainly provided so that the pty master (i.e. the terminal emulator) can set the window size to be seen by the slave (i.e. the application running in the emulated terminal). The other direction is not explicitly banned though.
clausecker··on The history of Unix's ioctl and signal about window sizes
A signal means that the application can immediately redraw its UI to the new dimension even if it is not currently reading input.

Also, if the size was reported in-band, it would mess up applications that are not aware of that in-band signalling.

clausecker··on The history of Unix's ioctl and signal about window sizes
My point was not that the terminals don't report ws_xpixel and ws_ypixel, but rather that none support the application setting the resolution using tcsetwinsize() with the terminal subsequently changing its video mode / resizing itself to the requested size.
clausecker··on The history of Unix's ioctl and signal about window sizes
I submitted the proposal for `tcgetwinsize` to POSIX a few years ago. I originally wrote it because I was sick of having to turn off _POSIX_C_SOURCE for just a single file to get glibc to expose TIOCGWINSZ.

SIGWINCH and the TIOCGWINSZ ioctl() were originally omitted from POSIX as they were considered relevant for windowing systems only and GUI-stuff was considered out of scope for POSIX. Furthermore, POSIX only specifies ioctl() for STREAMS; other interfaces that traditionally use ioctl() calls are specified in POSIX using wrapper functions (which is what the new interface is; it is specified such that you can implement it just by wrapping the traditional TIOCGWINSZ/TIOCSWINSZ ioctl calls).

My original proposal had functions tcgetsize() and tcsetsize(), but it turns out that QNX already uses these identifiers with an incompatible signature, so a last minute change was made to name these tcgetwinsize() and tcsetwinsize().

Furthermore, the winsize structure traditionally also has ws_xpixel and ws_ypixel members indicating the resolution of the terminal. This existed primarily becaus on some historical virtual terminals, a client could change the video mode by calling the TIOCSWINSZ ioctl, providing resolution and row/column count for the desired video mode. While no current virtual terminal known to me supports this, the POSIX spec mandates that if a slave PTY calls tcsetwinsize(), the window size update is propagated to the master, allowing terminal emulators to implement this feature if desired. Another objection raised was that the traditional unsigned short type may be insufficient for future high-definition screens and a resolution may not be well defined for some types of terminals like hardcopy or braille terminals.

I maintain that submitting a feature to POSIX and waiting for a new version of the standard to be released is probably the easiest way to get glibc to implement a feature you want.

clausecker··on Why Gauss wanted a heptadecagon on his tombstone
Yes, but only if that number is a prime.
clausecker··on Intel: New Core Ultra Processors Deliver Breakthrough Performance
No AVX-512, I think I'll pass.
clausecker··on In pre-WWII Berlin, the shape of your roof was a political decision
I lived in this borrough for most of my childhood. Never knew about this dispute though. The Onkel Tom settlement is really beautiful. It comes with an underground station with an integrated shopping mall -- a novel concept back then.
clausecker··on Do low-level optimizations matter? Faster quicksort with cmov (2020)
That could be. Agner's tables seem to confirm that.
clausecker··on Do low-level optimizations matter? Faster quicksort with cmov (2020)
Are you sure? I recall cmov always having single cycle latency.
clausecker··on 'Model collapse'? An expert explains the rumours about an impending AI doom
> Most of the time I then answer my own questions a few months later.

Thank you for doing that. This is very valuable.

clausecker··on SSH has become our universal (Unix) external access protocol
Sure, but the setup really sucks for transitive jump hosts. It would be cool if SSH supported bang paths to access a remote host via various jump hosts, like `foo!bar!baz@quux` to access `baz@quux` by jumping through foo and then bar.
clausecker··on SSH has become our universal (Unix) external access protocol
SSH is great but rapidly becomes less so once companies decide to put their servers behind some times cascaded SSH gateways, so you need to know which magic invocation of jump hosts to put in to have your connection go through anyway.
clausecker··on Intel details Skymont
For me, the most important part is -fno-math-errno which allows the compiler to ignore that libm functions are allowed to set errno. This is perfectly safe (unless you rely on that rarely known side effect) and is usually the one flag I explicitly set.
clausecker··on Posix.1-2024 is published
Also c17 -G to create shared objects, SIGWINCH and tcgetwinsize() to query the size of a terminal window, lots of new shell features, make is now somewhat useful, gettext() and associated commands are in, asprintf(), C17 support, strlcpy, strlcat, and many more all new and exciting features.
← PreviousPage 2 of 4Next →