lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> On 22 Mar 2018, at 21.17, Petri Häkkinen <petrih3@gmail.com> wrote:
> 
> 
> On 22 Mar 2018, at 20.29, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> 
>>> Any feedback, critique, questions, comments etc. are welcome!
>> 
>> I am particularly puzzled by this result:
>> 
>>> Benchmark        Unmodified    Patched   Patched
>>>                Tables        Tables    Arrays
>>> Scatter-read     0.200s        0.208s    0.170s
>> 
>> If I undestood correctly the code, the Patched Arrays implementation
>> uses exactly the same code as Unmodified Tables for reads. Can you
>> explain this difference?
> 
> Without diving deeper into it, I would guess that in this case some elements of the table go into the hash part (the data is sparse because of random access pattern in the benchmark). Look ups from the hash map is slower than reading from an array which is always stored linearly.
> 
Clarification: what I mean is that the table has been generated by writing values to random indices in the previous benchmark. I don’t know the details fully how Lua builds the array and hash parts of the table in this case. I’m only assuming some elements would fall out of the array part. Does this explanation make any sense?

Petri