Improve MAKE-LOAD-FORM-SAVING-SLOTS on STRUCTURE-OBJECT.
commit4bf626e745d5d2e34630ec4dd67b7c17bd9b8f28
authorDouglas Katzman <dougk@google.com>
Sun, 2 Nov 2014 18:46:46 +0000 (2 13:46 -0500)
committerDouglas Katzman <dougk@google.com>
Sun, 2 Nov 2014 19:26:20 +0000 (2 14:26 -0500)
treee1a329f38101a5ad88165190bed03a2a3234cf86
parent70d821d6497e164f7ec455be94ca17987984e7a1
Improve MAKE-LOAD-FORM-SAVING-SLOTS on STRUCTURE-OBJECT.

- use simpler code than SLOT-SETTER-LAMBDA-FORM.
- use a trick based on :SB-JUST-DUMP-IT-NORMALLY if it can be
  shown to have identical behavior to a user's MAKE-LOAD-FORM.
  This occurs when and only when the user's code is
  MAKE-LOAD-FORM-SAVING-SLOTS for all slots.

A consequence of the second point is that the first only matters
when a :SLOT-NAMES argument excludes some slots. Creating large trees
of constant data, such as needed by cl-protobufs, by setting a single
variable to a structure computed through macros expanding to
(DEFVAR *A-BIG-SCHEMA* #S(SCHEMA ....)) now compiles in a fraction of
the time it used to. [The downloadable version of cl-protobufs
uses STANDARD-OBJECT, making this patch inapplicable though]

A test comprised of one DEFVAR initialized to '#.(COMPUTE-THINGS)
where COMPUTE-THINGS returned a list of 10,000 instances of a
structure of 6 slots was sped up thusly:
 Test              |  Fasl size |  Compile   |  Load
 ------------------|------------|------------|--------
 baseline          |  17,504 KB |  83 sec    | .26 sec
 simplified sexprs |  16,311 KB |  45 sec    | .17 sec
 FOP-based dumping |   1,858 KB |   0.26 sec | .02 sec
src/code/target-defstruct.lisp
src/compiler/main.lisp
src/pcl/env.lisp
tests/dump.impure-cload.lisp