hollow icon indicating copy to clipboard operation
hollow copied to clipboard

ByteArrayOrdinalMap growth appears to be too aggressive

Open DanielThomas opened this issue 6 years ago • 2 comments

I think ByteArrayOrdinalMap grows too aggressively:

screen shot 2018-12-05 at 1 11 16 pm

Wouldn't 134217728 be the table size with a load factor of 1.0? (I haven't taken the time to look really closely at the implementation, but I'm assuming pointersAndOrdinals is just the key array).

DanielThomas avatar Dec 05 '18 21:12 DanielThomas

One explanation for the discrepancy of sizeBeforeGrow and pointersAndOrdinals.length() is those fields are not marked as volatile and not all methods of the class are synchronized. I don't see how the discrepancy could occur otherwise given the following code is the only place where the fields are updated (in growKeyArray):

       /// 70% load factor
       sizeBeforeGrow = (int) (((float) newKeys.length()) * 0.7);
       pointersAndOrdinals = newKeys;

PaulSandoz avatar Jan 17 '19 20:01 PaulSandoz

See also #378

PaulSandoz avatar Feb 25 '19 19:02 PaulSandoz