[ZODB-Dev] Re: ZODB Benchmarks
Jim Fulton
jim at zope.com
Thu Dec 6 15:03:47 EST 2007
On Nov 6, 2007, at 3:17 PM, Roché Compaan wrote:
> On Tue, 2007-11-06 at 14:51 -0500, Jim Fulton wrote:
>> On Nov 6, 2007, at 2:40 PM, Sidnei da Silva wrote:
>>
>>>> Despite this change there are still a huge amount
>>>> of unexplained calls to the 'persistent_id' method of the
>>>> ObjectWriter
>>>> in serialize.py.
>>>
>>> Why 'unexplained'? 'persistent_id' is called from the Pickler
>>> instance
>>> being used in ObjectWriter._dump(). It is called for each and every
>>> single object reachable from the main object, due to the way Pickler
>>> works (I believe). Maybe persistent_id can be analysed and optimized
>>> for the most common cases?
>>
>> Yup.
>>
>> Note that there is a undocumented feature in cPickle that I added
>> years ago to deal with this issue but never got around to pursuing.
>> Maybe someone else would be able to spend the time to try it out and
>> report back.
>>
>> If you set inst_persistent_id, rather than persistent_id, on a
>> pickler, then the hook will only be called for instances. This
>> should eliminate that vast majority of the calls.
>
> So is this as simple as modifying the following code in the
> ObjectWriter:
>
> self._p.persistent_id = self.persistent_id
>
> to:
>
> self._p.inst_persistent_id = self.persistent_id
Yes.
> I'll give it a go as part of my benchmarks that I'm running and report
> back.
I hope you weren't waiting for my answer.
Jim
--
Jim Fulton
Zope Corporation
More information about the ZODB-Dev
mailing list