Skip to content

Conversation

@mm-ipinfo
Copy link
Contributor

@mm-ipinfo mm-ipinfo commented Jan 22, 2026

Make use of the new v2 API (#47) to cache decoded and serialized MMDB values.

Testing on a 1GB MMDB file:

┌────────┬───────┬───────┬─────────┐
│ Format │  Old  │  New  │ Speedup │
├────────┼───────┼───────┼─────────┤
│ CSV    │ 1m31s │ 27.2s │ 3.3x    │
├────────┼───────┼───────┼─────────┤
│ TSV    │ 2m18s │ 26.1s │ 5.3x    │
├────────┼───────┼───────┼─────────┤
│ JSON   │ 2m51s │ 15.1s │ 11.3x   │
└────────┴───────┴───────┴─────────┘

@max-ipinfo this is the raw Claude output which I might cleanup a bit, but it seems to work as expected.

@mm-ipinfo mm-ipinfo changed the base branch from master to max/maxminddb-golang-v2 January 22, 2026 20:38
Base automatically changed from max/maxminddb-golang-v2 to master January 23, 2026 14:41
@mm-ipinfo mm-ipinfo requested a review from max-ipinfo January 23, 2026 15:27
@mm-ipinfo
Copy link
Contributor Author

mm-ipinfo commented Jan 23, 2026

@max-ipinfo extracted CSV/TSV/JSON exports to dedicated exporter_* files:

type exporter interface {
	WriteRecord(result maxminddb.Result) error
	Flush() error
}

Also simplified a little the JSON logic. It's a bit slower (15s -> 24s) but still much faster than the current version.

@max-ipinfo
Copy link
Contributor

It's a bit slower (15s -> 24s) but still much faster than the current version.

Just curious. Why would moving it to an exporter interface make it that slower? Are the function calls via the interface that much worse?

Copy link
Contributor Author

mm-ipinfo commented Jan 23, 2026

Oh sorry, I was unclear 😄 It's not the interface but the JSON simplification that slows down things a bit. Instead of manually writing {"range": …, and then write the cached JSON (minus the first char) we just cache everything but with range set to __RANGE__ and we replace it with the actual value at write time. It's a bit slower due to the bytes.Replace call but it's also much less hacky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants