Author serhiy.storchaka
Recipients inada.naoki, rhettinger, serhiy.storchaka, vstinner, xiang.zhang
Date 2016-10-28.20:03:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1477685025.02.0.178216551343.issue28199@psf.upfronthosting.co.za>
In-reply-to
Content
Yes, the difference is pretty small. The largest difference I got is 7% in following microbenchmark:

$ ./python -m perf timeit -s 'x = list(range(1000))' -- 'dict.fromkeys(x)'
Unpatched:          Median +- std dev: 80.6 us +- 0.5 us
dictresize3.patch:  Median +- std dev: 80.9 us +- 2.8 us
dictresize4.patch:  Median +- std dev: 75.4 us +- 2.1 us

I suppose this is due to using memcpy. In other microbenchmarks the difference usually is 1-2%.

Xiang, your microbenchmark don't work for this patch because dict(d) make only one resizing.

> Cons of Serhiy's patch is it's two pass. If entries are larger than L2 cache,
fetch from L3 cache may be larger.

Agree. But on other hand, dictresize3.patch needs to fit in L2 cache all indices table and prefetch two entries arrays: old and new. dictresize4.patch in every loop works with smaller memory: two entries arrays in the first loop and an indices table and new entries arrays in the second loop.
History
Date User Action Args
2016-10-28 20:03:45serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, vstinner, inada.naoki, xiang.zhang
2016-10-28 20:03:45serhiy.storchakasetmessageid: <1477685025.02.0.178216551343.issue28199@psf.upfronthosting.co.za>
2016-10-28 20:03:45serhiy.storchakalinkissue28199 messages
2016-10-28 20:03:44serhiy.storchakacreate