concurrent-map key interface{} support
Enhancement: If concurrent-map is supposed to behave the same as the plain map, then the allowed key types should be the same and the type map[interface{}]interface{} should be supported.
Hi @ross-oreto
You have a point there. There is obviously a trade-off between allowing arbitrary key types to the map's performance, and perhaps a usability issue as well (it may be annoying to type convert). Would be interesting to benchmark such an implementation. Would be cool if you could try to make this change on your own dev branch and benchmark it. If you end up doing so please update. Otherwise I'll leave this hanging for a while and close it.
Baseline: BenchmarkItems-4 300 4808352 ns/op 1949388 B/op 735 allocs/op BenchmarkMarshalJson-4 100 13807963 ns/op 3298981 B/op 30961 allocs/op BenchmarkStrconv-4 30000000 55.6 ns/op 7 B/op 1 allocs/op BenchmarkSingleInsertAbsent-4 2000000 779 ns/op 183 B/op 2 allocs/op BenchmarkSingleInsertPresent-4 10000000 133 ns/op 16 B/op 1 allocs/op BenchmarkMultiInsertDifferent_1_Shard-4 1000000 2348 ns/op 327 B/op 11 allocs/op BenchmarkMultiInsertDifferent_16_Shard-4 1000000 2424 ns/op 327 B/op 11 allocs/op BenchmarkMultiInsertDifferent_32_Shard-4 1000000 2263 ns/op 327 B/op 11 allocs/op BenchmarkMultiInsertDifferent_256_Shard-4 500000 3006 ns/op 340 B/op 12 allocs/op BenchmarkMultiInsertSame-4 1000000 1447 ns/op 160 B/op 10 allocs/op BenchmarkMultiGetSame-4 3000000 475 ns/op 0 B/op 0 allocs/op BenchmarkMultiGetSetDifferent_1_Shard-4 500000 3034 ns/op 334 B/op 12 allocs/op BenchmarkMultiGetSetDifferent_16_Shard-4 500000 3140 ns/op 334 B/op 12 allocs/op BenchmarkMultiGetSetDifferent_32_Shard-4 500000 3077 ns/op 335 B/op 12 allocs/op BenchmarkMultiGetSetDifferent_256_Shard-4 500000 2984 ns/op 340 B/op 12 allocs/op BenchmarkMultiGetSetBlock_1_Shard-4 1000000 2229 ns/op 163 B/op 12 allocs/op BenchmarkMultiGetSetBlock_16_Shard-4 1000000 2165 ns/op 163 B/op 12 allocs/op BenchmarkMultiGetSetBlock_32_Shard-4 1000000 2057 ns/op 163 B/op 12 allocs/op BenchmarkMultiGetSetBlock_256_Shard-4 1000000 1956 ns/op 163 B/op 12 allocs/op BenchmarkKeys-4 1000 1867250 ns/op 329373 B/op 34 allocs/op
with interface{} key: BenchmarkItems-4 300 5340246 ns/op 1950417 B/op 803 allocs/op BenchmarkMarshalJson-4 300 5256855 ns/op 1950606 B/op 806 allocs/op BenchmarkStrconv-4 30000000 55.5 ns/op 7 B/op 1 allocs/op BenchmarkSingleInsertAbsent-4 1000000 1087 ns/op 207 B/op 4 allocs/op BenchmarkSingleInsertPresent-4 5000000 295 ns/op 35 B/op 3 allocs/op BenchmarkMultiInsertDifferent_1_Shard-4 500000 4415 ns/op 561 B/op 31 allocs/op BenchmarkMultiInsertDifferent_16_Shard-4 500000 4513 ns/op 561 B/op 31 allocs/op BenchmarkMultiInsertDifferent_32_Shard-4 500000 4475 ns/op 562 B/op 31 allocs/op BenchmarkMultiInsertDifferent_256_Shard-4 200000 6789 ns/op 771 B/op 52 allocs/op BenchmarkMultiInsertSame-4 500000 3058 ns/op 352 B/op 30 allocs/op BenchmarkMultiGetSame-4 500000 2323 ns/op 192 B/op 20 allocs/op BenchmarkMultiGetSetDifferent_1_Shard-4 300000 7133 ns/op 770 B/op 52 allocs/op BenchmarkMultiGetSetDifferent_16_Shard-4 200000 6709 ns/op 733 B/op 52 allocs/op BenchmarkMultiGetSetDifferent_32_Shard-4 200000 6634 ns/op 733 B/op 52 allocs/op BenchmarkMultiGetSetDifferent_256_Shard-4 300000 6790 ns/op 780 B/op 52 allocs/op BenchmarkMultiGetSetBlock_1_Shard-4 300000 5743 ns/op 521 B/op 52 allocs/op BenchmarkMultiGetSetBlock_16_Shard-4 300000 5622 ns/op 521 B/op 52 allocs/op BenchmarkMultiGetSetBlock_32_Shard-4 300000 5567 ns/op 521 B/op 52 allocs/op BenchmarkMultiGetSetBlock_256_Shard-4 300000 5493 ns/op 521 B/op 52 allocs/op BenchmarkKeys-4 1000 2007344 ns/op 329577 B/op 54 allocs/op
Would it be more feasible to implement this now with support for generics?
@ross-oreto
Hi, how did you handle with Marshal Json ? BenchmarkMarshalJson-4 300 5256855 ns/op 1950606 B/op 806 allocs/op
I'm facing with Marshal Json error with interface{} type key. Got any idea or suggestion ?
@ross-oreto Hi, how did you handle with Marshal Json ?
BenchmarkMarshalJson-4 300 5256855 ns/op 1950606 B/op 806 allocs/opI'm facing with Marshal Json error withinterface{}type key. Got any idea or suggestion ?
I made changes locally necessary to use the interface key and ran those benchmarks, however I did not push my changes.