Better HN
topnewbestaskshowjobs
Log inSign up

physicles

1,822 karma · joined Feb 3, 2019 (7y ago) · 645 submissions

Submissions

comment 3y ago · link · parent

Good counter-point. I see these main points over there:

1. It doesn't scale (there it is again)

2. Queuing with Postgres is super fiddly to get right

3. You're hacking a queue on top of something that isn't a queue

4. Running redis or rabbit isn't all that complicated

#1 as TFA argues, premature concern about scaling is the root of so much needless complexity. You should make scaling decisions like this: 1) assume boring tech like PG will satisfy your needs; 2) if it demonstrably does not, then find something that does.

#2 is obviously true; just look at this thread. There are battle-tested queuing libraries in most popular languages, but you do have to dig into the details of how they interact with things like pgbouncer.

#3 I guess so? But if the queue abstraction works and isn't leaky, what does it matter?

#4 can be debated. For several years I've been running a moderately complicated setup with 2 databases, redis, and kafka for several years. There's no way I'm going to add another piece of tech unless there's no other choice. The cognitive cost is too high.

The main debate is in the tradeoff between #2 and #4. Personally, if I can use an existing piece of tech to solve a problem to avoid having to ops another piece of tech, then I'm going to do that every time.

comment 3y ago · link · parent

See my other comment over here: https://news.ycombinator.com/item?id=37610899#37619993

comment 3y ago · link · parent

It did feel unnecessary at the time, but I was obsessed with all things half-life so I was there mashing the refresh button the night when it launched. The launch itself was kind of a shit show, but IIRC it didn’t take more than a few months for everyone to realize that it was massively improved compared to the old ways of distribution.

comment 3y ago · link · parent

There’s a huge footgun with replication that the article didn’t mention, and it’s the reason why I don’t use it.

Postgres is VERY committed to making sure a replication slot’s consumer doesn’t miss any data. This means that if a consumer stops consuming data from the slot, Postgres will helpfully store all that missed data… right up until the disk fills up and the database falls over. Had this happen during prototyping with two different SaaS DBs, and the only way to get it back up was to file a support ticket. (I can’t remember if metrics warned that the disk was about to fill up or not). Basically, if your replication slot consumer stops reading, that should trigger some kind of alert.

The other reason I don’t use it: the code path to get the initial snapshot of a table is totally different from the code path to read changes. Initializing the read from the replication slot so you never miss any changes is nontrivial.

It’s too bad, because replication is obviously the least hacky solution for change capture.

I use polling, but storing the txid instead of updated_at.

comment 3y ago · link · parent

For polling, instead of updated_at, I use a _txid column that gets set by a trigger to the current transaction ID. Then, when polling, use txid_current() to see which transactions have committed and which haven’t. It’s a little dicey and super easy to hit fencepost errors, but it’s been running smoothly in production for a few years.

comment 3y ago · link · parent

We’ve got some logs in CloudWatch, but I barely use it because the query interface is unfathomably slow (in terms of query throughput). Do you use the web interface to query, or some other way?

comment 3y ago · link · parent

Thanks a ton! Details around this use case are conspicuously missing from the public discourse.

You've really changed your workflow to adapt to these new tools. The amount of mental effort seems comparable to learning a new IDE, maybe a bit less.

Instead of the chat app, I wrote a python script that uses the GPT-4 completion API. I can just pop over to the terminal and type 'chat' and it's there. As far as I can tell, it's basically the same as the app.

We are starting to see AI tooling that can fit an entire 100k line code base in its context window. I still see myself having a job five years out. Ten years out, not so much. Luckily I'll be close to retirement.

comment 3y ago · link · parent

I've also been in industry for ~17 years and coding for a decade or so before that, but I'd seriously sit down and watch an hour long video of someone just using AI to work on a large existing system. Virtually all the AI coding content out there is about building something new from scratch.

Could elaborate more on your workflow? Do you use Copilot, or just GPT4? Are you copying and pasting large blocks of existing code to hint at how things should fit together, or do you describe how the existing code is structured in English? Do you find yourself decomposing your work differently so as to fit your new AI workflow?

comment 3y ago · link · parent

I agree that windows is a gateway to sell people on office, but open sourcing it? Getting decades worth of apps and drivers working on the Linux kernel instead of, you know, doing nothing? I don’t see how either one benefits them.

They’re just monetizing users as much as they can stand to juice revenue. No other explanation is needed.

comment 3y ago · link · parent

This is one of the reasons why I stopped using Ubuntu and switched to pop os. Is there something keeping you from switching to another Debian derivative?

comment 3y ago · link · parent

Even after a half dozen lan parties, my group of friends could never figure out how to get windows file sharing working reliably. Eventually I set up an http server so people could download patches and stuff. Worked great. I put a sign on the wall with my IP address, 10.1.1.32.

comment 3y ago · link · parent

For the people building the product, suggestion boxes don’t hit the same way as actually using it. I think the employee driver badge is super corporate but also a good move if you want to improve the product. At Microsoft this was called dogfooding, and for pre-release software it was painful, but an important part of the culture.

I notice this all the time with software. I tend to keep hardware for 5-8 years, and by the end of that window, apps and websites start feeling sluggish. Of course they do: all the devs have modern hardware and don’t notice how crappy the experience is on old hardware. You can tell them, but they don’t feel the pain and their empathy is limited by how much it actually impacts the bottom line.

comment 3y ago · link · parent

My understanding now is that using pgBouncer falls under the category of YAGNI / “the best part is no part”: don’t use it unless you have a demonstrated need for it, because it adds complexity.

About 5 years ago we migrated to postgres and installed pgBouncer because of course you do. Sometime last year I started seeing some weird issues like the article points out, and the more I looked into the gory details, the more shocked I became. (The fact that statement level isolation even exists is… wow)

So I did an experiment and deleted it. Things kept working just fine. We’re not living in a microservices world so application-level pooling is enough — I don’t think I’ve ever seen us use half of available connections.

comment 3y ago · link · parent

I see. I’ve seen embedded styling/html in localized text, but doing that with rtf also makes sense.

comment 3y ago · link · parent

I’m curious, why is that? When you’re dealing with semi-structured data like localization files, adding formatting seems counter-productive.

comment 3y ago · link · parent

I still have the programs I wrote when I went through this book. The experience of bringing a 3D world to life felt like magic: you start with a black screen, draw some lines, and when you move them around in just the right way there’s suddenly a world inside the screen. It’s hard to get that same feeling today.

I think I was gifted this book for my 13th birthday so some of the math was a bit beyond me. But learning assembly and working out some of the more intricate algorithms like polygon clipping were both great training for a new programmer.

comment 3y ago · link · parent

I spent a ton of time with this book too! It really lays everything out. The feeling of building something like that from absolute scratch was amazing. I can’t get motivated to do that again these days — ready-made, better implementations are too accessible.

I was 13 at the time, so I struggled with the math (this was pre-internet so I couldn’t just search stuff). I’d never seen matrices and wasn’t able to figure them out from that book. I distinctly remember hitting a wall in the chapter on lighting because it mentioned taking the dot product of two vectors, but I didn’t understand why that would give you the cosine of the angle between them because I’d never heard of the dot product before.

Edit: right at the bottom of page 405. I reread that sentence so many times.

comment 3y ago · link · parent

See my response to a sibling. I wasn't clear; I was implicitly differentiating between these:

1. errors that can be handled locally (such as parsing; in other languages, these situations are often signaled with return values instead of exceptions)

2. errors that can't be handled locally (such as network errors; other languages use exceptions for these)

My argument was that worrying too much about error handling performance in #2 is premature optimization. 1ms is extreme, but the actual figure of capturing a call stack in Go -- several microseconds, by my benchmark -- puts it squarely in the "don't worry about it unless your code is performance-critical" category.

comment 3y ago · link · parent

I think there's less daylight between us than it seems.

> Errors are normal, not exceptional.

The _handling_ of errors is normal. Code that doesn't consider errors is not production code.

And granted, in Go, control flow is driven by errors more often than in C++ or Java. Sentinel error values are common. See for example all usage of error.Is, checking for io.EOF, packages that define ErrSituationA and ErrSituationB, etc.

But my argument was about errors that can't be dealt with locally, where the origination and ultimate handling are very far apart. A given flow will encounter these errors relatively rarely compared to the happy path (and if it's not rare, you probably need to fix or change something). Having an intuition about this is important for predicting your code's performance. For example:

- The SQL call failed because the network connection dropped; client gets 500 or 502, or retry.

- A call to an external service failed because the network was bad; it gets retried.

- The SQL call succeeded, but the record the client asked for wasn't found, so the client gets a 404.

- Writing to a temporary file failed because the disk is full, so some batch job fails with an error.

Apart from potential concerns about DoS, worrying too much about the performance of error handling in these relatively rare cases is absolutely premature optimization.

DoS isn't even a concern. I just benchmarked capturing a call stack in Go, and it's on the order of a few microseconds. Unless you're in performance critical code (and you're benchmarking, right?), it's fine.

comment 3y ago · link · parent

Indeed, our code base is littered with fmt.Errorf("...: %w", err), but that only works if enough places in the code add context. Currently only about 15% of return sites do this.

And I disagree that the cost of carrying around the callstack is something to worry about. Errors are akin to exceptions in C++/Java: no happy path should rely on errors for control flow (except io.EOF, but that won't generate a call stack). They should be rare enough that any cost below about 1ms and 10k is negligible.

comment 3y ago · link · parent

I'm slowly retraining myself to write structured logs instead of Infof, etc. The extra effort really is negligible. There's a nice benefit too: my log printer takes structured logs and adds color coding, which isn't possible with Infof.

comment 3y ago · link · parent

In the last few months I've realized what I desperately need: a way to wrap an error with a call stack at the point where it enters our code base. This would probably save me on average 20-30 minutes a week.

I see this all the time:

   main.go:141 error: could not transmogrify the thing: a144cd21c48
And then I literally grep the code base to find the error message. That works ~50% of the time, but the other 50%, I see this:

   main.go:141 error: not found
And then I have to spend 5-10 minutes spelunking to try to find where that error might have originated from.

But this would be amazing:

   main.go:141 error: not found callstack=...

comment 3y ago · link · parent

Yeah it's essential to have a viewer that deals natively with structured logs.

I'm iterating on a log pretty printer that accepts structured logs in a pipe and does things like color coding, adding terminal-recognized vscode:// hyperlinks for call stacks, smart wrapping based on the terminal width, and special formatting for panics and stuff.

NCurses is probably coming in a couple months.

Does anything like this already exist?

comment 3y ago · link · parent

I turned off my history about a year ago in an effort to reduce the time I spend on YouTube. It sort of worked. I suspect this new change will help much more.

comment 3y ago · link · parent

This is a tour de force, and it accomplishes the goal of enabling FP using the Go syntax and toolchain.

But code written using this library is no longer Go: most Go programmers can't grok it, and it's awkward to call normal Go libraries because there's no way to know if that function you're calling is pure.

If your goal is to "make it easy and fun to write maintainable and testable code in golang" by making pure functions first-class, is there another way to do that without inventing a new language?

From experience and inspired by Carmack's classic essay on FP in C++[1], I tend toward a functional style: minimize state, treat locals as const, avoid non-const globals, enable parallelism by isolating state. Go makes it easy to write static analysis tools, so go vet could be augmented to, for example, keep track of which functions are pure, and show some yellow underlines at those places where input parameters are mutated.

I'd use something like that.

[1] http://sevangelatos.com/john-carmack-on/

comment 3y ago · link · parent

Go is dying?

comment 3y ago · link · parent

We built a new cluster and very carefully rolled over our producers and consumers. It wasn’t simple, but it’s possible to do without downtime.

comment 3y ago · link · parent

A rocket functions by ejecting mass out the back at high speed. By conservation of momentum, the rocket then accelerates.

You want to optimize for velocity gain (also known as delta-v) per unit mass of propellant. So the question is, should you eject something heavier at lower speed, or something lighter at high speed? Which is more efficient?

If you write out the equation for a rocket ejecting some propellant at some velocity, apply conservation of momentum, and solve for the ratio of delta-v to propellant mass (just a bit of high school physics), it turns out that a higher exhaust velocity makes a more efficient rocket.

As a sibling post points out, if you compare water vapor with hydrogen at the same temperature, hydrogen will have the higher velocity. Chemical rockets usually produce water and/or carbon dioxide, which are bigger molecules and therefore less efficient propellants than hydrogen. So if you have a way to heat hydrogen to the same kinds of temperatures you get in rocket exhaust — say, in a nuclear reactor — that’ll make a more efficient rocket.

There are of course considerations other than pure efficiency. Our most efficient rockets, ion engines, are indeed crazy efficient, but their thrust is measured in milli-newtons or newtons. They can’t be used to lift things off earth. They also use propellants like krypton and xenon, presumably because they’re easier to store than hydrogen.

comment 3y ago · link · parent

Not my experience at all.

We’ve been running a 3 node cluster for several years, and a significant minority of the times I’ve been paged is because ZK got into a bad state that was fixed by a restart (what bad state exactly? Don’t know, don’t care, don’t have two spare weeks to spend figuring it out). Note that we have proper liveness checks on individual instances, so the issue is more complicated than that.

Migrated to 3.3 with KRaft about half a year ago, and we haven’t had a single issue since. It just runs and we resize the disks from time to time.

comment 3y ago · link · parent

That’s unfortunate. When I was on windows phone in the late 2000s, every new feature got a round of threat modeling. Each team (pm/test/dev) were responsible for building the threat model themselves, but the threat model was reviewed by another security team.

What the hell happened? Is annual security training still a thing?

1
111213
22