HNHacker News
TopNewBestAskShowJobs

zachmu

919 karma · joined August 6, 2019

submissionscomments
zachmu··on Show HN: Probabilistic Tic-Tac-Toe
I got the die to settle on an edge in the corner of the playfield, which triggered a re-roll.

Is this actually simulating a d20 with physics?

zachmu··on 23words.com
Nice try but "basket" is obviously not a real word
zachmu··on Brain overgrowth dictates autism severity, new research suggests
This reminds me of a twitter thread I read a few years ago making this prediction:

https://www.tinygnomes.com/qwiki.cgi?mode=previewSynd&uuid=B...

We had already known from autopsies that neural density in certain brain regions is much higher among autists.

zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
Yes, it is the same situation. No, we don't tend to use unique names for errors. The idiom is just too strong.

This is somewhat mitigated by consistent consecutive error handling, meaning you always immediately dispatch an error on the line after assigning it. Every time we have had bugs because of this, it's because someone tried to be clever and delay handling an error until slightly later (like at the end of an if else chain where each branch might have had an error).

zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
err has the same problem as ok, it's true. It's a messy, kind of embarrassing spot in the language and idioms, not something to celebrate.
zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
This article has a hilariously defensive tone.

The reality is that the vast majority of error handling in go is to do one of two things

1) pass it up the stack 2) wrap it and pass it up the stack

The fact that you must do this explicitly in all cases is a failure of the language. Many people have pointed this out, but the go team and elite members in the community are very dedicated to the myth that every error is precious and special and must be handled in a one-off manner.

zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
My whole point is that following the convention basically guarantees shadowing in many contexts. That's bad.
zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
You can get that by implementing an error type, or otherwise constructing a new error every time one is returned. But doing this adds to the cost of returning the error.

This is how we use most errors in our code base. But we tend to not treat them as sentinels, we are only interested in the descriptive error messages.

zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
It has also become somewhat common to use io.EOF to signal the end of iteration, like the reader libraries do.
zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
The problem is error wrapping. Somebody deeper in the stack can break your equality check.
zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
There is a link in the blog to a public gist, it's just a single file you can download and run.
zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
That's pretty cool, I'll try to remember to post a follow up when this makes it into a release.
zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
Our database is within spitting distance of MySQL's raw performance and getting faster all the time. Certainly there are some applications where that will not be fast enough. That didn't prevent MySQL from becoming the worlds most widely deployed free database.

And yes, postgres is faster and will eventually pass MySQL in deployments, but that's success also has very little to do with its speed.

zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
My main argument against this practice isn't performance, it is that it makes error handling more difficult to write, review, and maintain. Treating errors as opaque and passing them up the stack in the general case is automatic and trivial to get right. Wrapping them is not.

I agree with your point about debugging, but I have a different idea how to best achieve it. Rather than wrapping an error at every stack layer, just take a stack trace when the error is created. This works great as long as... you don't design the system to require sentinel errors. Treating errors as rare, exceptional events rather than normal values used for control flow changes how you approach them.

zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
This is true.

We have in the past eliminated sentinel errors and gotten measurable gains from doing so, but this is mostly because our errors were both common (occurring several times on every request) and expensive to construct. The direct cost of errors.Is() was minor compared to the cost of building the error itself.

And you might be surprised how common it is for people to insist on wrapping an error at every layer of the stack. I've gotten in arguments with these people online, they're out there.

zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
Corrections and new title are now live. Thank you for your forbearance.
zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
That's interesting, because I ran the benchmarks on that version of Go.
zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
That's the BenchmarkFoundErrorsIsNilCheck variation, and it eliminates the performance penalty on the happy path. Still just as bad on the error path.
zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
You'll never get those 4 nanoseconds of your life back though
zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
Agree to disagree here. And yes, this article is a follow-up to the linked one.

The last section of the blog has a discussion of aesthetic and philosophical concerns around using errors for control flow. I'm against it, for the reasons I provide. YMMV.

zachmu··on Go: Sentinel errors and errors.Is() slow your code down by 3000%
Blog author here with a regretful correction. This result is not accurate, mea culpa. The headline should read: errors.Is() is 500% slower.

Basically: the critical functions in the benchmark are small enough they were being inlined by the compiler, which means it's possible for the compiler to further optimize the loop to avoid all comparisons in some cases, producing an inaccurate result for some of the benchmarks. You can fix this by adding noinline directives to the methods.

I'll be publishing an update to the article and a post-mortem on how this slipped past review. The rank ordering of techniques in the article is unchanged, but the magnitude of the difference is not nearly so large.

zachmu··on Business Booms and Depressions Since 1775 (1943)
Ah to have been born in the Era of Good Feeling
zachmu··on Introducing Copilot+ PCs
If Microsoft thinks I'm going to let Windows store screenshots of my work every second indefinitely with their current approach to online identity and privacy, they are nuts.
zachmu··on LDAPjs decomissioned by maintainer over hateful email
I think of it more as a general observation: the people who maintain open source projects that must deal with the public must have thick skin, or they won't last. Acknowledging that there are and will always be assholes like the email writer in the world is not to excuse their behavior. It's great to call out shitty behavior and try to get rid of it, but it will always be around at some low level, that's the reality.
zachmu··on Oh Frick Go Back: GUI Tool to Removes Ads from Various Places Around Windows 11
Microsoft cramming more and more ads in their OS could be the push we need to finally achieve the year of the Linux desktop
zachmu··on Flock Safety is the biggest player in a city-by-city scramble for surveillance
I will admit I'm just repeating their claim unskeptically :)
zachmu··on Flock Safety is the biggest player in a city-by-city scramble for surveillance
Very cool company, now involved in solving 10% of reported crime in the US.

They use DoltDB to version control their machine learning feature store:

https://www.dolthub.com/blog/2024-03-07-dolt-flock/

zachmu··on Tesla conducting more layoffs, including entire Supercharger team
You can just say: I don't know. I don't know why Tesla is pursuing layoffs, or this particular layoff strategy.

And because I don't know, I don't have a strong opinion about it one way or the other. That's all "benefit of the doubt" means. "I don't know one way or the other, but this guy has a pretty good track record, so until I know more I won't assume anything bad."

zachmu··on Why SQLite Uses Bytecode
Dolt's EXPLAIN output prints the execution tree directly. E.g.:

    explain select * from xy join uv on (x = u and u  > 0) where u < 2;
    Project
     ├─ columns: [xy.x:2!null, xy.y:3, uv.u:0!null, uv.v:1]
     └─ LookupJoin
         ├─ IndexedTableAccess(uv)
         │   ├─ index: [uv.u]
         │   ├─ static: [{(0, 2)}]
         │   ├─ colSet: (3,4)
         │   ├─ tableId: 2
         │   └─ Table
         │       ├─ name: uv
         │       └─ columns: [u v]
         └─ IndexedTableAccess(xy)
             ├─ index: [xy.x]
             ├─ keys: [uv.u:0!null]
             ├─ colSet: (1,2)
             ├─ tableId: 1
             └─ Table
                 ├─ name: xy
                 └─ columns: [x y]
zachmu··on British Columbia to recriminalize use of drugs in public spaces
Of course the boundless compassion of the kind that permits public spaces to be littered with needles and fentanyl smoke is driven by a political ideology, come on.
← PreviousPage 2 of 9Next →