- •1 Создание простого приложения в Eclipse
- •1.1. Запуск приложения Real-Time Java на целевой системе qnx Neutrino
- •1.2. Приложение демонстрирующее основные функциональные возможности rmi api of Jamaica
- •2 Building and Running an Example Java Program
- •2 Performance Optimization
- •2.1. Creating a profile
- •2.1.1. Creating a profiling application
- •2.2. Using a profile with the Builder
- •2.2.1. Building with a profile
- •2.3. Interpreting the profiling output
- •2.3.1. Format of the profile file
- •6.3.2. Example
- •3 Reducing Footprint and Memory
- •Import javax.Realtime.AsyncEventHandler;
- •Import javax.Realtime.PosixSignalHandler;
- •4 Дополнительное задание
2.1.1. Creating a profiling application
The compilation technology of Jamaica’s builder is able to use the data generated during profile runs using the -profile option to guide the compilation process, producing optimal performance with a minimum increase in code size.
Here is a demonstration of the profiler using the HelloWorld example:
> jamaicabuilder -cp classes -setGraphics=none -profile -interpret HelloWorld
The generated executable HelloWorld now prints the profiling information after execution. The output may look like this:
> ./HelloWorld 10000
2.2. Using a profile with the Builder
Having collected the profiling data, the Jamaica Compiler can create a compiled version of the application using the profile information. This compiled version benefits from profiling information in several ways:
Compilation is limited to the most time critical methods, keeping noncritical methods in smaller interpreted byte-code format.
Method inlining prefers inlining of calls that have shown to be executed most frequently during the profiling run.
Profiling information also collects information on the use of reflection, so an application that cannot use smart linking due to reflection can profit from smart linking even without manually listing all classes referenced via reflection.
2.2.1. Building with a profile
The builder option -useProfile is used to select the generated profiling data:
> jamaicabuilder -cp classes -setGraphics=none -useProfile HelloWorld.prof HelloWorld
Due to the profile-guided optimizations performed by the compiler, the runtime performance of the application built using a profile as shown usually exceeds the performance of a fully compiled application. Furthermore, the memory footprint is significantly smaller and the modify-compile-run cycle time is usually significantly shorter as well since only a small fraction of the application needs to be compiled. It is not necessary to re-generate profile data after every modification.
2.3. Interpreting the profiling output
When running in profiling mode, the VM collects data to create an optimized application but can also be interpreted manually to find find memory leaks or time consuming methods. You can make Jamaica collect information about performance, memory requirements etc.
To collect additional information, you have to set the property jamaica. profile_groups to select one or more profiling groups. The default value is builder to collect data used by the builder. You can set the property to the values builder, memory, speed, all or a comma separated combination of those. Example:
> jamaicavmp -cp classes \
> -Djamaica.profile_groups=builder,speed \
> HelloWorld
2.3.1. Format of the profile file
Every line in the profiling output starts with a keyword followed by space separated values. The meaning of these values depends on the keyword.
For a better overview, the corresponding values in different lines are aligned as far as possible and words and signs that improve human reading are added. Here for every keyword the additional words and signs are omitted and the values are listed in the same order as they appear in the text file.
Keyword: BEGIN_PROFILE_DUMP Groups: all
Values
unique dump ID
Keyword: END_PROFILE_DUMP Groups: all
Values
unique dump ID
Keyword: HEAP_REFS Groups: memory
Values
total number of references in object attributes
total number of words in object attributes
relative number of references in object attributes
Keyword: HEAP_USE Groups: memory
Values
total number of currently allocated objects of this class
number of blocks needed for one object of this class
block size in bytes
number of bytes needed for all objects of this class
relative heap usage of objects of this class
total number of objects of this class organized in a tree structure
relative number of objects of this class organized in a tree structure
name of the class
Keyword: INSTANTIATION_COUNT Groups: memory
Values
total number of instantiated objects of this class
number of blocks needed for one object of this class
number of blocks needed for all objects of this class
number of bytes needed for all objects of this class
total number of objects of this class organized in a tree structure
relative number of objects of this class organized in a tree structure
class loader that loaded the class
name of the class
Keyword: PROFILE Groups: builder
Values
total number of bytecodes spent in this method
relative number of bytecodes spent in this method
signature of the method
class loader that loaded the class of the method
Keyword: PROFILE_CLASS_USED_VIA_REFLECTION Groups: builder
Values
name of the class used via reflection
Keyword: PROFILE_CYCLES Groups: speed
Values
total number of processor cycles spent in this method (if available on the target)
signature of the method
Keyword: PROFILE_INVOKE Groups: builder
Values
number of calls from caller method to called method
bytecode position of the call within the method
signature of the caller method
signature of the called method
Keyword: PROFILE_INVOKE_CYCLES Groups: speed
Values
number of processor cycles spent in the called method
bytecode position of the call within the method
signature of the caller method
signature of the called method
Keyword: PROFILE_NATIVE Groups: all
Values
total number of calls to the native method
relative number of calls to the native method
signature of the called native method
Keyword: PROFILE_NEWARRAY Groups: memory
Values
number of calls to array creation within a method
bytecode position of the call within the method
signature of the method
Keyword: PROFILE_THREAD Groups: memory, speed
Values
current Java priority of the thread
total amount of CPU cycles in this thread
relative time in interpreted code
relative time in compiled code
relative time in JNI code
relative time in garbage collector code
required C stack size
required Java stack size
Keyword: PROFILE_THREADS Groups: builder
Values
maximum number of concurrently used threads
Keyword: PROFILE_THREADS_JNI Groups: builder
Values
maximum number of threads attached via JNI
Keyword: PROFILE_VERSION Groups: all
Values
version of Jamaica the profile was created with
