hashmap

A Golang lock-free thread-safe HashMap optimized for fastest read access.

APACHE-2.0 License

Stars
1.7K
Committers
13

Bot releases are visible (Hide)

hashmap - v1.0.8 hashing improvements Latest Release

Published by cornelk about 2 years ago

  • improved hashing and avoid dedicated MapString type
hashmap - v1.0.7 hashing improvements

Published by cornelk about 2 years ago

  • optimized hashing by separating string support into separate type
  • removed all external dependencies
hashmap - v1.0.6 hashing improvements

Published by cornelk about 2 years ago

  • optimize hashing by Inlining hashing as anonymous functions
  • reduce allocations for write operations
hashmap - v1.0.5 hashing improvements and fix

Published by cornelk about 2 years ago

  • fix hashing on ARM CPUs
  • optimize hashing by using specialized xxhash implementations
  • reduce variable allocations in get functions
  • removed obsolete 0 length checks

It is noticeable faster than the current version of HaxMap is able to handle collisions of valid 0 hash values:

BenchmarkReadHashMapUint-8                	 1314156	       955.6 ns/op
BenchmarkReadHaxMapUint-8                 	  872134	      1316 ns/op (can not handle hash 0 collisions)
// works for this library, fails for HaxMap
func TestHash0Collision(t *testing.T) {
	m := New[string, int]()
	staticHasher := func(key string) uintptr {
		return 0
	}
	m.SetHasher(staticHasher)
	m.Set("1", 1)
	m.Set("2", 2)
	_, ok := m.Get("1")
	if !ok {
		t.Error("1 not found")
	}
	_, ok = m.Get("2")
	if !ok {
		t.Error("2 not found")
	}
}
hashmap - v1.0.4 concurrent insert bug fixes

Published by cornelk about 2 years ago

  • fixed insert during map grow
  • fixed add not working properly during concurrent delete
  • add SetHasher function to allow setting of a custom hasher
  • benchmarks have been moved to a subdirectory to remove imports for external libraries from main module
hashmap - v1.0.3 Generics version improvements

Published by cornelk about 2 years ago

  • CAS has been removed as it is not working
  • Iter function signature has been changed to Range
  • all comparable key types are supported now
hashmap - v1.0.2 Generics version

Published by cornelk about 2 years ago

  • fix hash collision handling
  • switch library to use generics
  • minor API changes
  • CAS is currently not supported
  • removed []byte key support
hashmap -

Published by cornelk about 5 years ago

  • Fixed delete action when using hashed key
  • Fixed race condition in list