diff options
author | Raymond Hettinger <python@rcn.com> | 2015-02-27 07:21:29 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-02-27 07:21:29 (GMT) |
commit | daf57f25e5690cfaa4636ccf0d113908dc0783a4 (patch) | |
tree | 9dea7077c9a9350ef293ac5cf0ad40daf9cb4ce2 /Modules | |
parent | b1e6e57a170d39733937176431767983f8e82ab7 (diff) | |
download | cpython-daf57f25e5690cfaa4636ccf0d113908dc0783a4.zip cpython-daf57f25e5690cfaa4636ccf0d113908dc0783a4.tar.gz cpython-daf57f25e5690cfaa4636ccf0d113908dc0783a4.tar.bz2 |
Bump the blocksize up from 62 to 64 to speed up the modulo calculation.
Remove the old comment suggesting that it was desireable to have
blocksize+2 as a multiple of the cache line length. That would
have made sense only if the block structure start point was always
aligned to a cache line boundary. However, the memory allocations
are 16 byte aligned, so we don't really have control over whether
the struct spills across cache line boundaries.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_collectionsmodule.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index d3b0287..0df35d9 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -10,14 +10,11 @@ /* The block length may be set to any number over 1. Larger numbers * reduce the number of calls to the memory allocator, give faster * indexing and rotation, and reduce the link::data overhead ratio. - * - * Ideally, the block length will be set to two less than some - * multiple of the cache-line length (so that the full block - * including the leftlink and rightlink will fit neatly into - * cache lines). + * Making the block length a power of two speeds-up the modulo + * calculation in deque_item(). */ -#define BLOCKLEN 62 +#define BLOCKLEN 64 #define CENTER ((BLOCKLEN - 1) / 2) /* A `dequeobject` is composed of a doubly-linked list of `block` nodes. |