Advice: I think there are many ways to make go-swiss better
ahfuzhang opened this issue · 2 comments
Give some advice about this lib:
- ctrl byte is everything, so no need to set kv when delete.
those lines are not need:
Line 141 in c0064a0
Line 190 in c0064a0
Line 246 in c0064a0
2.when init ctrl bytes, we can use simd or unsafe code, not one by one.
see:
Line 69 in c0064a0
3.If the group's ctrl bytes are all empty, Iter()
can be faster.
see:
Line 220 in c0064a0
we can add:
if metaMatchEmpty(&m.ctrl[g])==0xffff{continue;}
4.Let ctrl bytes slice address is align to 32, so we can use _mm_load_128() to replace __mm_loadu_128():
see:
Line 64 in c0064a0
alloc more 32 bytes, and use unsafe code to choose a start address of 128bit alignment.
- If group count is power of 2, not need to use if to check range.
see:Line 96 in c0064a0
g = g & 0xffff // if group count is 65536
6.try groupSize=32, and use avx2 to match 32 bytes each time.
- XXHash might be better than golang map hasher.
I think I understand the purpose of those lines on advice 1:
when the content of the object is the same but the pointer is different, replace it with the current object. And when delete, we should set to null for gc.
However, for ultimate performance optimization, it is recommended to provide a value type version. Then remove the operations that are valid for reference types but not valid for value types.