From 954b7150af057a770657b67c2da646527ed9e426 Mon Sep 17 00:00:00 2001 From: Alexander Bondarenko <486682+dpwiz@users.noreply.github.com> Date: Thu, 23 Nov 2023 00:37:33 +0200 Subject: [PATCH] android, desktop: set RTS options for core (#3418) * desktop: allow settings RTS options * set initial heap and arena sizes * add non-moving GC for even more productivity/less reallocs * add RTS options for android too --------- Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> --- .../src/commonMain/cpp/android/simplex-api.c | 14 ++++++++++++-- .../src/commonMain/cpp/desktop/simplex-api.c | 7 +++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/cpp/android/simplex-api.c b/apps/multiplatform/common/src/commonMain/cpp/android/simplex-api.c index b729e3b7f..54478425f 100644 --- a/apps/multiplatform/common/src/commonMain/cpp/android/simplex-api.c +++ b/apps/multiplatform/common/src/commonMain/cpp/android/simplex-api.c @@ -5,7 +5,7 @@ //#include // from the RTS -void hs_init(int * argc, char **argv[]); +void hs_init_with_rtsopts(int * argc, char **argv[]); // from android-support void setLineBuffering(void); @@ -32,7 +32,17 @@ Java_chat_simplex_common_platform_CoreKt_pipeStdOutToSocket(JNIEnv *env, __unuse JNIEXPORT void JNICALL Java_chat_simplex_common_platform_CoreKt_initHS(__unused JNIEnv *env, __unused jclass clazz) { - hs_init(NULL, NULL); + int argc = 5; + char *argv[] = { + "simplex", + "+RTS", // requires `hs_init_with_rtsopts` + "-A16m", // chunk size for new allocations + "-H64m", // initial heap size + "-xn", // non-moving GC + NULL + }; + char **pargv = argv; + hs_init_with_rtsopts(&argc, &pargv); setLineBuffering(); } diff --git a/apps/multiplatform/common/src/commonMain/cpp/desktop/simplex-api.c b/apps/multiplatform/common/src/commonMain/cpp/desktop/simplex-api.c index 1b0d11a2b..e2cd7ed55 100644 --- a/apps/multiplatform/common/src/commonMain/cpp/desktop/simplex-api.c +++ b/apps/multiplatform/common/src/commonMain/cpp/desktop/simplex-api.c @@ -4,11 +4,14 @@ #include // from the RTS -void hs_init(int * argc, char **argv[]); +void hs_init_with_rtsopts(int * argc, char **argv[]); JNIEXPORT void JNICALL Java_chat_simplex_common_platform_CoreKt_initHS(JNIEnv *env, jclass clazz) { - hs_init(NULL, NULL); + int argc = 5; + char *argv[] = {"simplex", "+RTS", "-A16m", "-H64m", "-xn", NULL}; // see android/simplex-api.c for details + char **pargv = argv; + hs_init_with_rtsopts(&argc, &pargv); } // from simplex-chat