Presentation is loading. Please wait.

Presentation is loading. Please wait.

Web Cache Prefetching as an Aspect: Towards a Dynamic-Weaving Based Solution Marc Ségura-Devillechaise, Jean-Marc Menaud, Gilles Muller OBASCO Project.

Similar presentations


Presentation on theme: "Web Cache Prefetching as an Aspect: Towards a Dynamic-Weaving Based Solution Marc Ségura-Devillechaise, Jean-Marc Menaud, Gilles Muller OBASCO Project."— Presentation transcript:

1 Web Cache Prefetching as an Aspect: Towards a Dynamic-Weaving Based Solution Marc Ségura-Devillechaise, Jean-Marc Menaud, Gilles Muller OBASCO Project EMN/INRIA, France Julia L. Lawall DIKU University of Copenhagen, Denmark AOSD 2003

2 2 Improving the Web Web cache: Stores previously-accessed contents preparing for later potential re-accesses Advantageous if contents are accessed repeatedly Content prefetching: Stores contents that have not yet been accessed preparing for later potential accesses Advantageous if contents are accessed eventually –Relies on the prediction of the access patterns of a Web application

3 3 Prefetching A prefetching policy must anticipate access patterns: –Access patterns are application dependent –A Web cache is shared among many Web applications Consequence: –Policies should be deployed on demand in the cache Problem: –How to integrate dynamically new prefetching policies within Web caches?

4 4 Web Caches Client Cache Server Storage space 3? 38245895 3 382 3 345 Storage space 3 39 4 855 Storage space 34 3 611 Storage space 3? 3 Cache in the neighborhood client request cooperation request

5 5 Typical flow of a cooperation request Accept user request Request analysis File lookup Send User Reply Local Storage Accept cooperation request Replacement policy Network module Send cooperation request Send Internet request Send cooperation reply ClientCache Web cache Typical flow of a user request Network neighborhood Internet Server

6 6 Issues in integrating prefetching in Web caches Observation: –Prefetching crosscuts the cache structure –Execution paths: modules are not sufficient A “natural” solution: AOP

7 7 AOP for prefetching in Web Caches Mapping Joinpoints Where, within the cache, a policy is allowed to run The pointcut language When a particular prefetching policy should be triggered Advice language What the prefetching policy should do Weaving Link a prefetching policy to the cache Specifies where adaptation can take place Specifies when to adapt Specifies the behaviour of the adaptation code Link the adaptation code to the base program

8 8 AOP for prefetching in Web caches Steps Base program development Aspect development Execution of base program Weaving time Prefetching policy Web cache development Prefetching deployment time Adapted development Adaptation code Adaptation code link time Web cache execution Adapted execution time

9 9 Constraints on the runtime system A cache processes every request to a subnet. –It must be efficient. The aspect code must be efficient. –The cache service must always be available. The base program must continuously run. Web caches are written in C. The aspect system must support the C language. Prefetching policies should be deployed on demand in the cache. The aspect system must allow dynamic weaving.

10 10 Strong performance requirements –Base program code preparation ( hookable ) –Aspect and base program Translated into C code by our tools Can be compiled with compiler optimizations –Weaving is performed with almost no interruption of the application Targeted for an audience of C developers –Advice as C code block –All pointcuts can be thought as « did the base program execute this C construct ?» Need to be able to perform the extension dynamically –Weaving performed at runtime Meeting the constraints µDyner runtime system

11 11 Meeting the constraints µDyner language Need to be able to reason on execution paths –Pointcut on nested functions calls «did f() call g() call h()? » Need to be able to monitor some global variable –Last element in the pointcut sequence can test whether a given global variable has been read or written In order to extend Web caches –The advice replaces the execution of the last element in the sequence. Can trigger execution of the original definition through continue.

12 12 Runtime Build and design time Lifecycle and tools support Base program development Aspect development Execution Weaving

13 13 Base code maintainer Pretreated base code Adaptable cache µDyner support library Preprocessing Compile - link (gcc) Cache source code C with hookable Postprocessing Lifecycle and tools support Runtime Build and design time Aspect development Execution Weaving hookable int withdraw(float amount,BankAccount * account) { assert(account!=NULL); account->debit = amount + account->debit ; return SUCCESS; }

14 14 Base code maintainer Pretreated base code Adaptable cache µDyner support library Pretreatment Compile - link (gcc) Cache source code C with hookable Postprocessing Lifecycle and tools support C code Pointcut action as functions Prefetching policies: aspect sources Compiled aspects Shared library Compile link (gcc) Preprocessing Aspect developer Runtime Build and design time Execution Weaving #include "../BaseProgram/BankAccount.h" #define MAX_WITHDRAWAL_AMOUNT 1000.0 anAspect:[ int withdraw(float amount, BankAccount * account) :[ { if(amount >= MAX_WITHDRAWAL_AMOUNT) return BANK_REFUSED; return continue_withdraw(amount,account); } ]

15 15 Base code maintainer Pretreated base code Adaptable cache µDyner support library Runtime Preprocessing Build and design time Compile - link (gcc) Cache source code C with hookable Postprocessing Lifecycle and tools support C code Pointcut action as functions Prefetching policies: aspect sources Compiled aspects Shared library Compile link (gcc) Preprocessing Aspect developer Cache administrator Execute µDyner instrumentation thread Cache threads Cache (host process)

16 16 Base code maintainer Pretreated base code Adaptable cache µDyner support library Runtime Preprocessing Build and design time Compile - link (gcc) Cache source code C with hookable Postprocessing Lifecycle and tools support C code Pointcut action as functions Prefetching policies: aspect sources Compiled aspects Shared library Compile link (gcc) Preprocessing Aspect developer Cache administrator Execute µDyner instrumentation thread Cache threads Prefetching policy deployed through shell commands (weave - deweave) Cache (host process)

17 17 µDyner implementation Aspect as shared library Base program preparation Weave

18 18 µDyner compiled aspects Shared native library

19 19 µDyner compiled aspects aspect entry point advice code continue pointers

20 20 µDyner compiled aspects aspect entry point advice code continue pointers Points to an address in the base program allowing to execute the last pointcut element

21 21 µDyner compiled aspects aspect entry point advice code continue pointers Invoked each time the base program reaches the last joinpoint element

22 22 µDyner compiled aspects aspect entry point advice code continue pointers Invoked each time the base program reaches the last join point element Checks pointcut Calls advice or continue

23 23 µDyner base code preparation Prepare the base program for analysis –Collect functions and variables addresses –Collect addresses of instructions accessing hookable variable –Collect addresses of instructions calling functions Prepare the base program for alteration –Make potential rewriting sites big enough to contain a jump instruction

24 24 µDyner weaver Open the aspect shared library Overwrite the last joinpoint as a jump to the aspect entry point Set the continue pointers in the aspect library

25 25 int transfer_money { } // original function code int withdraw(float amount, BankAccount * account) { JUMP +3; NOP; NOP; NOP; withdraw(100,account) // code Host process } Weaving implementation

26 26 #include "../BaseProgram/BankAccount.h" #define MAX_WITHDRAWAL_AMOUNT 1000.0 anAspect:[ int withdraw(float amount, BankAccount * account) :[ { if(amount >= MAX_WITHDRAWAL_AMOUNT) return BANK_REFUSED; return continue_withdraw(amount, account); } ] int transfer_money { } // original function code int withdraw(float amount, BankAccount * account) { JUMP +3; NOP; NO; NOP; withdraw(100,account) // code Host process } if(pointcut != TRUE) continue_withdraw(amount,account); else advice(amount,account); } int advice(float amount, BankAccount * account) { if(amount >= MAX_WITHDRAWAL_AMOUNT) return BANK_REFUSED; return continue_withdraw(amount,account); } int anAspect(float amount, BankAccount * account) { void * continue_withdraw = withdraw +5; Aspect Weaving implementation Overview of a compiled aspect Generated at compilation of the base program Generated at compilation of the aspect Generated at weaving time continue pointer aspect entry point aspect advice Aspect rewriting site

27 27 int transfer_money { } // original function code int withdraw(float amount, BankAccount * account) { JUMP +3; NOP; NO; NOP; withdraw(100,account) // code Host process } Generated at compilation of the base program Generated at compilation of the aspect Generated at weaving time if(pointcut != TRUE) continue_withdraw(amount,account); else advice(amount,account); } int advice(float amount, BankAccount * account) { if(amount >= MAX_WITHDRAWAL_AMOUNT) return BANK_REFUSED; return continue_withdraw(amount,account); } int anAspect(float amount, BankAccount * account) { } else { JUMP anAspect JUMP withdraw+5 } Hook if(aspect_loaded ==TRUE) void * continue_withdraw = withdraw +5; Aspect 1 load the aspect library – allocate the hook 2 rewriting the base code 3 set aspect_loaded to true Weaving implementation Hook:

28 28 int transfer_money { } // original function code int withdraw(float amount, BankAccount * account) { JMP 3; NOP; NOP; NOP; withdraw(100,account) // code Host process } if(pointcut != TRUE) continue_withdraw(amount,account); else advice(amount,account); } int advice(float amount, BankAccount * account) { if(amount >= MAX_WITHDRAWAL_AMOUNT) return BANK_REFUSED; return continue_withdraw(amount,account); } int anAspect(float amount, BankAccount * account) { } else { JUMP anAspect JUMP withdraw+5 } Hook if(aspect_loaded ==TRUE) void * continue_withdraw = withdraw +5; Aspect 1 load the aspect librairy – allocate the hook 2 rewriting the base code 3 set aspect_loaded to true Weaving implementation JUMP Hook Hook: Generated at compilation of the base program Generated at compilation of the aspect Generated at weaving time

29 29 int transfer_money { } // original function code int withdraw(float amount, BankAccount * account) { withdraw(100,account) // code Host process } if(pointcut != TRUE) continue_withdraw(amount,account); else advice(amount,account); } int advice(float amount, BankAccount * account) { if(amount >= MAX_WITHDRAWAL_AMOUNT) return BANK_REFUSED; return continue_withdraw(amount,account); } int anAspect(float amount, BankAccount * account) { } else { JUMP anAspect JUMP withdraw+5 } Hook if(aspect_loaded ==TRUE) void * continue_withdraw = withdraw +5; Aspect 1 load the aspect librairy – allocate the hook 2 rewriting the base code 3 set aspect_loaded to true Weaving implementation JUMP Hook Hook: Generated at compilation of the base program Generated at compilation of the aspect Generated at weaving time

30 30 int transfer_money { } // original function code int withdraw(float amount, BankAccount * account) { withdraw(100,account) // code Host process } if(pointcut != TRUE) continue_withdraw(amount,account); else advice(amount,account); } int advice(float amount, BankAccount * account) { if(amount >= MAX_WITHDRAWAL_AMOUNT) return BANK_REFUSED; return continue_withdraw(amount,account); } int anAspect(float amount, BankAccount * account) { } else { JUMP anAspect JUMP withdraw+5 } Hook if(aspect_loaded ==TRUE) void * continue_withdraw = withdraw +5; Aspect Use case – advice execution JUMP Hook Weaving implementation Hook: Generated at compilation of the base program Generated at compilation of the aspect Generated at weaving time Jump Function return Function call

31 31 int transfer_money { } // original function code int withdraw(float amount, BankAccount * account) { withdraw(100,account) // code Host process } if(pointcut != TRUE) continue_withdraw(amount,account); else advice(amount,account); } int advice(float amount, BankAccount * account) { if(amount >= MAX_WITHDRAWAL_AMOUNT) return BANK_REFUSED; return continue_withdraw(amount,account); } int anAspect(float amount, BankAccount * account) { } else { JUMP unAspect JUMP withdraw+5 } Hook if(aspect_loaded ==TRUE) void * continue_withdraw = withdraw +5; Aspect Use case – advice execution JUMP Hook Weaving implementation Hook: Generated at compilation of the base program Generated at compilation of the aspect Generated at weaving time Jump Function return Function call

32 32 Link performance evaluation Methods Measure the runtime of a given application for a given input Same measure with the same application with the same input but with woven aspects The ratio gives a performance evaluation Micro evaluation : Macro evaluation : Invoke an empty method Invoke an empty method with an empty aspect The ratio gives a performance evaluation

33 33 Link performance evaluation Results Linux Pentium4 1.6 GHz Micro evaluation: 2.2 slower Macro evaluation:1.015 slower (Tinyproxy – hit counting aspect)

34 34 Related Work Dynamic weaving: –PROSE Popovici A., Gross T., Alonso G. 2002 –JAC Pawlak R., Seinturier L., Duchien 2001 Native code instrumentation: –Dyninst Buck B., Hollingsworth J.K, 2000 AOP for C: –AspectC Y. Coady, G. Kiczales 2001

35 35 Future Work Increase the expressivity of the pointcut language (designing static functions…) Remove all static preparation of the base program code –Implies: suppression of hookable –Exploit debugging information rather than relying on source code Design a set of prefetching policies Modify Squid (prepare it for aspectization) –Build a dynamically adaptable web cache –Experiment with prefetching policies

36 36 Conclusion Prefetching as a crosscutting concern A method to link the base program to the aspect Almost no service interruption during weaving Very fast, once woven Prototype: µDyner –Within the implementation, links aspect and base program through dynamic code rewriting –Running under GNU/Linux, Pentium

37 Questions

38 38 [BUC 00] BUCK B., Hollingsworth J. K., An API for Runtime Code Patching, The International Journal of High Performance Computing Applications, vol. 14, n 4, 2000, p. 317-329. [CAH 02] Redmond B., Cahill V., Supporting unanticipated dynamic adaptation of application behaviour ECOOP 2002 – Object-Oriented Conference, 16th European Conference, vol. 2374 of Lectures Notes in Computer Sciences page 205-230, Malaga, Spain Juin 2002 [DOU 01] Douence R., Motelet O., Südholt M., A formal definition of crosscuts, Proceedings of the 3rd International Conference on Reflection and Crosscutting Concerns, vol. 2192 de Lecture Notes in Computer Science, Kyoto, Japan, 2001, Springer Verlag, p. 170-186. [DOU 02] Douence R., Fradet P., Südholt M., A framework for the detection and resolution of aspect interactions, Proceedings of the ACM SIGPLAN/SIGSOFT Conference on Generative Programming and Component Engineering (GPCE’02), 2002, p. 173-188. [KLE 96] Kleinoder J., Golm M. MetaJava : An efficient run-time meta architecture for Java. International Workshop on Object-Orientation In Operation Systems – IWOOS’96, p. 54- 61, Seattle WA, octobre 1996. [HOL 97] Hollingsworth J. K., Miller B. P., Goncalves M. J. R., Naim O., Xu Z., Zheng L., MDL : A Language and Compiler for Dynamic Program Instrumentation, IEEE PACT, 1997, p. 201-213. [OLI 98] Oliva A., Buzato L.E. The implementation of Guaranà in Java. Techhnical report IC- 98-32, Institute of of computing, University of Campinas, Brésil, septembre 1998. [PAW 01] Pawlak R., Seinturier L., Duchien L., Florin G., JAC : A Flexible Solution for Aspect-Oriented Programming in Java, Proceedings of Reflection’01, vol. 2192 de Lecture Notes in Computer Science, Springer, 2001, p. 1-24. [POP 02] Popovici A., Gross T., Alonso G., Dynamic weaving for aspect-oriented programming, Proceedings of the 1st international conference on Aspect-oriented software development, Enschede, The Netherlands, 2002, ACM Press, p. 141-147. References

39 39 AOP in a nutshell Joinpoints –The instrumentation sites within the base program. The pointcut language –A pattern on the execution trace of the base program. Action language –What to do when the pointcut matches the execution of the base program Weaving –Link a base program and an aspect –At compile time, at load time, at runtime.

40 40 Base code maintainer Pretreated base code Adaptable cache µDyner support library Runtime Pretreatment Build and design time Compile - link (gcc) Cache source code C with hookable Postreatement Three actors for three steps C code Pointcut action as functions Prefetching policies: aspect sources Compiled aspects Shared library Compile link (gcc) Pretreatment Aspect developer Cache administrator Execute µDyner instrumentation thread Cache threads Prefetching policy deployed through shell commands (weave - deweave) Cache (host process) #include "../BaseProgram/BankAccount.h" #define MAX_WITHDRAWAL_AMOUNT 1000.0 int (*continue_withdraw)(float amount,BankAccount * account)=NULL; int advice(float amount,BankAccount * account){ if(amount >= MAX_WITHDRAWAL_AMOUNT) return BANK_REFUSED; return continue_withdraw(amount,account); } int anAspect(float amount,BankAccount * account) { return advice(amount,account); }

41 41 Base code maintainer Pretreated base code Adaptable cache µDyner support library Runtime Pretreatmentt Build and design time Compile - link (gcc) Cache source code C with hookable Postreatement Three actors for three steps C code Pointcut action as functions Prefetching policies: aspect sources Compiled aspects Shared library Compile link (gcc) Pretreatment Aspect developer Cache administrator Execute µDyner instrumentation thread Cache threads Prefetching policy deployed through shell commands (weave - deweave) Cache (host process) int withdraw(float amount,BankAccount * account) __attribute__ ((noinline)); int withdraw(float amount,BankAccount * account) { __asm__ __volatile__ ( "jmp assert"); __asm__ __volatile__ ("nop");__asm__ __volatile__ ("nop"); __asm__ __volatile__ ("nop"); assert(account!=NULL); if((account->credit) <= OVERDRAFT_WITH_TRIAL) return BANK_REFUSED; account->debit = amount +account->debit ; return SUCCESS; }

42 42 By Partial matchBy PopularityBy Lifetime Accept user request Parse request File lookup Local storage Accept ICP request Send Internet request Send ICP request Send user reply Send ICP reply Replacement policy Interaction Interface appropriate Interaction Interface inadequate No interaction

43 43 Summary Difficult to anticipate the interaction of prefetching and the cache –Interaction depends heavily of the policy –Difficult for the cache to offer an API supporting this interaction A generic API might even slow down the cache.

44 44 Link performance evaluation Micro evaluation : ratio –µDyner (AOP for C – dynamic native code rewriting ) : 2.2 –IguanaJ [CAH 02] (MOP for Java – dynamic code rewriting of JIT code) : 24.0 –MetaXa [KLE 96] (MOP for Java – modified JVM) : 28.0 –Prose [POP 02] (AOP for Java – based on Java debugging API ) : 40.0 –Guaranà [OLI 98] (MOP for Java - modified JVM modifiée) : 70.0 Macro evaluation : ratio –µDyner (AOP for C) with Tinyproxy : 1.015 –Java Aspect Component [PAW 01] (AOP for Java) :5.000

45 45 Joinpoint –an event embeds a partial description of the current execution context events are grouped in a single execution trace Pointcut –a sequence of events –a monitor inspects the trace continuously checks the different pointcuts triggers the execution of aspect when needed The action language –access to the base program through the information contained in the events Weaving –Registration on the monitor The EAOP model [DOU 01, DOU 02]

46 46 EAOP for Web Caches? Well defined semantics but… Issues with the model –Not very well suited for concurrent applications –The duplication of execution context is relatively costly. Events are big. Issues with the proposed prototype –Weaving for Java –The set of events are open Everybody can use his own events Lack of a clear distinction between action and pointcut

47 47 int transfer_money { } // original function code int withdraw(float amount, BankAccount * account) { withdraw(100,account) // code Host process } if(pointcut != TRUE) continue_withdraw(amount,account); else advice(amount,account); } int advice(float amount, BankAccount * account) { if(amount >= MAX_WITHDRAWAL_AMOUNT) return BANK_REFUSED; return continue_withdraw(amount,account); } int anAspect(float amount, BankAccount * account) { } else { JMP anAspect JUMP withdraw+5 } Hook if(aspect_loaded ==TRUE) void * continue_withdraw = withdraw +5; Aspect Use case – pointcut not verified JUMP Hook Weaving implementation Hook: Generated at compilation of the base program Generated at compilation of the aspect Generated at weaving time Jump Function return Function call

48 48 int transfer_money { } // original function code int withdraw(float amount, BankAccount * account) { withdraw(100,account) // code Host process } if(pointcut != TRUE) continue_withdraw(amount,account); else advice(amount,account); } int advice(float amount, BankAccount * account) { if(amount >= MAX_WITHDRAWAL_AMOUNT) return BANK_REFUSED; return continue_withdraw(amount,account); } int anAspect(float amount, BankAccount * account) { } else { JMP anAspect JUMP withdraw+5 } Hook if(aspect_loaded ==TRUE) void * continue_withdraw = withdraw +5; Aspect Use case – aspect not activated JUMP Hook Weaving implementation Hook: Generated at compilation of the base program Generated at compilation of the aspect Generated at weaving time Jump Function return Function call


Download ppt "Web Cache Prefetching as an Aspect: Towards a Dynamic-Weaving Based Solution Marc Ségura-Devillechaise, Jean-Marc Menaud, Gilles Muller OBASCO Project."

Similar presentations


Ads by Google