Unanticipated Partial
Behavioral Reflection


    David Röthlisberger
    Marcus Denker
    Eric Tanter




© Marcus Denker
Roadmap


> Example
> Behavioral Reflection
     — Smalltalk / Metaclasstalk
     — Unanticipated Reflection
     — Partial ...
Running Example




>    Typical web application (e.g. Wiki)

>    Shows performance problem under high load

>    Goals:
...
Towards a Solution



>    Analyse the problem
     — Install profiler
     — Analyze
     — Retract profiler


>    Solve t...
Reflection



>    Reflection: computation about computation
     — base level / meta level
     — causally connected


>   ...
Unanticipated Reflection


>    “Unanticipated Use” means:
     — No need to know in advance (and plan for) reflection
     ...
Reflection in Smalltalk


>    Structural Reflection
     — Classes / Methods are objects
     — Can be changed at runtime

...
MetaclassTalk


>    Extends the Smalltalk metaclass model

>    Metaclass defines
     — message lookup
     — access to i...
Partial Reflection


> Hooksets: collection of operation occurrences
> Links
     — Bind hooksets to metaobjects
     — Defi...
Geppetto


>    Partial Behavioral Reflection pioneered in Java
     — Code transformation at load time
     — Not unantici...
Solving the Problem



>    Operation:
     — Method Execution (around)


>    Hookset:
     — All execution operations in...
Solving the Problem: Hookset + Link


>   Hookset

      allExecs := Hookset new.
      allExecs inPackage: ’Wiki’; operat...
Solving the Problem: Protocol

>    Protocol
      profile callDescriptor:
         (CallDescriptor
            selector: ...
Solving the Problem: Caching



>    Operation:
     — Method Execution (around)


>    Hookset:
     — The one slow metho...
Caching II

    >    Hookset:
          toughWorks := Hookset new.
          toughWorks inClass: Worker; inMethod: #toughW...
Geppetto



>    Operations:
     — MethodEval (like MethodWrappers)
     — MsgSend, InstVarAccess, TempAccess



>    Con...
Benchmarks I

>    Slowdown for reification of message send


      System                 Slowdown

      Geppetto        ...
Benchmarks II


>     Geppetto Vs. Metaclasstalk

                   Metaclasstalk   Geppetto   Speedup
                  ...
Future Work



>    Pluggable backends
     — Bytecode
     — AST based transformation
     — VM Support


>    Use for ty...
Conclusion




> Example for the need of Partial Behavioral Reflection
> Overview of Geppetto
> Solution of the Example
> B...
Conclusion




> Example for the need of Partial Behavioral Reflection
> Overview of Geppetto
> Solution of the Example
> B...
Upcoming SlideShare
Loading in …5
×

Unanticipated Partial Behavioral Reflection

651 views
634 views

Published on

"Unanticipated Partial Behavioral Reflection"

Dynamic, unanticipated adaptation of running systems is of interest in a variety of situations, ranging from functional upgrades to on-the-fly debugging or monitoring of critical applications. In this paper we study a particular form of computational reflection, called unanticipated partial behavioral reflection, which is particularly well-suited for unanticipated adaptation of real-world systems. Our proposal combines the dynamicity of unanticipated reflection, i.e., reflection that does not require preparation of the code of any sort, and the selectivity and efficiency of partial behavioral reflection. First, we propose unanticipated partial behavioral reflection which enables the developer to precisely select the required reifications, to flexibly engineer the metalevel and to introduce the meta behavior dynamically. Second, we present a system supporting unanticipated partial behavioral reflection in Squeak Smalltalk, called Geppetto, and illustrate its use with a concrete example of a Seaside web application. Benchmarks validate the applicability of our proposal as an extension to the standard reflective abilities of Smalltalk.


ESUG, 04.09.2006

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
651
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Unanticipated Partial Behavioral Reflection

  1. 1. Unanticipated Partial Behavioral Reflection David Röthlisberger Marcus Denker Eric Tanter © Marcus Denker
  2. 2. Roadmap > Example > Behavioral Reflection — Smalltalk / Metaclasstalk — Unanticipated Reflection — Partial Reflection > Unanticipated Partial Behavioral Reflection > Example revisited > Benchmarks > Conclusion © Marcus Denker
  3. 3. Running Example > Typical web application (e.g. Wiki) > Shows performance problem under high load > Goals: — Profile and fix the problem — No restart / interruption of service © Marcus Denker
  4. 4. Towards a Solution > Analyse the problem — Install profiler — Analyze — Retract profiler > Solve the problem — Introduce a caching mechanism — Experiment with multiple solutions © Marcus Denker
  5. 5. Reflection > Reflection: computation about computation — base level / meta level — causally connected > Structural Reflection — Reification of structure > Behavioral Reflection — Reification of execution © Marcus Denker
  6. 6. Unanticipated Reflection > “Unanticipated Use” means: — No need to know in advance (and plan for) reflection — Possible to be done at runtime > Java: reflection only at load time — No runtime change in general — Need to compile in hooks for reflection > Smalltalk reflection is unanticipated — taken for granted. But it’s quite cool! © Marcus Denker
  7. 7. Reflection in Smalltalk > Structural Reflection — Classes / Methods are objects — Can be changed at runtime > Behavioral Reflection — No model of execution below method body — message sending / variable access hard coded by VM — #doesNotUnderstand / MethodWrappers > Reflective capabilities of Smalltalk should be improved! © Marcus Denker
  8. 8. MetaclassTalk > Extends the Smalltalk metaclass model > Metaclass defines — message lookup — access to instance variables > Problems: — Reflection only controllable at class boundaries — No fine-grained selection (e.g. single operations) — Protocol between base and meta level is fixed © Marcus Denker
  9. 9. Partial Reflection > Hooksets: collection of operation occurrences > Links — Bind hooksets to metaobjects — Define Protocol between base and meta metaobject > Goals — Highly selective reification links activation condition — Flexiblel metalevel engineering – Protocol specification hookset – Cross-cutting hooksets © Marcus Denker
  10. 10. Geppetto > Partial Behavioral Reflection pioneered in Java — Code transformation at load time — Not unanticipated (it’s Java...) > Geppetto: Partial Behavioral Reflection for Smalltalk > For Squeak 3.9 with ByteSurgeon — but portable to other dialects > Let’s see an example! © Marcus Denker
  11. 11. Solving the Problem > Operation: — Method Execution (around) > Hookset: — All execution operations in the wiki package metaobject > Metaobject: — A profiling tool links activation condition hookset © Marcus Denker
  12. 12. Solving the Problem: Hookset + Link > Hookset allExecs := Hookset new. allExecs inPackage: ’Wiki’; operation: MethodEval. > Link profile := Link id: #profiler hookset: allExecs metaobject: Profiler new. profile control: Control around. © Marcus Denker
  13. 13. Solving the Problem: Protocol > Protocol profile callDescriptor: (CallDescriptor selector: #profileMethod:in:withArguments: parameters: {Parameter selector. Parameter self. Parameter arguments.} passingMode: PassingMode plain). > Install / Retract profile install. profile uninstall. © Marcus Denker
  14. 14. Solving the Problem: Caching > Operation: — Method Execution (around) > Hookset: — The one slow method (#toughWorks:) metaobject > Metaobject: — A Cache links activation condition hookset © Marcus Denker
  15. 15. Caching II > Hookset: toughWorks := Hookset new. toughWorks inClass: Worker; inMethod: #toughWork:; operation: MethodEval. > Link: cache := Link id: #cache hookset: toughWorks metaobject: Cache new. cache control: Control around. cache callDescriptor:(CallDescriptor selector: #cacheFor: parameters: {Parameter arg1} passingMode: PassingMode plain). © Marcus Denker
  16. 16. Geppetto > Operations: — MethodEval (like MethodWrappers) — MsgSend, InstVarAccess, TempAccess > Control — Before, After, Around, Replace > Activation condition per Link © Marcus Denker
  17. 17. Benchmarks I > Slowdown for reification of message send System Slowdown Geppetto 10.85 Iguana/J 24 Metaclasstalk 20 © Marcus Denker
  18. 18. Benchmarks II > Geppetto Vs. Metaclasstalk Metaclasstalk Geppetto Speedup (ms) (ms) message 108 46 2.3x send instance var 272 92 2.9x read © Marcus Denker
  19. 19. Future Work > Pluggable backends — Bytecode — AST based transformation — VM Support > Use for typical ByteSurgeon based projects — e.g. Tracing, Unstuck-Debugger > Experiment with advanced Scoping © Marcus Denker
  20. 20. Conclusion > Example for the need of Partial Behavioral Reflection > Overview of Geppetto > Solution of the Example > Benchmarks © Marcus Denker
  21. 21. Conclusion > Example for the need of Partial Behavioral Reflection > Overview of Geppetto > Solution of the Example > Benchmarks Questions? © Marcus Denker

×