| Store | Cart

Re: Cannot write serialization code without access to Perl_hv_backreferences_p

From: Steffen Mueller <smue...@cpan.org>
Mon, 22 Dec 2014 17:56:08 +0100
On 12/22/2014 03:51 PM, demerphq wrote:
> Now, if Sereal were a two pass serializer like DDS we could do one> traversal over the data structure, and use the bookkeeping for that to> control the second pass. But that would obviously be inefficient as well.

Technically, Sereal can have sort of a second pass, specifically in the 
face of weakrefs: If encountered had weakrefs which are not otherwise 
referenced in the structure, we erase the "weaken" tags from the output 
at the end of the normal serialization pass (by replacing the tag with a 
padding entry instead of memmove'ing what might be a large amount of data).

But as for introducing a full O(inputsize) or rather O(outputsize) pass, 
see below:

> So all together this is a performance issue. If a serialization tool> wants to handle weakrefs properly and efficiently it needs something> like hv_backreferences_p(). Having said that I have a patch that> introduces a new API call in yves/backrefs. I think probably> hv_backreferences_p() can be made internal again, and the use case> replaced by the proposed new sv_get_backrefs().

I'd phrase it as "it's a performance issue in terms of having a wide 
range of features that users should only pay for if they use them". So 
the cost of supporting weakrefs is O(n_weakrefs_used) instead of 
O(input) or O(output).

--Steffen

Recent Messages in this Thread
Father Chrysostomos Dec 21, 2014 08:49 pm
demerphq Dec 21, 2014 09:23 pm
demerphq Dec 21, 2014 09:24 pm
demerphq Dec 21, 2014 09:53 pm
bulk88 Dec 21, 2014 10:25 pm
demerphq Dec 21, 2014 10:31 pm
bulk88 Dec 21, 2014 11:31 pm
demerphq Dec 22, 2014 02:22 am
Aristotle Pagaltzis Dec 22, 2014 12:51 pm
demerphq Dec 22, 2014 02:51 pm
Steffen Mueller Dec 22, 2014 04:56 pm
demerphq Dec 22, 2014 05:06 pm
Aristotle Pagaltzis Dec 23, 2014 06:44 am
demerphq Dec 23, 2014 01:41 pm
bulk88 Dec 21, 2014 10:11 pm
demerphq Dec 21, 2014 10:15 pm
Steffen Mueller Dec 21, 2014 07:23 pm
Messages in this thread