lmac - Release notes v0.9.0

Version v0.9.0 — released 2026-09-06
Previous release: v0.8.0

HIGHLIGHTS

v0.9.0 brings many performance optimizations. By removing duplicate organization names, the embeded dataset was minimized. When exploring ways to optimize func Find the storage model changed from a slice to a single string const. Minimizing memory allocations usually helps performance a lot. In that area 0 allocations was reached for both Find and Lookup. The API surface did increase slightly by introducing a new type Assignment, but the readability and usability for callers is worth it.

CHANGES

BENCHMARKS

benchmarkv0.8.0v0.9.0change
Find ns/op9383841400206.7x
Find B/op124240
Find allocs/op15530
Lookup ns/op969.3203.14.8x
Lookup B/op2160
Lookup allocs/op180
dataset size2497999 B2223111 B-11%
binary size (cmd/lmac)4404492 B3940293 B-10.5%
full build time~2.6s~2.2s-15%

UPGRADE

  $ go install sogvin.com/lmac/cmd/lmac@latest

DOCUMENTATION

func All() iter.Seq[Assignment]

All returns every MA-L, MA-M and MA-S assignment in the database.

func Find(substr string) iter.Seq[Assignment]

Find the assignments whose organization contains substr.

for a := range lmac.Find("Dell") {
    fmt.Println(a, a.Organization())
}

func Lookup(mac string) string

Lookup returns the registered organization for the given MAC address.

Allowed formats:

00:00:00:00:00:aa
00-00-00-00-00-aa
0000000000aa

Partial MAC addresses are also allowed:

00:01:22
00-01-22
000122

The values are case-insensitive.

type Assignment uint64

An Assignment is a MAC address block the IEEE has assigned to an organization, packed into a uint64. Bit layout:

0x001bc504b0025f13
0x001bc504b00      prefix
             2     registry tag
              5f13 org index

Masking off tag and org index leaves the 48 bit MAC prefix in bits 63..16, the form parse returns and AppendText formats. Keeping the prefix in the high bits makes assignments sort by prefix, which containing relies on.

func (a Assignment) AppendText(dst []byte) ([]byte, error)

AppendText appends the assignment prefix to dst as upper case hex digits separated by : every two digits, six digits for MA-L, seven for MA-M and nine for MA-S. The odd registries end in a half byte, eg. 00:55:8D:0. The error is always nil, it implements encoding.TextAppender.

func (a Assignment) Organization() string

Organization returns the organization of the assignment, empty string if the org index is unknown.

func (a Assignment) Registry() string

Registry returns the assignment's registry, "ma-l", "ma-m" or "ma-s".

func (a Assignment) String() string

String returns the assignment prefix as upper case hex digits separated by : every two digits, eg. 00:1B:C5:04:B. The number of digits depends on the registry, see AppendText.

AUTHOR

Gregory Vinčić