Urgent.News

What's breaking now, across thousands of outlets.

Tech

Hacking the Go compiler to efficiently map IPv4 to IPv6

The Go programming language's netip.Addr type provides an Unmap() method that extracts IPv4 addresses from IPv4-mapped IPv6 addresses. However, Go maintainers have rejected adding a Map() or To6() method to reverse the process, as they believe users should use netip.AddrFrom16(ip.As16()) instead. This pattern is currently eight times slower than a native method.

The article explores three methods to optimize this sequence: adding the reverse mapping to the standard library, implementing it as an external helper, and using the unsafe package. The standard library solution costs 0.88 ns per operation, the helper approach takes 7.14 ns, and the unsafe solution matches the performance of the first one.

The article then delves into the assembly code generated by the compiler for each solution and discusses the challenges of implementing the optimization in the Go compiler.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at vincent.bernat.ch →

More in Tech

Publishing 20 files at once with no GitHub token

I needed to update 20+ files in a GitHub repo. I had no personal access token, no SSH key, and no gh CLI — and creating a token required sudo mode, which I could not pass.

  • Reporter updated 20 files in GitHub repository without token
  • Web UI allowed 20 files to be uploaded in single commit
  • Recommended uploading changed files for efficiency

Three tiny CSV fixtures that catch different importer mistakes

A well-formed CSV can still carry the wrong meaning for your importer. Here are three fictional inputs, with explicit expectations, that you can copy into a test suite without uploading any customer…

  • Repeating ID in CSV input causes importer bug
  • Tolerant importer silently overwrites records
  • Explicitly stating business decision in test suite essential

Recaller

This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend What I Built I built Recaller — an ultra-minimalist, sophisticated dual-tone black and white web application designed…

  • Recaller is an ultra-minimalist web app for deep focus and memory
  • Combines Pomodoro clock, 3D flashcards, and quizzes into one interface
  • Built for Alex, a student struggling with fragmented study tools

More from Sunday 4 October →