From 8533bb95d36c0d21ee26d79b02ab14dff16de856 Mon Sep 17 00:00:00 2001 From: rhunk <101876869+rhunk@users.noreply.github.com> Date: Wed, 1 May 2024 01:31:50 +0200 Subject: [PATCH] perf(native): startup time --- native/jni/src/library.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/native/jni/src/library.cpp b/native/jni/src/library.cpp index 0fc550db..3c4570c9 100644 --- a/native/jni/src/library.cpp +++ b/native/jni/src/library.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "logger.h" #include "common.h" @@ -29,12 +30,20 @@ bool JNICALL init(JNIEnv *env, jobject clazz) { LOGD("client_module offset=0x%lx, size=0x%zx", client_module.base, client_module.size); - UnaryCallHook::init(env); - FstatHook::init(); - SqliteMutexHook::init(); - DuplexHook::init(env); + auto threads = std::vector(); + + #define RUN(body) threads.push_back(std::thread([&] { body; })) + + RUN(UnaryCallHook::init(env)); + RUN(FstatHook::init()); + RUN(SqliteMutexHook::init()); + RUN(DuplexHook::init(env)); if (common::native_config->composer_hooks) { - ComposerHook::init(); + RUN(ComposerHook::init()); + } + + for (auto &thread : threads) { + thread.join(); } LOGD("Native initialized");