4.2 HdpHProf Implementation Design
4.2.6 Trace Analysis and Presentation
HdpHProf provides analysis tools to analyse and present the HdpH DSL implementa- tion performance. Performance data analysis was discussed earlier in Sections 2.3.1. HdpHProf extends the GHC-Events Library with analysis tools specially designed for
the DSL HdpH. The library is equipped with tools and functionalities that can be used to read and process HdpH’s eventlogs to produce performance profiles. We call the extended version the GHC-Events-HdpH Library and it is available to download online [2]. As proof of concept we designed two analysis tools for HdpH internals: Spark Pool Contention Analysis, and Registry Contention Analysis. These are tools specified for detecting contention on data structures shared between HdpH schedulers and we want to know when it occurs because contention reduces performance. Fig- ure 4.1 (Phase 4) demonstrates how the analysis tools read and present performance of the DSL implementation. We will discuss the tools in more detail in the following sections.
Spark Pool Analysis
The spark pool is an important shared data structure in the HdpH DSL implementation that schedulers use to get sparks. This means that more than one scheduler can access the spark pool concurrently during execution. This can create contention where schedulers have to wait for sparks and this can affect the performance of HdpH. The Spark Pool Contention Analysis tool is designed to detect contention on accessing the spark pool by the multiple schedulers. It reads the spark pool trace events and analyses them for contention.
The tool is designed to detect two type of conflicts: 1) unproductive conflict, when two or more schedulers conflict and none of them leave the spark pool with a converted spark, and 2) productive conflict, where two or more schedulers conflict and one scheduler leaves the spark pool with a converted spark. It is important to distinguish between these two types of contentions as unproductive conflicts happen when the spark pool is empty and no scheduler leaves with a spark; whereas, productive conflicts happen when the spark pool contains some sparks and eventually one scheduler leaves with a spark while other schedulers must wait.
Figure 4.4 illustrates how contention on spark pool is identified by conflicts be- tween sequences of spark pool trace events over time. An unproductive conflict exists when the first scheduler enters the spark pool until it exits the spark pool; meanwhile, a second scheduler enters after the first scheduler and leaves with no spark until the first scheduler exits the spark pool. With this data more statistical information can be derived; e.g. how often conflicts happen, what are their durations, and what is the maximum conflict duration. This information can be used to understand the behaviour
of the HdpH RTS and to help improve it.
S#1 ESP
Spark Pool Trace Events
S#2ESP S#2 NS S#1 NS S#3 ESP S#4 ESP S#4 CS S#3 NS
S#X ESP = Scheduler number X tries to enter Spark Pool
S#X CS = Scheduler number X exits with converted spark
S#X NS = Scheduler number X exits with no spark to convert Unproductive Conflict Productive Conflict
Time
Figure 4.4: Spark Pool Conflicts.
Registry Analysis
The registry is another important data structure that manages global data in the HdpH DSL implementation. The registry can face high demand as many schedulers may try to access the registry concurrently, but only one scheduler can update the registry at a time and the others have to wait. The Registry Contention Analysis tool is designed to detect contention between schedulers accessing the registry.
A conflict on the registry occurs when a scheduler is holding the registry while one or more other schedulers are trying to access the registry and they have to wait until the first scheduler leaves the registry. Figure 4.5 shows how contention on the registry is detected by conflicts between the sequence of registry trace events over time. A conflict happens when a first scheduler enters the registry and a second scheduler tries to access the registry after the first scheduler and it has to wait until the first scheduler releases the registry. With this data statistical information can be derived, e.g. how often conflicts occur, and what are the durations of these conflicts. This information can help to understand the execution behaviour of HdpH RTS and improve it in the event of performance problems.
HpdH Performance Presentation
To present the HdpH RTS implementation performance data, HdpHProf uses sum- mative profiles for presentation. We extend the GHC-Events Library with HdpHProf profiles for the DSL profiling. HdpHProf analysis tools, the Spark Pool Contention
S#1 Enters
Registry Trace Events
Conflict
Time
S#2 Enters S#3 Enters S#1 Exits S#2 Exits S#3 Exits
S#X Enters = Scheduler number X tries accessing the registry S#X Exited = Scheduler number X exits the registry
Figure 4.5: Registry Conflicts.
Analysis and the Registry Contention Analysis present their result in the form of a summative profile. Figure 4.1 (Phase 4) demonstrates how a performance profile is produced from an eventlog with HdpHProf analysis tools. The profilers are discussed and presented in more detail in the implementation (Section 4.3.5).