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>
This commit is contained in:
Alexander Bondarenko 2023-11-23 00:37:33 +02:00 committed by GitHub
parent d0419df396
commit 954b7150af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View File

@ -5,7 +5,7 @@
//#include <android/log.h>
// 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();
}

View File

@ -4,11 +4,14 @@
#include <stdint.h>
// 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