Bifrost: Setting Smalltalk Loose

93
Letting Smalltalk Loose Jorge Ressia www.scg.unibe.ch

description

Presentation at ESUG 2011

Transcript of Bifrost: Setting Smalltalk Loose

Page 1: Bifrost: Setting Smalltalk Loose

Letting Smalltalk Loose

Jorge Ressia

www.scg.unibe.ch

Page 2: Bifrost: Setting Smalltalk Loose

Computer revolution has not

happened yet

Page 3: Bifrost: Setting Smalltalk Loose

Computer revolution has not

happened yetAlan Kay

Keynote OOPSLA 1997

Page 4: Bifrost: Setting Smalltalk Loose

improve previous ways of thinking

Page 5: Bifrost: Setting Smalltalk Loose

create new ways of thinking

Page 6: Bifrost: Setting Smalltalk Loose

Object-orientedProgramming

Page 7: Bifrost: Setting Smalltalk Loose

Dynamic

Page 8: Bifrost: Setting Smalltalk Loose

We still go back to the source code

Page 9: Bifrost: Setting Smalltalk Loose

Debugging

Page 10: Bifrost: Setting Smalltalk Loose

}

{

}

{

}

{}

{

}

{

Page 11: Bifrost: Setting Smalltalk Loose

}

{

}

{

}

{}

{

}

{

Page 12: Bifrost: Setting Smalltalk Loose

}

{

}

{

}

{}

{

}

{

Page 13: Bifrost: Setting Smalltalk Loose

}

{

}

{

}

{}

{

}

{

Page 14: Bifrost: Setting Smalltalk Loose

}

{

}

{

}

{}

{

}

{

Page 15: Bifrost: Setting Smalltalk Loose

}

{

}

{

}

{}

{

}

{

Page 16: Bifrost: Setting Smalltalk Loose

}

{

}

{

}

{}

{

}

{

Page 17: Bifrost: Setting Smalltalk Loose

Profiling

Page 18: Bifrost: Setting Smalltalk Loose

Profile

}

{

}

{

}

{}

{

}

{

Domain-Specific Profiling 3

CPU time profiling

Mondrian [9] is an open and agile visualization engine. Mondrian describes avisualization using a graph of (possibly nested) nodes and edges. In June 2010a serious performance issue was raised1. Tracking down the cause of the poorperformance was not trivial. We first used a standard sample-based profiler.

Execution sampling approximates the time spent in an application’s methodsby periodically stopping a program and recording the current set of methodsunder executions. Such a profiling technique is relatively accurate since it haslittle impact on the overall execution. This sampling technique is used by almostall mainstream profilers, such as JProfiler, YourKit, xprof [10], and hprof.

MessageTally, the standard sampling-based profiler in Pharo Smalltalk2, tex-tually describes the execution in terms of CPU consumption and invocation foreach method of Mondrian:

54.8% {11501ms} MOCanvas>>drawOn:54.8% {11501ms} MORoot(MONode)>>displayOn:30.9% {6485ms} MONode>>displayOn:

| 18.1% {3799ms} MOEdge>>displayOn:...

| 8.4% {1763ms} MOEdge>>displayOn:| | 8.0% {1679ms} MOStraightLineShape>>display:on:| | 2.6% {546ms} FormCanvas>>line:to:width:color:...

23.4% {4911ms} MOEdge>>displayOn:...

We can observe that the virtual machine spent about 54% of its time inthe method displayOn: defined in the class MORoot. A root is the unique non-nested node that contains all the nodes of the edges of the visualization. Thisgeneral profiling information says that rendering nodes and edges consumes agreat share of the CPU time, but it does not help in pinpointing which nodesand edges are responsible for the time spent. Not all graphical elements equallyconsume resources.

Traditional execution sampling profilers center their result on the frames ofthe execution stack and completely ignore the identity of the object that receivedthe method call and its arguments. As a consequence, it is hard to track downwhich objects cause the slowdown. For the example above, the traditional profilersays that we spent 30.9% in MONode>>displayOn: without saying which nodeswere actually refreshed too often.

Coverage

PetitParser is a parsing framework combining ideas from scannerless parsing,parser combinators, parsing expression grammars and packrat parsers to modelgrammars and parsers as objects that can be reconfigured dynamically [11].

1 http://forum.world.st/Mondrian-is-slow-next-step-tc2257050.html#a2261116

2 http://www.pharo-project.org/

Page 19: Bifrost: Setting Smalltalk Loose

Domain

Profile

}

{

}

{

}

{}

{

}

{

Domain-Specific Profiling 3

CPU time profiling

Mondrian [9] is an open and agile visualization engine. Mondrian describes avisualization using a graph of (possibly nested) nodes and edges. In June 2010a serious performance issue was raised1. Tracking down the cause of the poorperformance was not trivial. We first used a standard sample-based profiler.

Execution sampling approximates the time spent in an application’s methodsby periodically stopping a program and recording the current set of methodsunder executions. Such a profiling technique is relatively accurate since it haslittle impact on the overall execution. This sampling technique is used by almostall mainstream profilers, such as JProfiler, YourKit, xprof [10], and hprof.

MessageTally, the standard sampling-based profiler in Pharo Smalltalk2, tex-tually describes the execution in terms of CPU consumption and invocation foreach method of Mondrian:

54.8% {11501ms} MOCanvas>>drawOn:54.8% {11501ms} MORoot(MONode)>>displayOn:30.9% {6485ms} MONode>>displayOn:

| 18.1% {3799ms} MOEdge>>displayOn:...

| 8.4% {1763ms} MOEdge>>displayOn:| | 8.0% {1679ms} MOStraightLineShape>>display:on:| | 2.6% {546ms} FormCanvas>>line:to:width:color:...

23.4% {4911ms} MOEdge>>displayOn:...

We can observe that the virtual machine spent about 54% of its time inthe method displayOn: defined in the class MORoot. A root is the unique non-nested node that contains all the nodes of the edges of the visualization. Thisgeneral profiling information says that rendering nodes and edges consumes agreat share of the CPU time, but it does not help in pinpointing which nodesand edges are responsible for the time spent. Not all graphical elements equallyconsume resources.

Traditional execution sampling profilers center their result on the frames ofthe execution stack and completely ignore the identity of the object that receivedthe method call and its arguments. As a consequence, it is hard to track downwhich objects cause the slowdown. For the example above, the traditional profilersays that we spent 30.9% in MONode>>displayOn: without saying which nodeswere actually refreshed too often.

Coverage

PetitParser is a parsing framework combining ideas from scannerless parsing,parser combinators, parsing expression grammars and packrat parsers to modelgrammars and parsers as objects that can be reconfigured dynamically [11].

1 http://forum.world.st/Mondrian-is-slow-next-step-tc2257050.html#a2261116

2 http://www.pharo-project.org/

Page 20: Bifrost: Setting Smalltalk Loose

Mondrian

Page 21: Bifrost: Setting Smalltalk Loose
Page 22: Bifrost: Setting Smalltalk Loose

System ComplexityLanza and Ducasse 2003

Page 23: Bifrost: Setting Smalltalk Loose

Domain-Specific Profiling 3

CPU time profiling

Mondrian [9] is an open and agile visualization engine. Mondrian describes avisualization using a graph of (possibly nested) nodes and edges. In June 2010a serious performance issue was raised1. Tracking down the cause of the poorperformance was not trivial. We first used a standard sample-based profiler.

Execution sampling approximates the time spent in an application’s methodsby periodically stopping a program and recording the current set of methodsunder executions. Such a profiling technique is relatively accurate since it haslittle impact on the overall execution. This sampling technique is used by almostall mainstream profilers, such as JProfiler, YourKit, xprof [10], and hprof.

MessageTally, the standard sampling-based profiler in Pharo Smalltalk2, tex-tually describes the execution in terms of CPU consumption and invocation foreach method of Mondrian:

54.8% {11501ms} MOCanvas>>drawOn:54.8% {11501ms} MORoot(MONode)>>displayOn:30.9% {6485ms} MONode>>displayOn:

| 18.1% {3799ms} MOEdge>>displayOn:...

| 8.4% {1763ms} MOEdge>>displayOn:| | 8.0% {1679ms} MOStraightLineShape>>display:on:| | 2.6% {546ms} FormCanvas>>line:to:width:color:...

23.4% {4911ms} MOEdge>>displayOn:...

We can observe that the virtual machine spent about 54% of its time inthe method displayOn: defined in the class MORoot. A root is the unique non-nested node that contains all the nodes of the edges of the visualization. Thisgeneral profiling information says that rendering nodes and edges consumes agreat share of the CPU time, but it does not help in pinpointing which nodesand edges are responsible for the time spent. Not all graphical elements equallyconsume resources.

Traditional execution sampling profilers center their result on the frames ofthe execution stack and completely ignore the identity of the object that receivedthe method call and its arguments. As a consequence, it is hard to track downwhich objects cause the slowdown. For the example above, the traditional profilersays that we spent 30.9% in MONode>>displayOn: without saying which nodeswere actually refreshed too often.

Coverage

PetitParser is a parsing framework combining ideas from scannerless parsing,parser combinators, parsing expression grammars and packrat parsers to modelgrammars and parsers as objects that can be reconfigured dynamically [11].

1 http://forum.world.st/Mondrian-is-slow-next-step-tc2257050.html#a2261116

2 http://www.pharo-project.org/

Page 24: Bifrost: Setting Smalltalk Loose

Which is the relationship?Domain-Specific Profiling 3

CPU time profiling

Mondrian [9] is an open and agile visualization engine. Mondrian describes avisualization using a graph of (possibly nested) nodes and edges. In June 2010a serious performance issue was raised1. Tracking down the cause of the poorperformance was not trivial. We first used a standard sample-based profiler.

Execution sampling approximates the time spent in an application’s methodsby periodically stopping a program and recording the current set of methodsunder executions. Such a profiling technique is relatively accurate since it haslittle impact on the overall execution. This sampling technique is used by almostall mainstream profilers, such as JProfiler, YourKit, xprof [10], and hprof.

MessageTally, the standard sampling-based profiler in Pharo Smalltalk2, tex-tually describes the execution in terms of CPU consumption and invocation foreach method of Mondrian:

54.8% {11501ms} MOCanvas>>drawOn:54.8% {11501ms} MORoot(MONode)>>displayOn:30.9% {6485ms} MONode>>displayOn:

| 18.1% {3799ms} MOEdge>>displayOn:...

| 8.4% {1763ms} MOEdge>>displayOn:| | 8.0% {1679ms} MOStraightLineShape>>display:on:| | 2.6% {546ms} FormCanvas>>line:to:width:color:...

23.4% {4911ms} MOEdge>>displayOn:...

We can observe that the virtual machine spent about 54% of its time inthe method displayOn: defined in the class MORoot. A root is the unique non-nested node that contains all the nodes of the edges of the visualization. Thisgeneral profiling information says that rendering nodes and edges consumes agreat share of the CPU time, but it does not help in pinpointing which nodesand edges are responsible for the time spent. Not all graphical elements equallyconsume resources.

Traditional execution sampling profilers center their result on the frames ofthe execution stack and completely ignore the identity of the object that receivedthe method call and its arguments. As a consequence, it is hard to track downwhich objects cause the slowdown. For the example above, the traditional profilersays that we spent 30.9% in MONode>>displayOn: without saying which nodeswere actually refreshed too often.

Coverage

PetitParser is a parsing framework combining ideas from scannerless parsing,parser combinators, parsing expression grammars and packrat parsers to modelgrammars and parsers as objects that can be reconfigured dynamically [11].

1 http://forum.world.st/Mondrian-is-slow-next-step-tc2257050.html#a2261116

2 http://www.pharo-project.org/

?

Page 25: Bifrost: Setting Smalltalk Loose

What is the problem?

Page 26: Bifrost: Setting Smalltalk Loose

Fixed Object Model

Page 27: Bifrost: Setting Smalltalk Loose

Most of the time this is good

Page 28: Bifrost: Setting Smalltalk Loose

Restricts what we can do

Page 29: Bifrost: Setting Smalltalk Loose

Time

Page 30: Bifrost: Setting Smalltalk Loose

Time is a very useful concept

Page 31: Bifrost: Setting Smalltalk Loose

considering it absolute limit us

Page 32: Bifrost: Setting Smalltalk Loose

absolute object model limit us

Page 33: Bifrost: Setting Smalltalk Loose

objects that evolve

Page 34: Bifrost: Setting Smalltalk Loose

Why?

Page 35: Bifrost: Setting Smalltalk Loose

ExecutionReification

StructureEvolution

ProfilingDebugging

Page 36: Bifrost: Setting Smalltalk Loose

ExecutionReification

StructureEvolution

ProfilingDebugging

Page 37: Bifrost: Setting Smalltalk Loose

}

{

}

{

}

{}

{

}

{

Page 38: Bifrost: Setting Smalltalk Loose

}

{

}

{

}

{}

{

}

{

Page 39: Bifrost: Setting Smalltalk Loose

When is the next state written?

Page 40: Bifrost: Setting Smalltalk Loose

Stop when the next message is received

Page 41: Bifrost: Setting Smalltalk Loose

Close the gap

Page 42: Bifrost: Setting Smalltalk Loose

Object Debugger

Page 43: Bifrost: Setting Smalltalk Loose

ExecutionReification

StructureEvolution

Debugging Profiling

Page 44: Bifrost: Setting Smalltalk Loose

MetaSpy

Page 45: Bifrost: Setting Smalltalk Loose

MetaSpy

TOOLS 2011Bergel etal.

Page 46: Bifrost: Setting Smalltalk Loose

Mondrian Profiler

Page 47: Bifrost: Setting Smalltalk Loose
Page 48: Bifrost: Setting Smalltalk Loose

System ComplexityLanza, Ducasse 2003

Page 49: Bifrost: Setting Smalltalk Loose
Page 50: Bifrost: Setting Smalltalk Loose

Profiling

StructureEvolution

Debugging

ExecutionReification

Page 51: Bifrost: Setting Smalltalk Loose

What if we do not know what to evolve?

Page 52: Bifrost: Setting Smalltalk Loose
Page 53: Bifrost: Setting Smalltalk Loose

?

Page 54: Bifrost: Setting Smalltalk Loose

Prisma

Page 55: Bifrost: Setting Smalltalk Loose

Scarring

Page 56: Bifrost: Setting Smalltalk Loose
Page 57: Bifrost: Setting Smalltalk Loose
Page 58: Bifrost: Setting Smalltalk Loose
Page 59: Bifrost: Setting Smalltalk Loose
Page 60: Bifrost: Setting Smalltalk Loose

Scanning

Page 61: Bifrost: Setting Smalltalk Loose
Page 62: Bifrost: Setting Smalltalk Loose
Page 63: Bifrost: Setting Smalltalk Loose
Page 64: Bifrost: Setting Smalltalk Loose
Page 65: Bifrost: Setting Smalltalk Loose
Page 66: Bifrost: Setting Smalltalk Loose
Page 67: Bifrost: Setting Smalltalk Loose
Page 68: Bifrost: Setting Smalltalk Loose

Back in time Debugger

Page 69: Bifrost: Setting Smalltalk Loose

Back in time Debugger

Object Flow Debugger

Lienhard etal. ECOOP 2008

Page 70: Bifrost: Setting Smalltalk Loose

Instance variable history

Page 71: Bifrost: Setting Smalltalk Loose

:Person field-write@t2

field-write@t3

init@t1

'Doe'

person := Person new t1...name := 'Doe' t2...name := 'Smith' t3

'Smith'

nullpredecessor

predecessor

value

value

value

name

name

name

Page 72: Bifrost: Setting Smalltalk Loose

Profiling

ExecutionReification

Debugging

StructureEvolution

Page 73: Bifrost: Setting Smalltalk Loose

Talents

scg.unibe.ch/research/talents

Page 74: Bifrost: Setting Smalltalk Loose

Talents

scg.unibe.ch/research/talents

IWST 2011J. Ressia, T. Gîrba, O. Nierstrasz, F. Perin and

L. Renggli

Page 75: Bifrost: Setting Smalltalk Loose

Dynamically composable units of

reuse

Page 76: Bifrost: Setting Smalltalk Loose

moosetechnology.org

Page 77: Bifrost: Setting Smalltalk Loose

aFAMIXClass isTestClass

Keyinstance-ofmessage sendlookup

FAMIXEntity

FAMIXType

isTestClassFAMIXClass

aFAMIXClass

1

2

3

self inheritsFrom: 'TestCase'

MooseEntity

...

Page 78: Bifrost: Setting Smalltalk Loose

aFAMIXClass isTestClass

FAMIXClass

aFAMIXClass

1

2

4

aFAMIXClass inheritsFrom: 'TestCase'

aJeeClassTalent

Keyinstance-ofmessage sendlookupacquire

3aJeeClassTalent talent isTestClass

FAMIXEntity

FAMIXType

MooseEntity

...

Page 79: Bifrost: Setting Smalltalk Loose

•@ alias

•- exclusion

•, composition

Operators

Page 80: Bifrost: Setting Smalltalk Loose

Flattening

Page 81: Bifrost: Setting Smalltalk Loose

Scoping

Page 82: Bifrost: Setting Smalltalk Loose

Evolution friendly Object Model

Page 83: Bifrost: Setting Smalltalk Loose
Page 84: Bifrost: Setting Smalltalk Loose

Organize the Meta-level

Page 85: Bifrost: Setting Smalltalk Loose

ExplicitMeta-objects

Page 86: Bifrost: Setting Smalltalk Loose

Object

Meta-object

Class

Page 87: Bifrost: Setting Smalltalk Loose

Object

Meta-object

Class

Page 88: Bifrost: Setting Smalltalk Loose

Evolved Object

Meta-object

Class

Page 89: Bifrost: Setting Smalltalk Loose

Object>>haltAtNextMessage | aMetaObject | aMetaObject := BFBehavioralMetaObject new. aMetaObject when: (BFMessageReceiveEvent new) do: [ self metaObject unbindFrom: self.

TransparentBreakpoint signal ]. aMetaObject bindTo: self

Page 90: Bifrost: Setting Smalltalk Loose

We let Smalltalk loose

Page 91: Bifrost: Setting Smalltalk Loose

Object Debugger Prisma

Subjectopia MetaSpy

Talents Chameleon

Page 93: Bifrost: Setting Smalltalk Loose

scg.unibe.ch/research/bifrost