Linx Kit provides APIs to implement the Hotspot Accelerate function. By optimizing the hotspot code patterns during thread execution, these APIs improve the thread execution efficiency. The Hotspot Accelerate function is used to optimize the performance of specific threads and is applicable to scenarios requiring higher thread execution efficiency.
For example, in the figure below, the key threads (logic and rendering threads) on the CPU exhibit periodicity at the frame level.

After identifying the source code location, you can call the relevant APIs at the entry and exit of the periodic hotspot process. The Hotspot Accelerate module then records and saves the program runtime behavior, such as branch jumps and other key information, and replays this behavior in the next frame, thereby improving thread execution efficiency.
In scenarios where thread performance needs to be optimized, you can call Hotspot Accelerate APIs provided by Linx Kit to improve the thread execution efficiency. The following describes the main development procedure of the Hotspot Accelerate module:
find_library(linxkit-lib liblinx.so)
target_link_libraries(entry PUBLIC ${linxkit-lib})The following shows the complete code and steps for enabling Hotspot Accelerate:
Import the header file.
#include "LinxKit/linx_hotspot.h"
Call HMS_LINX_HotspotAccelerateInit to initialize the Hotspot Accelerate module when an app process is created.
int32_t ret = HMS_LINX_HotspotAccelerateInit();
if (ret != 0) {
(void)OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_ID, "linxkit_test", "LinxKit init error: %{public}d", ret);
} Call HMS_LINX_HotspotAccelerateBegin to start hotspot acceleration. ctx is initialized to 0. A valid ctx will be automatically allocated by the Hotspot Accelerate API later.
uint32_t ctx = g_ctx;
int32_t ret = HMS_LINX_HotspotAccelerateBegin(&ctx);
g_ctx = ctx;
if (ret != 0) {
(void)OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_ID, "linxkit_test", "LinxKit acc begin error: %{public}d", ret);
} Call HMS_LINX_HotspotAccelerateEnd to stop hotspot acceleration and release resources when acceleration is not required.
ret = HMS_LINX_HotspotAccelerateEnd(ctx);
if (ret != 0) {
(void)OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_ID, "linxkit_test", "LinxKit acc end error: %{public}d", ret);
}