Rev 4718: Switching away from pre-fetching the string_hash function drops hash() time in http://bazaar.launchpad.net/~jameinel/bzr/2.1-memory-consumption
John Arbash Meinel
john at arbash-meinel.com
Wed Sep 30 18:38:11 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/2.1-memory-consumption
------------------------------------------------------------
revno: 4718
revision-id: john at arbash-meinel.com-20090930173804-3y2bossnkug69k8m
parent: john at arbash-meinel.com-20090930173110-p03w37bugnjkbtao
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-memory-consumption
timestamp: Wed 2009-09-30 12:38:04 -0500
message:
Switching away from pre-fetching the string_hash function drops hash() time
from 13.9ms down to 14.5ms. 4% loss.
Something we may want to revisit, but if this is an opportunity to make a generic
StaticTuple type, rather than a Keys specific one, it is probably worthwile.
-------------- next part --------------
=== modified file 'bzrlib/_keys_type_c.c'
--- a/bzrlib/_keys_type_c.c 2009-09-30 17:02:00 +0000
+++ b/bzrlib/_keys_type_c.c 2009-09-30 17:38:04 +0000
@@ -248,12 +248,8 @@
#endif
x = 0x345678L;
p = self->key_bits;
- string_hash = PyString_Type.tp_hash;
while (--len >= 0) {
- y = (*p)->ob_shash;
- if (y == -1) { /* not computed yet */
- y = string_hash((PyObject *)(*p));
- }
+ y = Py_TYPE(*p)->tp_hash(*p);
if (y == -1) /* failure */
return -1;
x = (x ^ y) * mult;
More information about the bazaar-commits
mailing list