## 4.6.2  Kernel Profiler
The kernel profiler is a sampling profiler built into the SAP HANA database. It can be used to analyze performance issues with systems on which third-party software cannot be installed, or parts of the database that are not accessible by the performance trace. It is inactive by default.
The kernel profile collects, for example, information about frequent and/or expensive execution paths during query processing.
It is recommended that you start kernel profiler tracing immediately before you execute the statements you want to analyze and stop it immediately after they have finished. This avoids the unnecessary recording of irrelevant statements. It is also advisable as this kind of tracing can negatively impact performance.
## Enabling and Configuring the Kernel Profiler
You can enable and configure the kernel profiler in the SAP HANA Database Explorer (Trace Configuration) or you can manage the kernel profiler from the SQL command line using the ALTER SYSTEM command. In both cases RESOURCE ADMIN or TRACE ADMIN privileges are required.
## Enabling Kernel Profiler using SQL
The kernel profiler statement supports basic functions such as start, stop, save and clear, but also a number of options such as to run the profile for a specific location, for a specific user or within certain memory limits.
The following examples illustrate the basic usage of the ALTER SYSTEM command:
ALTER SYSTEM START KERNEL PROFILER
ALTER SYSTEM SAVE KERNEL PROFILER
The SAVE keyword stops the profiler, saves the data (to the trace directory) and clears allocated memory. The following statement starts profiling at host:port ab1234:30003 and filters for the user specific trace (database trace) profile MYTRACEPROFILE
```
ALTER SYSTEM START KERNEL PROFILER AT 'ab1234:30003' TRACEPROFILE 'MYTRACEPROFILE';
```
Refer to the SAP HANA SQL Reference Guide for further options and details of these commands.
## Configuration Options in Database Explorer
| Option                | Description                                                                                                                                                                                                                                                                                            |
|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Service(s) to profile | The service(s) that you want to profile.                                                                                                                                                                                                                                                               |
| Sampling interval     | The amount of time the kernel profiler is to wait between call stack retrievals. When you activate the kernel profiler, it retrieves the call stacks of relevant threads several times. It waits between each sample for the length of time specified here minus the time the previous retrieval took. |
| Option          | Description                                                                                                                                                                                                                       |
|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Memory limit    | Memory limit that will stop tracing. The kernel profiler can potentially use a lot a memory. To prevent the SAP HANAdatabase from running out of memory due to profiling, you can specify a memory limit that cannot be exceeded. |
| Optional filter | The specific database user or application user you want to profile.                                                                                                                                                               |
## Kernel Profiler Traces
Profiling results are saved to two trace files. When started from SQL:
- kernel_profiler_cpu.dot
- kernel_profiler_wait.dot
When started from Database Explorer:
- CPU_&lt;service>=_&lt;host>=_&lt;port>=_&lt;timestamp>=.dot
- WAIT_&lt;service>=_&lt;host>=_&lt;port>=_&lt;timestamp>=.dot
To analyze these trace files you need a tool capable of reading the .dot output format, or you may be asked to send the files to SAP Support.
## View m_KERNEL_PROFILER
The view m_KERNEL_PROFILER displays the status of the profiler (started or stopped) and provides information about current kernel profilers. The view can also be accessed by users with RESOURCE ADMIN and/or TRACE ADMIN privileges.
## Further Information
An SAP Community blog Kernel profiler filtered by connection ID and statement hash gives further details of this feature.
## Related Information
Diagnostic Files and Logs
m_KERNEL_PROFILER System View ALTER SYSTEM {START | STOP | SAVE | CLEAR} KERNEL PROFILER Statement (System Management) SAP Community Blog: Kernel profiler filtered by connection ID and statement hash