frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Proposal: Add bare metal support to Go

https://github.com/golang/go/issues/73608
85•rbanffy•7mo ago

Comments

Someone•7mo ago
FTA:

  // printk emits a single 8-bit character to standard output
  //
  //go:linkname printk runtime.printk
  func printk(c byte)
So, printing “Hello, world!”, necessarily will have to make 13 calls to this function. I think I would have required a printk that prints an array of bytes. I expect that can be significantly faster on lots of hardware.

In contrast, there’s

  // getRandomData generates len(b) random bytes and writes them into b
  //
  //go:linkname getRandomData runtime.getRandomData
  func getRandomData(b []byte)
Here, they seem to acknowledge that it can be faster to make a single call.
jeroenhd•7mo ago
The method for printing uses an Intel UART driver to print characters. AFAIK, the standard low level UART generally only does single character transfers unless you write a (relatively) complex driver.

Rendering per string is better per string, but I'm not so sure how bad the difference is when it comes to UART but I doubt the system has enough throughput for the first implementation to matter.

90s_dev•7mo ago
I wonder if this is related to that bare metal bios os post from a week or so ago. I asked the author why he used tty asm calls to print instead of calling int 10 directly and he said it was more efficient, but for different reasons.

https://news.ycombinator.com/item?id=43873822

Someone•7mo ago
> The method for printing uses an Intel UART driver to print characters

The spec (rightfully) says “(e.g. serial console)”, not “Intel UART driver”.

You cannot know what bare metal you’re running on. On some hardware it could be sending data out over Bluetooth, USB or WiFi because that’s the only connection to the outside world.

ronsor•7mo ago
Arguably `printk(c byte)` should be `printck(c byte)`, and there should be a separate `printk(s []byte)` that handles an array of bytes.

If `printk` isn't implemented, then fall back to repeated calls of `printck`.

lcarsip•7mo ago
printk is the low level primitive for stdout printing and it's done this way as low level drivers generally only accept single characters.

There are upper level functions which simply takes a []byte and make fmt.Printf() work seamlessly and effectively when not printing on an UART that only takes a single character as output.

In TamaGo stdout is primarily used for debugging.

timewizard•7mo ago
> Here, they seem to acknowledge that it can be faster to make a single call.

It calls the internal Fill function to fill 4 bytes of the slice at a time. That calls the rng assembly stub function which uses 'rdrand' to get 32bits of random data. Which gets called len(b)/4 times.

I don't think they did it for speed but rather to be more idiomatic.

Anyways, OSDev has had a "Go Bare Bones" page for quite a while:

https://wiki.osdev.org/Go_Bare_Bones

jasonthorsness•7mo ago
We use 'scratch' containers for many of our Go applications, so they have no user-space stuff other than our application binary. It reduces exposure for security vulnerabilities. This proposal seems to be taking that approach to the extreme - not even a kernel. Super-interesting; I wonder if it could run on cloud VMs? How tiny could the image become?
jasonthorsness•7mo ago
Looks like Tamago targets multiple VM runtimes https://github.com/usbarmory/tamago?tab=readme-ov-file
veggieroll•7mo ago
How do you handle temp file space, timezone data, and other things that a minimal image provide?
kfreds•7mo ago
Temp file space: Use RAM, or talk to host storage over Virtio.

Timezone data etc: You would have to fetch that over the network, or from a metadata API such as the one Firecracker provides to VM guests.

fpoling•7mo ago
Services rarely need timezone done. So if one is OK with supporting only UTC, Go runtime works fine without any timezene data.

We use a minimal image to run in on AWS Nitro VM and it contains only kernel, init.d, the Go application file and TLS certificate roots with the root filesystem mounted over tmpfs.

Note that Nitro VM uses a custom kernel provided by AWS so the new proposal is not relevant for us. But if we could run Go directly in that VM, it will surely makes things faster and saves like 10% memory overhead. And it will also avoid OOM killer and few other bad unwanted interactions between Go runtime and Linux kernel memory management.

champtar•7mo ago
For timezones data go already has https://pkg.go.dev/time/tzdata
kfreds•7mo ago
> This proposal seems to be taking that approach to the extreme - not even a kernel.

To be fair, there is a kernel - the Go runtime. But since there is no privilege separation it classifies as a unikernel. Performance gains should be expected compared to a system where you have to copy data to/from guest VM kernel space to guest VM user space.

> I wonder if it could run on cloud VMs?

Yes. TamaGo currently runs in KVM guests with the following VMMs: Cloud Hypervisor, Firecracker microvm, QEMU microvm.

> How tiny could the image become?

Roughly the same size as your current Go binary. TamaGo doesn't add much.

ignoramous•7mo ago
> To be fair, there is a kernel - the Go runtime.

I like Anil Madhavapeddy's definition for such setups. A compiler that just refuses to stop:

  MirageOS is a system written in pure OCaml where not only do common network protocols and file systems and high-level things like web servers and web stacks can all be expressed in OCaml but the compiler just refuses to stop ... compiler, instead of stopping and generating a binary that you then run inside Linux or Windows, will continue to specialize the application that it is compiling and ... emit a full operating system that can just boot by itself.
https://signalsandthreads.com/what-is-an-operating-system / https://archive.vn/yLfkq
eyberg•7mo ago
Cloud vms are a main target for unikernels, however, as Russ mentions in one of the linked issues there actually is quite a lot of other code you need to include in your system depending on what you are deploying to.

For instance systems with arm64 might need UEFI or if you enable SEV now you need additional support for that which is why I'd agree with Russ's stance on this.

Every time someone asks us to provide support for a new cloud instance type (like a graviton 4 or azure's arm) we have to go in and sometimes provide a ton of new code to get it working.

kfreds•7mo ago
I assume you're referring to this[1]. I don't think it's necessary to bring all of that into the Go runtime itself, or ask the Go team to maintain it. It would be part of your application, and similar to a board support package.

TamaGo already supports UEFI on x86, and that too would be part of the BSP for your application, not something that would need to be upstreamed to Go proper. Same for AMD SEV SNP.

As for you (nanovms) supporting new instance types, wouldn't it be nice to do that work in Go? :)

Edit: I wonder how big the performance impact would be if you used TamaGo's virtio-net support instead of calling from Go into nanos.

advanderveer•7mo ago
I would be interested in this if it enabled deterministic simulation testing for the Go programming languages. There have been some efforts in this area but with little success.
rcarmo•7mo ago
I use TinyGo, and it does that job well. Not sure if it’s necessary to mainline it.
lcarsip•7mo ago
TinyGo targets an entirely different class of systems and is not something that can be upstream being a different compiler, see https://github.com/usbarmory/tamago/wiki/Frequently-Asked-Qu...

In New York City, congestion pricing leads to marked drop in pollution

https://e360.yale.edu/digest/new-york-congestion-pricing-pollution
193•Brajeshwar•1h ago•130 comments

Size of Life

https://neal.fun/size-of-life/
14•eatonphil•29m ago•2 comments

Map of all the buildings in the world

https://gizmodo.com/literally-a-map-showing-all-the-buildings-in-the-world-2000694696
110•dr_dshiv•5d ago•40 comments

Writing an Outlook Add-in in Rust

https://tritium.legal/blog/outlook
11•piker•1h ago•1 comments

Revisiting "Let's Build a Compiler"

https://eli.thegreenplace.net/2025/revisiting-lets-build-a-compiler/
191•cui•10h ago•31 comments

Launch HN: InspectMind (YC W24) – AI agent for reviewing construction drawings

5•aakashprasad91•27m ago•4 comments

Rust in the kernel is no longer experimental

https://lwn.net/Articles/1049831/
811•rascul•13h ago•576 comments

PeerTube is recognized as a digital public good by Digital Public Goods Alliance

https://www.digitalpublicgoods.net/r/peertube
627•fsflover•23h ago•130 comments

Volcanic eruptions set off a chain of events that brought Black Death to Europe

https://www.cam.ac.uk/stories/volcanoes-black-death
12•gmays•4d ago•2 comments

Amazon EC2 M9g Instances

https://aws.amazon.com/ec2/instance-types/m9g/
122•AlexClickHouse•4d ago•47 comments

Cloth Simulation

https://cloth.mikail-khan.com/
123•adamch•1w ago•24 comments

Putting email in its place with Emacs and Mu4e

https://eamonnsullivan.co.uk/posts-output/email-setup/2025-12-3-putting-email-in-its-place/
92•eamonnsullivan•6d ago•31 comments

When a video codec wins an Emmy

https://blog.mozilla.org/en/mozilla/av1-video-codec-wins-emmy/
238•todsacerdoti•4d ago•54 comments

Bruno Simon – 3D Portfolio

https://bruno-simon.com/
696•razzmataks•1d ago•164 comments

Mistral releases Devstral2 and Mistral Vibe CLI

https://mistral.ai/news/devstral-2-vibe-cli
694•pember•1d ago•319 comments

If you're going to vibe code, why not do it in C?

https://stephenramsay.net/posts/vibe-coding.html
581•sramsay•23h ago•540 comments

Django: what’s new in 6.0

https://adamj.eu/tech/2025/12/03/django-whats-new-6.0/
346•rbanffy•19h ago•116 comments

Show HN: Gemini Pro 3 hallucinates the HN front page 10 years from now

https://dosaygo-studio.github.io/hn-front-page-2035/news
3163•keepamovin•1d ago•902 comments

Running Linux on a RiscPC – why is it so hard?

https://thejpster.org.uk/blog/blog-2025-12-02/
36•zdw•1w ago•10 comments

Pebble Index 01 – External memory for your brain

https://repebble.com/blog/meet-pebble-index-01-external-memory-for-your-brain
557•freshrap6•1d ago•534 comments

Italy's longest-serving barista reflects on six decades behind the counter

https://www.reuters.com/lifestyle/culture-current/anna-possi-six-decades-behind-counter-italys-ba...
266•NaOH•5d ago•151 comments

The New Kindle Scribes Are Great, but Not Great Enough

https://www.wired.com/review/kindle-scribe-colorsoft-2025/
24•thm•1h ago•32 comments

10 Years of Let's Encrypt

https://letsencrypt.org/2025/12/09/10-years
758•SGran•21h ago•315 comments

Donating the Model Context Protocol and establishing the Agentic AI Foundation

https://www.anthropic.com/news/donating-the-model-context-protocol-and-establishing-of-the-agenti...
273•meetpateltech•23h ago•123 comments

So you want to speak at software conferences?

https://dylanbeattie.net/2025/12/08/so-you-want-to-speak-at-software-conferences.html
219•speckx•21h ago•113 comments

A supersonic engine core makes the perfect power turbine

https://boomsupersonic.com/flyby/ai-needs-more-power-than-the-grid-can-deliver-supersonic-tech-ca...
155•simonebrunozzi•1d ago•246 comments

Writing our own cheat engine (2021)

https://lonami.dev/blog/woce-1/
109•hu3•5d ago•24 comments

Passing the Torch: James Gross on the Next Chapter of Micromobility Industries

https://micromobility.io/news/how-charging-is-reshaping-the-business-of-shared-scooters-and-e-bikes
19•prabinjoel•6d ago•2 comments

The stack circuitry of the Intel 8087 floating point chip, reverse-engineered

https://www.righto.com/2025/12/8087-stack-circuitry.html
130•elpocko•22h ago•56 comments

Kaiju – General purpose 3D/2D game engine in Go and Vulkan with built in editor

https://github.com/KaijuEngine/kaiju
213•discomrobertul8•1d ago•98 comments