Motivated by the discussion about the boot times I dag in the trunk of lost
sources and found a piece of code I created long a go for serializing /
deserializing (does this word exist?) arbitrary lisp data.
The code is not complete, for it was a proof of concept -- the real code is
somewhere in CVS and I cannot find it right now --, but I managed to plug it
in with little effort and the results are interesting.
SI:SERIALIZE is a function that takes an object and produces an (ARRAY
(UNSIGNED-BYTE *) (*)) with enough information to reconstruct an EQUAL
object. SI:DESERIALIZE does the opposite. The whole code takes very little
in C and apart for some big switches to reconstruct the entries in the lisp
objects it is pretty simple. Everything is now available in CVS.
The funny thing is that this is an order of magnitude faster than using the
reader already for simple objects. The code I use to test it is listed below
and the outcome is pretty good.
It will be worth investigating whether the serializing code remains as
efficient when all other data types are introduced.
;; Using the reader
real time : 0.669 secs
run time : 0.660 secs
gc count : 3 times
consed : 2684081 bytes
;; Using SERIALIZE
real time : 0.092 secs
run time : 0.091 secs
gc count : 2 times
consed : 3183760 bytes
'(1 . #1=(3 "3" . ("445" . #1#))))
(let ((*print-circle* t))
(defun foo1 (y)
(dotimes (i 100000)
(defun foo2 (y)
(dotimes (i 100000)
(time (foo1 #.+r1+))
(time (foo2 #.+r2+))
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
From: Matthew Mondor <mm_lists@pu...> - 2010-06-06 16:44:11
On Sun, 6 Jun 2010 16:32:46 +0200
Juan Jose Garcia-Ripoll <juanjose.garciaripoll@...> wrote:
> SI:SERIALIZE is a function that takes an object and produces an (ARRAY
> (UNSIGNED-BYTE *) (*)) with enough information to reconstruct an EQUAL
> object. SI:DESERIALIZE does the opposite. The whole code takes very little
> in C and apart for some big switches to reconstruct the entries in the lisp
> objects it is pretty simple. Everything is now available in CVS.
So if I understand, the compiler could use SI:SERIALIZE, and loader
SI:DESERIALIZE to load back the static const objects? In any case, the
performance is impressive. I do think that serialize and deserialize
are correct terminology, or at least proper programming jargon :)