akka/akka — pull request #1852 by bantonsson (2013-11-27 14:26:58+00:00)
Title: =act #3720 Optimze actor creation speed and actor size

The things slowing down Akka 2.2 are repeated lookups of a path in the configuration, and multiple calls to reflective construcors. Both have been addressed with a caching configuration, and caching the producer in the props, and not the constructor to the producer.

Size of an actor, exluding the Props which is a different story, has grown with 8 bytes in the actor cell, and 8 bytes in the actor path.

Size of props has grown since we keep a reference to the reflective constructor, and exploded in size since the list of arguments where stored in a Vector(), which weighs in at 200 bytes (even if you only have 1 argument). The Vector has been changed to a List, and caching the right thing (see above) has also helped.

Measurements for actor size and creation speed
----------------------------------------------

All measurements with new actors as children of a driver actor. Measurements with the label new use a new Props for every actor, and the ones labeled same reuse the props for actor construction.

Creation times are measured from when we send the start message to the driver until it has called context.actorOf for all children and replied with a done message.

Actor size is measured after sending an alive message to every actor that they reply to.

```
Akka Actor creation comaprison (average of 100000 actors and multiple measurements)
-----------------------------------------------------------------------------------
Creation time in micro seconds with Props[EmptyActor] new:
2.1.4 : 6.7
2.2.3 : 20.2
2.2.3 + fixes: 10.9
Size in bytes with Props[EmptyActor] new:
2.1.4 : 472
2.2.3 : 536
2.2.3 + fixes: 488

Creation time in micro seconds with Props[EmptyActor] same:
2.1.4 : 6.3
2.2.3 : 16.2
2.2.3 + fixes: 7.9
Size in bytes with Props[EmptyActor] same:
2.1.4 : 416
2.2.3 : 432
2.2.3 + fixes: 432

Creation time in micro seconds with Props(new EmptyActor) new:
2.1.4 : 6.3
2.2.3 : 21.1
2.2.3 + fixes: 9.1
Size in bytes with Props(new EmptyActor) new:
2.1.4 : 472
2.2.3 : 760
2.2.3 + fixes: 560

Creation time in micro seconds with Props(new EmptyActor) same:
2.1.4 : 6.2
2.2.3 : 16.1
2.2.3 + fixes: 7.8
Size in bytes with Props(new EmptyActor) same:
2.1.4 : 416
2.2.3 : 432
2.2.3 + fixes: 432

Creation time in micro seconds with Props(classOf[EmptyArgsActor], ...) new:
2.1.4 : NA
2.2.3 : 19.9
2.2.3 + fixes: 15.6
Size in bytes with Props(classOf[EmptyArgsActor], ...) new:
2.1.4 : NA
2.2.3 : 792
2.2.3 + fixes: 664

Creation time in micro seconds with Props(classOf[EmptyArgsActor], ...) same:
2.1.4 : NA
2.2.3 : 15.7
2.2.3 + fixes: 7.7
Size in bytes with Props(classOf[EmptyArgsActor], ...) same:
2.1.4 : NA
2.2.3 : 440
2.2.3 + fixes: 440

Creation time in micro seconds with Props(new EmptyArgsActor(...)) new:
2.1.4 : 6.7
2.2.3 : 20.9
2.2.3 + fixes: 8.8
Size in bytes with Props(new EmptyArgsActor(...)) new:
2.1.4 : 480
2.2.3 : 768
2.2.3 + fixes: 568

Creation time in micro seconds with Props(new EmptyArgsActor(...)) same:
2.1.4 : 6.5
2.2.3 : 16.0
2.2.3 + fixes: 7.9
Size in bytes with Props(new EmptyArgsActor(...)) same:
2.1.4 : 424
2.2.3 : 440
2.2.3 + fixes: 440
```