1 / 18

Readings on Instrumentation, Profiling, and Tracing

Readings on Instrumentation, Profiling, and Tracing. IPT. Seminar presentation by Milan Jovic University of Lugano November 30, 2006. BIT: A Tool for Instrumenting Java Bytecodes. Han Bok Lee (University of Colorado, Boulder) Benjamin G. Zorn (University of Colorado, Boulder) USENIX, 1997.

jerod
Télécharger la présentation

Readings on Instrumentation, Profiling, and Tracing

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. Readings on Instrumentation, Profiling, and Tracing IPT Seminar presentation by Milan Jovic University of Lugano November 30, 2006

  2. BIT: A Tool for Instrumenting Java Bytecodes Han Bok Lee (University of Colorado, Boulder) Benjamin G. Zorn (University of Colorado, Boulder) USENIX, 1997

  3. What is BIT? • BIT = ATOM for Java bytecode • framework for Java

  4. The ATOM process The BIT process

  5. How does BIT work? • What has to be changed? • instances of BIT classes • new method calls required • new constants and variables needed • Constant pool has to be changed

  6. Class bytecode structure and Constant Pool

  7. disassembled while loop statement publicstaticvoid main(String[] args) { int i, j = 10; i = 0; while (j > 0) { if (j % 2 == 0) i++; else System.out.print(j+i); j--; } } public static void main(java.lang.String[]); Signature: ([Ljava/lang/String;)V Code: 0: bipush 10 2: istore_2 3: iconst_0 4: istore_1 5: goto 32 8: iload_2 9: iconst_2 10: irem 11: ifne 20 14: iinc 1, 1 17: goto 29 20: getstatic #16; //Field java/lang/System.out:Ljava/io/PrintStream; 23: iload_2 24: iload_1 25: iadd 26: invokevirtual #22; //Method java/io/PrintStream.print:(I)V 29: iinc 2, -1 32: iload_2 33: ifgt 8 36: return }

  8. disassembled SWITCH statement publicstaticvoid main(String[] args) { int i, j; i = 5; switch (i) { case 0:j=0;break; case 1:j=1;break; case 2:j=2;break; case 3:j=3;break; default : j=4; } System.out.println (j); } public static void main(java.lang.String[]); Code: 0: iconst_5 1: istore_1 2: iload_1 3: tableswitch{ //0 to 3 0: 32; 1: 37; 2: 42; 3: 47; default: 52 } 32: iconst_0 33: istore_2 34: goto 54 37: iconst_1 38: istore_2 39: goto 54 42: iconst_2 43: istore_2 44: goto 54 47: iconst_3 48: istore_2 49: goto 54 52: iconst_4 53: istore_2 54: getstatic #16; //Field java/lang/System.out:Ljava/io/PrintStream; 57: iload_2 58: invokevirtual #22; //Method java/io/PrintStream.println:(I)V 61: return }

  9. How to instrument? Routine ClassInfo addBefore () getBasicBlocks() getInstructions () getMethod () getRoutines () ClassInfo (fileName) write () Instruction addBefore () addAfter () getOpcode () getOrigOffset ()

  10. Instrument for dynamic instruction counting ClassInfo c = new ClassInfo (InstrumentFileName); Vector r = c.getRoutines (); for (Enumeration e = r.elements (); e.has MoreElements ();) { Routine rout = (Routine) e.nextElement (); Vector i = rout.getInstructions (); for (Enumeration e2 = rout.getBasicBlocks().elements ();; b.hasMoreElements ();) { BasicBlock bb = (BasicBlock) e2.nextElement (); bb.addBefore (“ICount”, “count”, new Integer (bb.size())); } } c.write (OutputFileName);

  11. Instrument for branch profiling ClassInfo c = new ClassInfo (InstrumentFileName); Vector r = c.getRoutines (); for (Enumeration e = r.elements (); e.has MoreElements ();) { Routine rout = (Routine) e.nextElement (); Vector i = rout.getInstructions (); for (Enumeration e2 = rout.getBasicBlocks ().elements(); e2.hasMoreElements ();) { BasicBlock bb = (BasicBlock) e2.nextElement (); Instruction inst = (Instruction) i.elementAt(bb.getEndAddress ()); short type = InstructionTable.InstructionTypeTable [inst.getOpcode ()]; if (type == InstructionTable.CONDITIONAL_INSTRUCTION) { inst.addBefore (“BranchPrediction”, “Offset”, new Integer (inst.getOrigOffset ()); inst.addBefore (“BracnhPrediction”, “Branch”, new String (“Branch Outcome”); } } String method = new String (rout.getMethod ()); rout.addBefore (“BranchPrediction”, “EnterMethod”, method); rout.addAfter (“BranchPrediction”, “LeaveMethod”, method); } c.write (OutputFileName);

  12. Analysis code for branch profiling static int pc = 0; public static void Offset (int offset) { pc = offset; } public static void Branch (int brOutcome) { Integer n = new Integer (pc); Branch b = (Branch) branch.get (n); if (b == null) b = new Branch (); if (brOutcome == 0) b.taken++; else b.not_taken++; }

  13. Performance of addingbranch count instrumentation

  14. BIT – Instrument user programs

  15. Portability

  16. Weakness of Tool? • Slowdown of instrumented program • 23% to 150% • Mostly around 150% • Doesn’t work with exceptions • Calls from instrumentation to analysis code limited to one argument

  17. Comparison of papers

  18. Discussion!

More Related