HNHacker News
TopNewBestAskShowJobs

mmcloughlin

644 karma · joined July 6, 2017

submissionscomments
mmcloughlin··on Study: Air purifier use at daycare centres cut kids' sick days by a third (2023)
Perhaps there is some evidence that people do get excited about free school lunches: Governor Tim Walz’s lunch policy in Minnesota has been a part of the buzz surrounding his recent Vice Presidential nomination.

https://www.cnbc.com/2024/08/19/universal-free-school-lunche...

mmcloughlin··on The Zen of Drinking Alone
For me, Naltrexone was an incredible help in reducing cravings in the first few months. I came off it after around six months and no longer need it, though I think many people take it for much longer and there's not much downside to doing so.

I avoided AA due to the quasi-religious aspect, but Smart Recovery meetings helped me in the initial phase (https://www.smartrecovery.org).

I was always concerned about the longer term aspect of replacing alcohol in social settings, and there is still some awkwardness there but non-alcoholic beers have really helped for me. The scene has exploded in recent years and they're really quite good, see Athletic Brewing for some excellent craft non-alcoholic beers (https://athleticbrewing.com). In a social setting you could be drinking one and nobody would have to know. I don't hide it but I'm still glad to have something "special" to drink at an occasion. And I drink them alone too: they fill that role of something to drink when I want to relax, and I enjoy that placebo effect.

mmcloughlin··on Destroying x86_64 instruction decoders with differential fuzzing
Great project and write-up. I'm reminded of a couple other projects.

MC Hammer project for LLVM tests round-trip properties of the ARM assembler. http://llvm.org/devmtg/2012-04-12/Slides/Richard_Barton.pdf

Sandsifter x86 fuzzer. https://github.com/xoreaxeaxeax/sandsifter https://youtu.be/KrksBdWcZgQ

mmcloughlin··on Present code with step-by-step highlights [slides]
I implemented something like this in Python for my LaTeX/beamer presentation recently. For example, see this and the following slides:

https://speakerdeck.com/mmcloughlin/better-x86-assembly-gene...

The sample code is in a file with special comments at the end of each line specifying which slide numbers it should be revealed on as well as inline commentary to show to the right of the line. Syntax highlighting is provided by Pygments.

I was thinking about open sourcing it, it's actually only approx 200 lines of Python but I think it's quite effective.

mmcloughlin··on Avo: Better X86 Assembly Generation from Go
Oh cool, thanks for sharing that talk. I might try to submit an avo talk to a meetup, if anyone will have me :)
mmcloughlin··on Avo: Better X86 Assembly Generation from Go
Only a small number of instructions in Go assembly are architecture neutral.

avo currently implements the x86 subset of Go assembler. It's definitely possible to add support for additional architectures, but it may be a fairly significant project.

mmcloughlin··on Avo: Better X86 Assembly Generation from Go
Thanks :)

> Any chance of ARM/ARM64 support?

Yes multi-architecture support is definitely something I've had in mind. However I wanted to limit the scope for the initial version, so I could produce a result in a reasonable time and allow me to gauge interest.

> It would be super useful if you could generate the code to memory then execute it directly.

avo was inspired by PeachPy and asmjit, both of which can produce executable code directly. So implementing an assembler in avo is something I have had in the back of my mind. However it wasn't one of my primary goals.

The use case I initially had in mind is massively unrolled crypto routines, where there's a lot of assembly code required but not much going on conceptually. My AES-CTR mode CL (https://go-review.googlesource.com/c/go/+/136896) and meow hash port (https://github.com/mmcloughlin/meow) got me thinking in this direction.

mmcloughlin··on Avo: Better X86 Assembly Generation from Go
Yes! This tripped me up at one point. My comment says "Otherwise we could be in the bizarre special-case of 3-argument CMP instructions."

https://github.com/mmcloughlin/avo/blob/0e253b3753beb409b3dd...

It gets to the point where the only source of truth is the Go assembler itself. My test suite takes the avo instruction database and generates a massive assembly file with one line per instruction form, then passes this to `go tool asm`.

mmcloughlin··on Avo: Better X86 Assembly Generation from Go
Haha yes! PeachPy was written at Georgia Tech and avo was written in California.
mmcloughlin··on Avo: Better X86 Assembly Generation from Go
avo author here. Yes PeachPy was the inspiration for this, as well as asmjit. Both mentioned in the credits:

https://github.com/mmcloughlin/avo#credits

PeachPy actually has Go output already, and Damian Gryski has used this to great effect:

https://github.com/mmcloughlin/avo/issues/40

Unfortunately because PeachPy wasn't initially written with Go in mind there are some rough edges and Go features it simply doesn't support. avo hopes to fill this gap for Go programmers.

mmcloughlin··on Avo: Better X86 Assembly Generation from Go
Author of avo here. While I did really enjoy working on this project, I still fully agree with you.

Go (Plan 9) syntax is not sufficiently different to make it a powerful intermediate representation, hence SSA as you point out. In fact many of the differences are frustrating subtle changes in instruction mnemonics or operand order. This might be okay if there was a canonical instruction database that made all these differences from Intel and AT&T easy to discover. However these exceptions are really recorded in various parts of the golang.org/x/arch/x86 repo. Producing the instruction database for avo was quite a time-consuming process. See:

https://github.com/mmcloughlin/avo/blob/master/internal/load... https://github.com/mmcloughlin/avo/issues/23

I've gained a lot more familiarity with the assembler and supporting infrastructure, so I'm hoping I may be able to contribute to this area of the core Go project.

mmcloughlin··on Your pprof is showing
Thanks for pointing out the mistake. I will update the post accordingly.

I still think there are some valuable lessons here.

mmcloughlin··on Show HN: Globe visualizations in Golang
If you'd like to output to an arbitrary writer, you can use the Image method.

https://godoc.org/github.com/mmcloughlin/globe#Globe.Image

This can be passed to an image encoder like

https://golang.org/pkg/image/png/#Encode https://golang.org/pkg/image/gif/#Encode https://golang.org/pkg/image/jpeg/#Encode

These functions take io.Writer objects. SavePNG was provided for convenience.

mmcloughlin··on Show HN: Globe visualizations in Golang
Oh nice! Should have used this for the cities example here

https://github.com/mmcloughlin/globe/blob/master/examples/ci...

In fact I might switch it, since the cities json file I used has some oddities.

mmcloughlin··on Show HN: Globe visualizations in Golang
Jason Davies has some beautiful maps!

Interactive would be hard. It would be relatively simple to output an animated gif though, as the pinhole library does here

https://github.com/tidwall/pinhole/blob/master/examples/eart...

I'm planning to add this feature.

mmcloughlin··on Show HN: Globe visualizations in Golang
Thanks!

I guess I wanted to use it to visualize data coming from other Go projects I was working on, so it made sense. A tiny example of this is https://github.com/mmcloughlin/spherand which correctly generates random points on a sphere. I also had seen pinhole (https://github.com/tidwall/pinhole) and thought it would be fun to play around with.

mmcloughlin··on Show HN: Globe visualizations in Golang
Standing on the shoulders of giants :)

gg and pinhole made this easy to write. The globe package really just deals with mapping (lat, lng) space to cartestian coordinates (and also includes some land/country datasets).

mmcloughlin··on Show HN: Globe visualizations in Golang
Yes the top image in the README is cities. The Starbucks image is lower down in their distinctive green color.
mmcloughlin··on Show HN: Globe visualizations in Golang
Thanks! I was really glad to find that imgur tool. I wanted to make sure the images in the README were kept in sync with the code.

Also credit has to go to https://github.com/tidwall/pinhole where all the actual rendering happens!

mmcloughlin··on Show HN: Globe visualizations in Golang
Yes, the first image in the README is from cities.go. The data file is too big so I didn't include it in the repo, but the Makefile will fetch it.

https://github.com/mmcloughlin/globe/blob/master/examples/Ma...

It came from this node package

https://www.npmjs.com/package/cities.json/

It looks like the dataset has more cities in some countries than others.