HNHacker News
TopNewBestAskShowJobs

jlouis

2,358 karma · joined June 21, 2008

Hacker. Prefers functional programming.
submissionscomments
jlouis··on Choose Boring Technology (2018)
One of the main points of this essay is that you have a certain budget for innovation, exemplified in a fixed token count, you spend on your tech stack. Once you are out of tokens, you end up injecting too much risk into the project, and it is likely to fail.

I think this view has to be generalized. Your budget isn't simply affecting the tech of the system, but it also affects the whole: business case, decision loop, company maturity, etc. If the business case is a true moonshot vision of epic proportions, you have to think about what tech stack can support it. In some cases, you can be fairly conservative in your tech choices. That's probably a good idea if the business case is pretty wild and ambitious since it will ground the project nicely.

However, in many cases things go hand in hand. There's often some important complex part of the business case which require complexity in the tech stack. Say, for the sake of the current spotlighted tech, the central component need a large language model. Then, that LLM is going to eat into your development effort budget quite a lot. You should probably focus on getting the core part of the system running quickly, and support it by conservative tools.

The flip side is a quite straightforward business case. Then, the competitive edge needs to come from better application of the tech, and that will often require more innovative approaches.

In summary: you need to think about where the innovation is in the project, and modify the tech choices accordingly.

jlouis··on Unpacking Elixir: Resilience
It's an Erlang convention. Erlang suffers from having a very rudimentary module system, so a clean separation between the public API and the gen_server API isn't that easy to make. If you have access to a better module system, you should definitely induce a cleaner separation and adapt that as a convention. It helps people in general, but the in particular the less experienced.
jlouis··on Unpacking Elixir: Resilience
This sort-of stems from the underlying OTP principles from Erlang. Each application has their own isolated supervision tree, and your system contains a number of applications.

Hence, a library which contains a service is likely to have their own internal supervision tree. Your code can then sort-of latch onto this tree and piggyback on its existence. This is very common in web applications because when a new connection is opened, you spawn a process to handle the connection. If connections are (de-)multiplexed into channels like in HTTP/2 and HTTP/3, you'd just move up one layer and spawn a process per channel.

Likewise, if you have a limited resource such as Postgres connections, they are usually maintained in a pool, and access is queued until a connection from the pool is ready for use. This can circumvent the need for something like pg_bouncer in some use-cases.

jlouis··on Unpacking Elixir: Resilience
The one_for_one policy means that if a child process terminates, it will get restarted. It is appropriate when the child processes managed by the supervisor are (relatively) independent. The contrasting policy is one_for_all where a terminating child will also induce a restart of all the other children of the supervisor. This is appropriate when there's a number of important dependencies between the children processes, and you'd better just rebuild the whole subtree.

It is key to run the thought process of system failure. You need to understand what will happen if a certain part of your system errors out in an unforeseen way and make sure your restart policies are likely to right the ship.

jlouis··on ZFS for Dummies
True, but in ZFS, you don't usually use these names unless you are shoving disks around. In which case it's nice to have an identity on the disk.

Most of your work is a logical naming scheme on top.

jlouis··on LinkedIn adopts protocol buffers and reduces latency up to 60%
forEach() incurs a function-call overhead unless you optimize it away in a compiler. So the idea a loop would be faster by some multiplier is quite plausible.

To get an order of magnitude in difference, you'd have to construct a special case. I've seen a multiplier of about 3, but not 16.

As an aside: you use forEach() over for loops because most array processing operates on small arrays, where the marginal improvement of using a loop is limited. If you have a large array, you will eventually switch to a for loop if the loop body is relatively small. Likewise, when the request size is small, JSON works fine. But when your requests grows in size, the JSON overhead will eventually become a problem which needs a solution.

The underlying consideration is Amdahl's law.

jlouis··on LinkedIn adopts protocol buffers and reduces latency up to 60%
I agree.

There's also a lot of alarm bells going on when you have reports of averages without reports of medians (quartiles, percentiles) and variance. Or even better: some kind of analysis of the distribution. A lot of data will be closer to a Poisson-process or have multi-modality, and the average is generally hiding that detail.

What can happen is that you typically process requests around 10ms but you have a few outliers at 2500ms. Now the average is going to be somewhere between 10ms and 2500ms. If you have two modes, then the average can often end up in the middle of nowhere, say at 50ms. Yet you have 0 requests taking 50ms. They take either 10 or 2500.

jlouis··on LinkedIn adopts protocol buffers and reduces latency up to 60%
Parsing overhead is sensitive to the amount of work the service is doing. If the service is doing relatively little, and there's a lot of junk in your request, you are forced to parse a lot of data which you then throw away. JSON is particularly nasty because there's no way to skip over data you don't care about. To parse a string, you have to look at every byte. This can be parallelized (via SIMD), but there's limits. In contrast, protobuf sprays length encoded tags all over the place which allows you to quickly handle large sequences of strings and bytes.

If your cache is hot and has a good hit-rate, the majority of your overhead is likely parsing. If you microbatch 100 requests, you have to parse 100 requests before you can ship them to the database for lookup (or the machine learning inference service). If the service is good at batch-processing, then the parsing becomes the latency-sensitive part.

Note the caveat: the 60% is for large payloads. JSON contains a lot of repetition in the data, so you often see people add compression to JSON unknowingly, because their webserver is doing it behind their back. A fairly small request on the wire deflates to a large request in-memory, and takes way more processing time.

That said, the statistician in me would like to have a distribution or interval rather than a number like "60%" because it is likely to vary. It's entirely possible that 60% is on the better end of what they are seeing (it's plausible in my book), but there's likely services where the improvement in latency is more mellow. If you want to reduce latency in a system, you should sample the distribution of processing latency. At least track the maximal latency over the last minute or so, preferably a couple of percentiles as well (95, 99, 99.9, ...).

jlouis··on Vale's first prototype for immutable region borrowing
Elimination is perhaps too strong a word, as you can't eliminate it entirely. But you can reduce its cognitive load by a large factor. The amount of code which is being written in a garbage collected language is a witness.

More manual memory management methods still have their place, because there are problems where you can't afford to use a garbage collector, or where it gets into the way.

C++ will be relevant for many years to come. It has way too much momentum as a language and too much software has been written in C++ to ignore it. I personally think Rust will eventually carve up a large part of its niche though, because I think it has a far better approach to managing memory.

jlouis··on GitHub merge queue is generally available
It's totally unreadable. There's 5% meat in it almost at the very end, the rest is about selling the feature.

The problem is that if you have multiple branches going into the same (mono)-repo, then they might all pass a localized CI-check, but fail if they are all merged. This is because the branches have an interaction between them. It can lead to a stall in commits and because everything hinges on the repo, work is going to stall as well.

So you serialize the branches, and impose an order on them: [x_1, x_2, x_3, ...]. Now, when running CI on one of these, x_j say, you do so in a temporary branch containing every branch x_i with i < j. This will avoid a stall up to branch x_j, if you started to merge the branches in order. If CI fails on branch x_j, you remove it from the list (queue) of branches to be merged and continue.

jlouis··on Vale's first prototype for immutable region borrowing
If you witness the amount of effort/work/man-hours that is being poured into making memory management easier, I'd say it is far from a trivial problem.

If you witness the endless amount of bugs, many security related, which stems from the idea that people can handle memory, I'd say it is far from a trivial problem.

If you witness any modern language, a common design principle is to eliminate memory management. Which argues it is far from a trivial problem.

jlouis··on My thoughts on OCaml
A language like ocaml excels when the input and output are program-like, and the problem can't be number-crunched by hardware. The typical example would be a compiler. Other examples would be model checkers, code generators for number crunching libraries, proof assistants, and so on. Complex problems, where you need to explore different avenues of approach quickly, and where symbolic manipulation is at the heart of the problem.

Thus, ocaml is best used as a "kernel" or "module". The contextual part of your system uses the part written in ocaml as a service.

But ocaml doesn't excel at problems which are common to a typical company. The people who are in the intersection of wanting to solve those problems, and ocaml developers are few. The same intersection with a more mainstream language is far larger.

However, if you find yourself with a problem at which ocaml excels, chances are the mainstream languages ends up falling short very quickly, because they tend to lack the abstraction features necessary for correctly handling the complexity.

jlouis··on Erlang/OTP: Garbage Collector
It likely would. But efficiency is only one factor. Many Erlang applications are far more concerned with consistent latency than throughput efficiency. So a switch to the JVM is a lot of cost.
jlouis··on John Carmack on Functional Programming in C++ (2018)
Enumerations are not ADTs.
jlouis··on Olric: Distributed, embeddable data structures in Go
In Erlang, mnesia has a couple of things going for it:

One, it stores Erlang terms. The consequence is that you need no data conversion when you want to store data persistently on disk. You just save whatever term you have.

Two, it provides Key/Value lookup at memory read speeds. It also does so across Erlang processes, so you don't have to call into another process to grab data in most cases. This was originally a main design constraint. You need it for low latency operation, and the only way to avoid a disk read is to keep things in memory. Nowadays, since we have fast disks with no seek-time, it matters less. But when Mnesia was built, we didn't have that luxury. Note that many other systems run in separate processes (memcached, redis, ...) which incurs a context switch and data transfer across a OS process boundary. When the K/V store is in the same memory space things are much faster.

Three, it is an excellent tool for rapid prototyping, and early development work. You can easily buy two terabytes of memory nowadays. Hence, scaling memory is relatively easy (save the time it takes to make that data hot in memory). This means your first million customers are easily served from memory, and it'll take a while before you reach a million customers. Mnesia also allows you to plug in other storage backends, so you can eventually move to a more traditional setup later.

Four, mnesia does provide query capability through a query planner. So for the occasional larger query, there are tools built-in which solves your problem in a very small amount of code.

jlouis··on CD Projekt is remaking the first Witcher game in Unreal Engine 5
Witcher 1 is a game in a number of acts, where each act is a relatively small closed space. It would be a really great way to get some UE5 knowledge to transplant into other games. By keeping those parts static in development, you get to use all the interesting new UE5 tech such as Lumen and Nanite.
jlouis··on CD Projekt is remaking the first Witcher game in Unreal Engine 5
FWIW, Id Tech 7 is built to support a game like Doom:Eternal, and nothing more. And the game itself is shaped around the capabilities of the engine. That's why it works.

Note Id had a texture streaming system in Rage in order to support a large seamless game world, but they cut that large open world for Doom:2016 and Eternal. In contrast, CDPR's games just grew with each new Witcher release.

jlouis··on Oracle Contributing GraalVM Community Edition Java Code to OpenJDK
You carefully avoid allocation.
jlouis··on Oracle Contributing GraalVM Community Edition Java Code to OpenJDK
No.

See Scheme48 or Go. There are some ways around that bootstrap problem.

jlouis··on Copilot under fire as dev claims it emits 'large chunks of my copyrighted code'
No.
jlouis··on C Minus Minus
The API cut ended up being in a different place with LLVM and WebAssembly. But the core idea still stands, and has been a hot potato for many years. In some ways, things are better now since there are fewer architectures than in the 90'es, so you don't have to support that many backends. On the other, things are worse because the amount of work you have to sink into a backend is non-trivial and ever growing.

One particular key aspect is that languages which have strong functional features tend to mismatch with typical imperative backends. This has been true for LLVM. It is unfortunate, because in reality, most IRs are essentially best described as small functional languages: they make state passing explicit, as it exposes better optimization analysis. SSA-form is functional programming in disguise.

jlouis··on The FreeBSD/Firecracker Platform
Documentation.

Everything is in one place, and it is maintained. In contrast, Linux requires you to go look up documentation in a lot of different places, and it is highly dependent on distribution what to do in a given situation.

One reason for this is that FreeBSD maintains not only a kernel, but also a userland. This means a change in the kernel can immediately be followed by appropriate changes in the userland and vice versa.

jlouis··on Go: Redefining For Loop Variable Semantics
It is a combination of scoping, which other people already wrote about, and also because the language support mutable data by default. Had the language been immutable/persistent by default, this particular semantic problem cannot occur in the first place.

Complexity increases rapidly when you combine constructs in a programming language. You get some feature interactions which are hard to get right, and also to predict.

jlouis··on Go: Redefining For Loop Variable Semantics
The reason for this change is to make wrong programs into correct programs. The examples will introduce more GC pressure, because the `append(..)` will append different values as the programmer expected. Thus, correcting the bug adds to GC pressure.

In the cases where the new value isn't appended, the compiler can easily optimize it away, and reuse the same memory location in a register or on the stack. My guess is that the optimizer portion of the compiler is at a place nowadays where this will happen, with no further change needed. When the compiler was new, it might have been a regression in efficiency.

jlouis··on Great Works in Programming Languages (2004)
Necula's work on proof-carrying-code was more or less transformed into CCured which is nothing but memory management.

It's from 2004. A lot of the interesting stuff with separation logic was just getting started at that point in time. This branch led to Facebook's Infer and bi-abduction.

jlouis··on GeForce RTX 40 Series
Much larger L2 cache on the GPU.

The 30xx cards needs a wide bus to feed it, but with the L2 cache on the GPU, you can get away with a smaller bus width (and faster memory on top, things shifted in the last couple of years and DDR6(X) memory is even faster now than it was).

Some of this also has to do with what kind of memory configurations you want to offer, as they are tied to the bus width. So if you widen the bus, you are looking at using more memory chips and having more memory. This pushes the price point upward, and you want it to tier somewhere in the middle of it all.

One "mistake" on the 30xx (Ampere) series were that the 3080 was much too powerful for its price point, and you couldn't really cram too much more power out above it due to its memory config. With this change, you can introduce a 4080Ti in between the 4080 16Gb and the 4090 as a mid-seasonal upgrade, and widen the bus a bit to satisfy it.

jlouis··on FLAC 1.4.0 released – added support for 32-bit audio
I don't think it's for storing music.
jlouis··on 40% of Google users now connect via IPv6
It rotates about once a day in most operating systems. Called ipv6 privacy extensions. This is of course defeatable, but it provides a nice black hole for a device. It moves on and you can't connect to it anymore.
jlouis··on We Halved Go Monorepo CI Build Time
In theory.

In practice, you often end up with larger changes which are mostly janitorial. Bumping a version of a log library across the infrastructure, or a version of a serialization system. This simplifies dependency convergence and a best handled as if they are cross-project changes.

The other problem is that over time, good factoring tend to deteriorate. A large software project will invariably have people with different brains working on it, and they'll have different needs for the factoring. So the project naturally pushes itself toward situations where cross-project changes become a necessary thing.

jlouis··on Tailscale SSH
It's likely just because it's a VPN not under control of the corporation. Corporations have this magical wand which they swing to make it hard for people to do their work :)
← PreviousPage 3 of 22Next →