1 / 48

Web Cache Prefetching as an Aspect: Towards a Dynamic-Weaving Based Solution

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. Improving the Web. Web cache:

oakes
Download Presentation

Web Cache Prefetching as an Aspect: Towards a Dynamic-Weaving Based Solution

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. 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. 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. 2 4 3 2 9 8 8 4 45 11 55 45 3 3 89 5 3 3 3 3 3 3 6 8 3 Storage space 3? 3? 3? 3? Storage space Web Caches Cache in the neighborhood Storage space Storage space Cache Client Server client request cooperation request Cache in the neighborhood

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

  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. 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. AOP for prefetching in Web caches Steps Base program development Web cache development Adapted development Aspect development Execution of base program Prefetching policy Web cache execution Adapted execution Adaptation code Weaving time Prefetching deployment time time Adaptation code link time

  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. Meeting the constraintsµDyner runtime system • 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

  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. Lifecycle and tools support Base program development Aspect development Build and design time Execution Weaving Runtime

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

  14. Lifecycle and tools support Prefetching policies: aspect sources Cache source code C with hookable Pretreatment Preprocessing C code Pointcut action as functions Pretreated base code µDyner support library Build and design time #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); } ] ] Compile - link (gcc) Compile link Postprocessing (gcc) Compiled aspects Shared library Adaptable cache Base code Aspect developer maintainer Execution Weaving Runtime

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

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

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

  18. µDyner compiled aspects Shared native library

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

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

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

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

  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. µ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. Weaving implementation int withdraw(float amount, BankAccount * account) { JUMP +3; NOP; NOP; NOP; // original function code } int transfer_money { // code withdraw(100,account) } Host process

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

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

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

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

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

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

  32. Link performance evaluationMethods • Micro evaluation : • Macro evaluation : Invoke an empty method Invoke an empty method with an empty aspect The ratio gives a performance evaluation 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

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

  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. 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. 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. References [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.

  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. #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); } µDyner instrumentation thread Three actors for three steps Prefetching policies: aspect sources Cache source code C with hookable Pretreatment Pretreatment C code Pointcut action as functions Pretreated base code µDyner support library Build and design time Compile - link (gcc) Compile link Postreatement (gcc) Compiled aspects Shared library Adaptable cache Base code Aspect developer maintainer Cache administrator Execute Cache (host process) Runtime Prefetching policy deployed through Cache threads shell commands(weave - deweave)

  41. µDyner instrumentation thread Three actors for three steps Prefetching policies: aspect sources Cache source code C with hookable Pretreatmentt Pretreatment C code Pointcut action as functions Pretreated base code µDyner support library Build and design time Compile - link (gcc) 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; } Compile link Postreatement (gcc) Compiled aspects Shared library Adaptable cache Base code Aspect developer maintainer Cache administrator Execute Cache (host process) Runtime Prefetching policy deployed through Cache threads shell commands(weave - deweave)

  42. 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.

  43. 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

  44. The EAOP model [DOU 01, DOU 02] • 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

  45. 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

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

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

More Related