Our great sponsors
-
faststringmap
A fast (5x) string keyed read-only map for Go - particularly good for keys using a small set of nearby runes.
-
countwords
Discontinued Playing with counting word frequencies (and performance) in various languages.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
We were using Go map[string]int to validate the strings and obtain the index in the list. However the map lookups were consuming a lot of compute time. I wondered whether this could be significantly reduced. I looked around and didn't immediately find anything. So I came up with https://github.com/sensiblecodeio/faststringmap which gave us a 5x performance improvement on map lookups and a 25% reduction in overall CSV processing time.
This article shows that map lookups can be optimized by using the (unintuitive) pattern: