74
RMod 1 Mariano Martinez Peck [email protected] http://marianopeck.wordpress.com/ Monday, August 22, 2011

Clustered Serialization with Fuel

Embed Size (px)

DESCRIPTION

Presentation of the research paper entitled "Clustered Serialization with Fuel" in ESUG International Workshop on Smalltalk Technologies (IWST 2011), Edinburgh, Scotland.

Citation preview

Page 1: Clustered Serialization with Fuel

RMod

1

Mariano Martinez [email protected]

http://marianopeck.wordpress.com/

Monday, August 22, 2011

Page 2: Clustered Serialization with Fuel

THANKS a lot!!!

2

SummerTalk 2011

Student: Martin DiasMentor: Mariano Martínez Peck

Monday, August 22, 2011

Page 3: Clustered Serialization with Fuel

Object references

3

Monday, August 22, 2011

Page 4: Clustered Serialization with Fuel

Object graph

4

Monday, August 22, 2011

Page 5: Clustered Serialization with Fuel

5

An objet graph serializer.

Monday, August 22, 2011

Page 6: Clustered Serialization with Fuel

Serialize

6

Input: an object graph

Output: stream of bytes

Monday, August 22, 2011

Page 7: Clustered Serialization with Fuel

Materialize(deserialize)

7

Output: an object graph

Input: stream of bytes

Monday, August 22, 2011

Page 8: Clustered Serialization with Fuel

Once serialized...

8

Database File Memory Socket

Stream of bytes

Monday, August 22, 2011

Page 9: Clustered Serialization with Fuel

Fuel’s main goals

Provide fast object serialization and materialization.

Be flexible and easy to customize.

Have a good OO design, well tested and benchmarked.

No need of special support from the VM.

Be a general purpose serializer.

Allow tools to be built on top of Fuel.9

Monday, August 22, 2011

Page 10: Clustered Serialization with Fuel

Key features Fast serialization and materialization.

Class reshape support.

Serialization of any kind of object.

Cycles support.

Global objects references.

Buffered writing.

Support for some “hook methods”.10

Monday, August 22, 2011

Page 11: Clustered Serialization with Fuel

Key Characteristics

Pickle format.

Objects grouped in clusters.

Analysis phase before writing.

Stack over recursion.

Two phases for writing instances and references.

Iterative graph recreation.11

Monday, August 22, 2011

Page 12: Clustered Serialization with Fuel

Pickle format

12

Invest more time in serialization so that objects can then be materialized much faster.

Monday, August 22, 2011

Page 13: Clustered Serialization with Fuel

Grouping objects in clusters

13

“Similar” objects (they share writing/loading information) are grouped together in clusters. The most common case, yet not the

only one, takes place when a class is a cluster for its instances.

Monday, August 22, 2011

Page 14: Clustered Serialization with Fuel

14

Monday, August 22, 2011

Page 15: Clustered Serialization with Fuel

14

Each jar has a specific type of element

Monday, August 22, 2011

Page 16: Clustered Serialization with Fuel

14

Each jar has a specific type of element

Jars are in order

Monday, August 22, 2011

Page 17: Clustered Serialization with Fuel

14

Label: - What’s inside? - How much?Each jar has

a specific type of element

Jars are in order

Monday, August 22, 2011

Page 18: Clustered Serialization with Fuel

14

Label: - What’s inside? - How much?

Different sizes and different amounts of elements

Each jar has a specific type of element

Jars are in order

Monday, August 22, 2011

Page 19: Clustered Serialization with Fuel

14

Label: - What’s inside? - How much?

Different sizes and different amounts of elements

Each jar has a specific type of element

Jars are in order

s/jar/cluster

Monday, August 22, 2011

Page 20: Clustered Serialization with Fuel

14

Label: - What’s inside? - How much?

Different sizes and different amounts of elements

Each jar has a specific type of element

Jars are in order

s/jar/cluster

Monday, August 22, 2011

Page 21: Clustered Serialization with Fuel

14

Label: - What’s inside? - How much?

Different sizes and different amounts of elements

Jars are in order

s/jar/cluster

Each cluster has a specific type of object

Monday, August 22, 2011

Page 22: Clustered Serialization with Fuel

14

Label: - What’s inside? - How much?

Different sizes and different amounts of elements

Jars are in order

s/jar/cluster

Each cluster has a specific type of object

Monday, August 22, 2011

Page 23: Clustered Serialization with Fuel

14

Label: - What’s inside? - How much?

Different sizes and different amounts of elements

s/jar/cluster

Each cluster has a specific type of object

Clusters are in order

Monday, August 22, 2011

Page 24: Clustered Serialization with Fuel

14

Label: - What’s inside? - How much?

Different sizes and different amounts of elements

s/jar/cluster

Each cluster has a specific type of object

Clusters are in order

Monday, August 22, 2011

Page 25: Clustered Serialization with Fuel

14

Different sizes and different amounts of elements

s/jar/cluster

Each cluster has a specific type of object

Clusters are in order

Label: - Cluster ID - Amount of

objects

Monday, August 22, 2011

Page 26: Clustered Serialization with Fuel

14

Different sizes and different amounts of elements

s/jar/cluster

Each cluster has a specific type of object

Clusters are in order

Label: - Cluster ID - Amount of

objects

Monday, August 22, 2011

Page 27: Clustered Serialization with Fuel

14

s/jar/cluster

Each cluster has a specific type of object

Clusters are in order

Label: - Cluster ID - Amount of

objects

Different sizes and different amounts of

objects

Monday, August 22, 2011

Page 28: Clustered Serialization with Fuel

Pickle format basic

15

Stream

Monday, August 22, 2011

Page 29: Clustered Serialization with Fuel

Pickle format basic

15

Stream

Monday, August 22, 2011

Page 30: Clustered Serialization with Fuel

Pickle format basic

15

Stream

Monday, August 22, 2011

Page 31: Clustered Serialization with Fuel

Pickle format basic

15

Stream

Monday, August 22, 2011

Page 32: Clustered Serialization with Fuel

16

Why the pickle format is so fast in materialization?

Standard serializers Fuel pickle format

Monday, August 22, 2011

Page 33: Clustered Serialization with Fuel

16

Why the pickle format is so fast in materialization?

Standard serializers Fuel pickle format

Recursive

materialization Iterative

materialization

Monday, August 22, 2011

Page 34: Clustered Serialization with Fuel

Pickle advantages

Batch/Bulk/Iterative materialization.

Efficient since types are stored and fetch only once.

Fast because at materialization we know the size of everything.

The generated stream is smaller.

More next....

17

Monday, August 22, 2011

Page 35: Clustered Serialization with Fuel

There is no silver bullet...

18

Fast serialization

(without pickle)

Slow serialization(with pickle)

Monday, August 22, 2011

Page 36: Clustered Serialization with Fuel

Fuel requires

Traversing the object graph.

Mapping each object to a specific cluster.

19

This is done in a phase before serialization called “Analysis”.

Monday, August 22, 2011

Page 37: Clustered Serialization with Fuel

Analysis phase

20

cluster1 aPointcluster2 x y

......

... ...

key (a cluster) value (a set)

1) Traverse (#fuelAccept: aVisitor)2) Fill dictionary(#fuelSerializer)

Monday, August 22, 2011

Page 38: Clustered Serialization with Fuel

Serialization

21

key (a cluster) value (a set)

serialize: anObject on: aStreammaterializeFrom: aStream

IDCluster

A cluster defines how its objects are serialized and materialized.

cluster1 aPointcluster2 x y

......

... ...

Monday, August 22, 2011

Page 39: Clustered Serialization with Fuel

Stack over recursion

22

To traverse the object graph, Fuel uses a custom stack implementation rather than a recursion.

Monday, August 22, 2011

Page 40: Clustered Serialization with Fuel

Basic stepsSerialization

1. Analyze.2. Serialize header.3. Serialize instances.4. Serialize references.5. Serialize root.

Materialization1. Materialize header.2. Materialize instances.3. Materialize references.4. Materialize root.

23

Monday, August 22, 2011

Page 41: Clustered Serialization with Fuel

Fuel for software(so far)

Moose export utility.

SandstoneDB persistence.

Pier kernel persistence.

Newspeak language.

Marea (my own research project!).

24

Monday, August 22, 2011

Page 42: Clustered Serialization with Fuel

Future Work

Continue efforts on performance optimization.

Create a tool for loading class and trait packages.

Support user-defined Singletons.

Fast statistics/brief info extraction of a stored graph.

Partial loading of a stored graph.25

Monday, August 22, 2011

Page 43: Clustered Serialization with Fuel

Future work 2

Enable to deploy serialization and materialization behavior independently.

Support object replacement for serialization and materialization.

Allow cycle detections to be disabled.

Partial loading.

26

Monday, August 22, 2011

Page 44: Clustered Serialization with Fuel

Serialization of primitive objects

27

Memory based stream

Monday, August 22, 2011

Page 45: Clustered Serialization with Fuel

Serialization of primitive objects

27

Memory based stream

StOMPSRPFuel

Monday, August 22, 2011

Page 46: Clustered Serialization with Fuel

Serialization of primitive objects

27

Memory based stream File based stream

StOMPSRPFuel

Monday, August 22, 2011

Page 47: Clustered Serialization with Fuel

Serialization of primitive objects

27

Memory based stream File based stream

StOMPSRPFuel

FuelSRPStOMP

Monday, August 22, 2011

Page 48: Clustered Serialization with Fuel

28

Materialization of primitive objects

Monday, August 22, 2011

Page 49: Clustered Serialization with Fuel

28

Fuel

ImageSegment

StOMP

Materialization of primitive objects

Monday, August 22, 2011

Page 50: Clustered Serialization with Fuel

Non primitive objects

29

Monday, August 22, 2011

Page 51: Clustered Serialization with Fuel

Non primitive objects

29

StOMPSRPFuel

Monday, August 22, 2011

Page 52: Clustered Serialization with Fuel

Non primitive objects

29

StOMPSRPFuel

Monday, August 22, 2011

Page 53: Clustered Serialization with Fuel

Non primitive objects

29

FuelImageSegmentStOMP

StOMPSRPFuel

Monday, August 22, 2011

Page 55: Clustered Serialization with Fuel

Excellent performance without special support from VM and good OO design.

Conclusionfor us

31

Monday, August 22, 2011

Page 56: Clustered Serialization with Fuel

Fuel is a vehicle. It is infrastructure. You can build cool stuff on top of it.

Conclusionfor YOU

32

Monday, August 22, 2011

Page 57: Clustered Serialization with Fuel

Thanks!

RMod

Mariano Martinez [email protected]

http://marianopeck.wordpress.com/

Monday, August 22, 2011

Page 58: Clustered Serialization with Fuel

34

Concrete example

Monday, August 22, 2011

Page 59: Clustered Serialization with Fuel

35

Monday, August 22, 2011

Page 60: Clustered Serialization with Fuel

Analysis phase

3620

cluster1 aRectanglecluster2 anOrigin aCornercluster3 10

key (a cluster) value (a IdentitySet)

20 30 40

Analysis phase

Monday, August 22, 2011

Page 61: Clustered Serialization with Fuel

Serializationinstances

phase

cluster1 aRectangle

cluster2 anOrigin aCorner

cluster3 10 20 30 40

Monday, August 22, 2011

Page 62: Clustered Serialization with Fuel

Serializationinstances

phase

cluster1 aRectangle

cluster2 anOrigin aCorner

cluster3 10 20 30 40

Monday, August 22, 2011

Page 63: Clustered Serialization with Fuel

Serializationinstances

phase

cluster1 aRectangle

cluster2 anOrigin aCorner

cluster3 10 20 30 40

1 Rectangle 2 origi corne 1

instance variable names

instance count

instance variable count

class name

cluster ID

Monday, August 22, 2011

Page 64: Clustered Serialization with Fuel

Serializationinstances

phase

cluster1 aRectangle

cluster2 anOrigin aCorner

cluster3 10 20 30 40

1 Rectangle 2 origi corne 1

instance variable names

instance count

instance variable count

class name

cluster ID

Monday, August 22, 2011

Page 65: Clustered Serialization with Fuel

Serializationinstances

phase

cluster1 aRectangle

cluster2 anOrigin aCorner

cluster3 10 20 30 40

1 Rectangle 2 origi corne 1

1 Point 2 x y 2

instance variable names

instance count

instance variable count

class name

cluster ID

Monday, August 22, 2011

Page 66: Clustered Serialization with Fuel

Serializationinstances

phase

cluster1 aRectangle

cluster2 anOrigin aCorner

cluster3 10 20 30 40

1 Rectangle 2 origi corne 1

1 Point 2 x y 2

54 10 20 30 40

instance variable names

instance count

instance variable count

class name

cluster ID

Monday, August 22, 2011

Page 67: Clustered Serialization with Fuel

cluster1 aRectangle

cluster2 anOrigin aCorner

cluster3 10 20 30 40

aRectangle anOrigiaCorner20 40 10 30instancesIndex

(IdentityDictionary)

1 5 7 3 2 4 6

54 10 20 30 40

2

Serializationreferences

phase

instances

references

Monday, August 22, 2011

Page 68: Clustered Serialization with Fuel

cluster1 aRectangle

cluster2 anOrigin aCorner

cluster3 10 20 30 40

aRectangle anOrigiaCorner20 40 10 30instancesIndex

(IdentityDictionary)

1 5 7 3 2 4 6

54 10 20 30 40

2

2

3

Serializationreferences

phase

instances

references

Monday, August 22, 2011

Page 69: Clustered Serialization with Fuel

cluster1 aRectangle

cluster2 anOrigin aCorner

cluster3 10 20 30 40

aRectangle anOrigiaCorner20 40 10 30instancesIndex

(IdentityDictionary)

1 5 7 3 2 4 6

54 10 20 30 40

2

2

3

4 5 6 7

Serializationreferences

phase

instances

references

Monday, August 22, 2011

Page 70: Clustered Serialization with Fuel

cluster1 aRectangle

cluster2 anOrigin aCorner

cluster3 10 20 30 40

aRectangle anOrigiaCorner20 40 10 30instancesIndex

(IdentityDictionary)

1 5 7 3 2 4 6

54 10 20 30 40

2

2

3

4 5 6 7

Serializationreferences

phase

instances

references

Monday, August 22, 2011

Page 71: Clustered Serialization with Fuel

2

2

3

4 5 6 7

final stream

1 Rectangle 2 origi corne 1

1 Point 2 x y 2

54 10 20 30 40

{instances

{references

Monday, August 22, 2011

Page 72: Clustered Serialization with Fuel

2

2

3

4 5 6 7

final stream

1 Rectangle 2 origi corne 1

1 Point 2 x y 2

54 10 20 30 40

{instances

{references

1{trailer

7 3{header clustersCount

objectsCounts

rootMonday, August 22, 2011

Page 73: Clustered Serialization with Fuel

2

Materialization

instances {2 3

4 5 6 7

1 Rectangle 2 origin corner 1

1 Point 2 x y 2

5 4 1 2 3 4

{references

1{trailer

7 3{header clustersCount

objectsCounts

root

Monday, August 22, 2011

Page 74: Clustered Serialization with Fuel

41

Monday, August 22, 2011