Skip to content

Commit 8e55d31

Browse files
committed
rt: Use 100k stacks for scheduler threads
1 parent 7f1ea3e commit 8e55d31

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/rt/rust_task_thread.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ pthread_key_t rust_task_thread::task_key;
1313
DWORD rust_task_thread::task_key;
1414
#endif
1515

16-
const size_t C_STACK_SIZE = (1024*1024);
16+
const size_t SCHED_STACK_SIZE = 1024*100;
17+
const size_t C_STACK_SIZE = 1024*1024;
1718

1819
bool rust_task_thread::tls_initialized = false;
1920

2021
rust_task_thread::rust_task_thread(rust_scheduler *sched,
2122
rust_srv *srv,
2223
int id) :
24+
rust_thread(SCHED_STACK_SIZE),
2325
ref_count(1),
2426
_log(srv, this),
2527
log_lvl(log_debug),

src/rt/sync/rust_thread.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
#include "globals.h"
22
#include "rust_thread.h"
33

4-
rust_thread::rust_thread() : thread(0) {
4+
const size_t default_stack_sz = 1024*1024;
5+
6+
rust_thread::rust_thread() : thread(0), stack_sz(default_stack_sz) {
7+
}
8+
9+
rust_thread::rust_thread(size_t stack_sz)
10+
: thread(0), stack_sz(stack_sz) {
511
}
612

713
rust_thread::~rust_thread() {
@@ -23,11 +29,11 @@ rust_thread_start(void *ptr) {
2329
void
2430
rust_thread::start() {
2531
#if defined(__WIN32__)
26-
thread = CreateThread(NULL, 0, rust_thread_start, this, 0, NULL);
32+
thread = CreateThread(NULL, stack_sz, rust_thread_start, this, 0, NULL);
2733
#else
2834
pthread_attr_t attr;
2935
pthread_attr_init(&attr);
30-
pthread_attr_setstacksize(&attr, 1024 * 1024);
36+
pthread_attr_setstacksize(&attr, stack_sz);
3137
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
3238
pthread_create(&thread, &attr, rust_thread_start, (void *) this);
3339
#endif

src/rt/sync/rust_thread.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
* Thread utility class. Derive and implement your own run() method.
66
*/
77
class rust_thread {
8-
public:
8+
private:
99
#if defined(__WIN32__)
1010
HANDLE thread;
1111
#else
1212
pthread_t thread;
1313
#endif
14+
size_t stack_sz;
15+
public:
16+
1417
rust_thread();
18+
rust_thread(size_t stack_sz);
1519
virtual ~rust_thread();
1620

1721
void start();

0 commit comments

Comments
 (0)