...
Note that in most cases, these allocations are so efficient that it likely won't affect performane. However, it's possible it could have an affect in a tight inner loop. At the very least, it avoids noise when profiling.
Examining Bytecode
As is apparent from the above suggestions, minimizing allocations is often key to improving Daffodil performance and making profiling less noisy. Often times an allocation will occur but it isn't clear based on the source why such an allocation might be happening. In these cases, it is often necessary to inspect the bytecode. To do so, the use of the javap
function can be invaluable. The following will convert a class to bytecode, including some helpful comments:
Code Block |
---|
|
java -p -c path/to/class/file.class |
It can also be useful to search the entire code base for certain allocations by looking through the disassemble code. A useful script to determine is the following:
Code Block |
---|
|
find daffodil.git -name '*.class' -exec javap -p -c '{}' \; > disassembled.txt |
From there, you can grep this file and determine where unexpected allocations may be taking place. For example, to find allocation
Code Block |
---|
|
grep -a "new" -n disassembled.txt | grep "java/math/BigInteger" |