X hits on this document

PDF document

Program Transformations for Light-Weight CPU Accounting and Control in the Java Virtual Machine A ... - page 10 / 40

97 views

0 shares

0 downloads

0 comments

10 / 40

10

void f(int x) {

g(); while (x > 0) {

if (h(x)) {

i(x);

}

  • --

    x;

}

}

  • --

    >

void f(int x) { ThreadCPUAccount cpu; cpu = ThreadCPUAccount.getCurrentAccount(); cpu.consumption += ...; if (cpu.consumption >= 0) cpu.triggerConsume(); g(); Start: cpu.consumption += ...; if (cpu.consumption >= 0) cpu.triggerConsume(); if (x > 0) { cpu.consumption += ...; if (h(x)) { cpu.consumption += i(x); } cpu.consumption += --x; goto Start; } cpu.consumption += ...; ...; ...;

}

Figure 4. Unoptimized rewriting of a method for CPU accounting.

paths leading through an invocation to the end of this method will necessarily pass through the beginning of the while loop, which itself already contains a compulsory polling conditional.

We do not show the concrete values by which the consumption variable is incremented; these values are calculated statically by the rewriting tool and represent the number of bytecodes that are going to be executed in the next accounting block.

Depending on the application, the concrete value for each accounting block can be computed in different ways:

  • 1.

    The number of bytecode instructions in the accounting block be- fore the rewriting takes place. In this strategy, the resulting CPU consumption reflects the number of bytecode instructions that the original, unmodified program would execute. This approach is particularly useful for benchmarking.

  • 2.

    The number of bytecode instructions in the accounting block after the rewriting, including the inserted accounting instructions. I.e., the resulting CPU consumption includes the accounting overhead. In particular, this setting allows a service provider to charge a client for the overall CPU consumption of the deployed client components.

3. For each of the previous two settings, each JVM bytecode instruc- tion may receive a different weight, as the complexity of the various

Document info
Document views97
Page views97
Page last viewedMon Dec 05 17:20:44 UTC 2016
Pages40
Paragraphs801
Words13591

Comments