Kaydet (Commit) daf57f25 authored tarafından Raymond Hettinger's avatar Raymond Hettinger

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.
üst b1e6e57a
...@@ -542,7 +542,7 @@ class TestBasic(unittest.TestCase): ...@@ -542,7 +542,7 @@ class TestBasic(unittest.TestCase):
@support.cpython_only @support.cpython_only
def test_sizeof(self): def test_sizeof(self):
BLOCKLEN = 62 BLOCKLEN = 64
basesize = support.calcobjsize('2P4nlP') basesize = support.calcobjsize('2P4nlP')
blocksize = struct.calcsize('2P%dP' % BLOCKLEN) blocksize = struct.calcsize('2P%dP' % BLOCKLEN)
self.assertEqual(object.__sizeof__(deque()), basesize) self.assertEqual(object.__sizeof__(deque()), basesize)
......
...@@ -10,14 +10,11 @@ ...@@ -10,14 +10,11 @@
/* The block length may be set to any number over 1. Larger numbers /* The block length may be set to any number over 1. Larger numbers
* reduce the number of calls to the memory allocator, give faster * reduce the number of calls to the memory allocator, give faster
* indexing and rotation, and reduce the link::data overhead ratio. * indexing and rotation, and reduce the link::data overhead ratio.
* * Making the block length a power of two speeds-up the modulo
* Ideally, the block length will be set to two less than some * calculation in deque_item().
* multiple of the cache-line length (so that the full block
* including the leftlink and rightlink will fit neatly into
* cache lines).
*/ */
#define BLOCKLEN 62 #define BLOCKLEN 64
#define CENTER ((BLOCKLEN - 1) / 2) #define CENTER ((BLOCKLEN - 1) / 2)
/* A `dequeobject` is composed of a doubly-linked list of `block` nodes. /* A `dequeobject` is composed of a doubly-linked list of `block` nodes.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment