Create on demand up to min_threads to avoid startup penalty, avoiding
throttling of threadpool worker thread creation (for now, using
a --server flag) at initialization.
When throttling happens, operations such as parallel https requests were
slowed down significantly due to all of the threads created in order
to complete the SSL operations.
Based on @kamalaboulhosn's patch (https://github.com/mono/mono/pull/640/files)
.TP
\fB--server\fR
Configures the virtual machine to be better suited for server
.TP
\fB--server\fR
Configures the virtual machine to be better suited for server
-operations (currently, a no-op).
+operations (currently, allows a heavier threadpool initialization).
.TP
\fB--verify-all\fR
Verifies mscorlib and assemblies in the global
.TP
\fB--verify-all\fR
Verifies mscorlib and assemblies in the global
mono_config_parse_file_with_context (&state, filename);
}
mono_config_parse_file_with_context (&state, filename);
}
+static gboolean mono_server_mode = FALSE;
+
+void
+mono_config_set_server_mode (gboolean server_mode)
+{
+ mono_server_mode = server_mode;
+}
+
+gboolean
+mono_config_is_server_mode (void)
+{
+ return mono_server_mode;
+}
+
const char* mono_config_string_for_assembly_file (const char *filename);
const char* mono_config_string_for_assembly_file (const char *filename);
+void mono_config_set_server_mode (gboolean server_mode);
+gboolean mono_config_is_server_mode (void);
+
MONO_END_DECLS
#endif /* __MONO_METADATA_CONFIG_H__ */
MONO_END_DECLS
#endif /* __MONO_METADATA_CONFIG_H__ */
#include <mono/metadata/threadpool-internals.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/environment.h>
#include <mono/metadata/threadpool-internals.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/environment.h>
+#include <mono/metadata/mono-config.h>
#include <mono/metadata/mono-mlist.h>
#include <mono/metadata/mono-perfcounters.h>
#include <mono/metadata/socket-io.h>
#include <mono/metadata/mono-mlist.h>
#include <mono/metadata/mono-perfcounters.h>
#include <mono/metadata/socket-io.h>
}
/* Create on demand up to min_threads to avoid startup penalty for apps that don't use
* the threadpool that much
}
/* Create on demand up to min_threads to avoid startup penalty for apps that don't use
* the threadpool that much
- * mono_thread_create_internal (mono_get_root_domain (), threadpool_start_idle_threads, tp, TRUE, FALSE, SMALL_STACK);
- */
+ */
+ if (mono_config_is_server_mode ()) {
+ mono_thread_create_internal (mono_get_root_domain (), threadpool_start_idle_threads, tp, TRUE, FALSE, SMALL_STACK);
+ }
}
for (i = 0; i < njobs; i++) {
}
for (i = 0; i < njobs; i++) {
}
} else if (strcmp (argv [i], "--desktop") == 0) {
mono_gc_set_desktop_mode ();
}
} else if (strcmp (argv [i], "--desktop") == 0) {
mono_gc_set_desktop_mode ();
- /* Put desktop-specific optimizations here */
+ /* Put more desktop-specific optimizations here */
} else if (strcmp (argv [i], "--server") == 0){
} else if (strcmp (argv [i], "--server") == 0){
- /* Put server-specific optimizations here */
+ mono_config_set_server_mode (TRUE);
+ /* Put more server-specific optimizations here */
} else if (strcmp (argv [i], "--inside-mdb") == 0) {
action = DO_DEBUGGER;
} else if (strncmp (argv [i], "--wapi=", 7) == 0) {
} else if (strcmp (argv [i], "--inside-mdb") == 0) {
action = DO_DEBUGGER;
} else if (strncmp (argv [i], "--wapi=", 7) == 0) {