Issue 17897: Optimize unpickle prefetching (original) (raw)

Created on 2013-05-03 18:16 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pickle_peek.patch serhiy.storchaka,2013-05-03 18:16 review
pickle_peek_2.patch serhiy.storchaka,2013-11-30 18:09 review
Messages (11)
msg188317 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-05-03 18:16
When C implementation of the unpickle reads a data, it also prefetches some data using peek() (if available) and then concatenates read and peeked chunks in the one input buffer. This causes an additional copying when a large data is read. The proposed patch gets rid of concatenating by moving a peeking before reading.
msg188335 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2013-05-03 23:50
Do you have benchmark results to show the code with the patch is faster?
msg188343 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-05-04 08:08
No, I have no any interesting results. ;) If an effect exists, it should reveal itself only in rare cases and be very small. This patch may be considered rather as a tiny refactoring (it decreases a number of code lines).
msg193212 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-07-17 08:48
See for test case.
msg193214 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-07-17 08:52
I'd prefer to see efforts go towards finishing the PEP 3154 implementation...
msg193215 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-07-17 09:04
This patch is orthogonal to the PEP 3154 framing. The affecting of is only an unexpected side effect.
msg204832 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-30 18:09
Patch is synchronized with tip (it was desynchronized since 23459df0753e).
msg204833 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-30 18:32
Microbenchmark: $ ./python -c "import pickle; d = b'x' * 10**6; f = open('test.pickle3', 'wb'); pickle.dump(d, f, 3); f.close()" $ ./python -m timeit -s "from pickle import load" "with open('test.pickle3', 'rb') as f: load(f)" Unpatched: 100 loops, best of 3: 7.27 msec per loop Patched: 100 loops, best of 3: 4.87 msec per loop
msg204843 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2013-11-30 20:53
Looks good to me! Feel free to commit.
msg204846 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-30 21:16
New changeset d565310e7ae3 by Serhiy Storchaka in branch 'default': Issue #17897: Optimized unpickle prefetching. http://hg.python.org/cpython/rev/d565310e7ae3
msg204847 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-30 21:17
Thank you Alexandre.
History
Date User Action Args
2022-04-11 14:57:45 admin set github: 62097
2013-11-30 21:17:26 serhiy.storchaka set assignee: serhiy.storchaka
2013-11-30 21:17:14 serhiy.storchaka set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2013-11-30 21:16:12 python-dev set nosy: + python-devmessages: +
2013-11-30 20:53:27 alexandre.vassalotti set messages: +
2013-11-30 18:32:18 serhiy.storchaka set messages: +
2013-11-30 18:09:28 serhiy.storchaka set files: + pickle_peek_2.patchmessages: +
2013-07-17 09:04:49 serhiy.storchaka set messages: +
2013-07-17 08:52:29 pitrou set nosy: - pitrou
2013-07-17 08:52:20 pitrou set messages: +
2013-07-17 08:48:28 serhiy.storchaka set messages: +
2013-05-04 08:08:09 serhiy.storchaka set messages: +
2013-05-04 00:03:24 vstinner set nosy: + vstinner
2013-05-03 23:50:37 alexandre.vassalotti set messages: +
2013-05-03 18:16:39 serhiy.storchaka create