WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
208223
Allow setting of stack sizes for threads
https://bugs.webkit.org/show_bug.cgi?id=208223
Summary
Allow setting of stack sizes for threads
Don Olmstead
Reported
2020-02-25 16:05:06 PST
Currently all threads use the default stack size and no attempt is made to change the size. This might not be ideal on some platforms or some thread types.
Attachments
WIP Patch
(5.50 KB, patch)
2020-02-25 16:08 PST
,
Don Olmstead
no flags
Details
Formatted Diff
Diff
WIP Patch
(5.94 KB, patch)
2020-02-26 09:23 PST
,
Don Olmstead
no flags
Details
Formatted Diff
Diff
Patch
(16.94 KB, patch)
2020-02-26 11:27 PST
,
Don Olmstead
no flags
Details
Formatted Diff
Diff
Patch
(17.00 KB, patch)
2020-02-26 11:37 PST
,
Don Olmstead
mark.lam
: review+
Details
Formatted Diff
Diff
Patch
(17.08 KB, patch)
2020-02-26 12:41 PST
,
Don Olmstead
no flags
Details
Formatted Diff
Diff
Patch
(17.08 KB, patch)
2020-02-26 12:42 PST
,
Don Olmstead
no flags
Details
Formatted Diff
Diff
Patch
(17.04 KB, patch)
2020-02-26 13:13 PST
,
Don Olmstead
ysuzuki
: review+
Details
Formatted Diff
Diff
Patch
(16.71 KB, patch)
2020-02-26 13:23 PST
,
Don Olmstead
no flags
Details
Formatted Diff
Diff
Show Obsolete
(7)
View All
Add attachment
proposed patch, testcase, etc.
Don Olmstead
Comment 1
2020-02-25 16:08:36 PST
Comment hidden (obsolete)
Created
attachment 391698
[details]
WIP Patch
Don Olmstead
Comment 2
2020-02-26 09:23:52 PST
Comment hidden (obsolete)
Created
attachment 391749
[details]
WIP Patch
Don Olmstead
Comment 3
2020-02-26 11:27:59 PST
Comment hidden (obsolete)
Created
attachment 391760
[details]
Patch
Don Olmstead
Comment 4
2020-02-26 11:37:48 PST
Created
attachment 391762
[details]
Patch
Mark Lam
Comment 5
2020-02-26 12:03:53 PST
Comment on
attachment 391762
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=391762&action=review
r=me with fixes.
> Source/WTF/ChangeLog:11 > + based on their own observations. Additionally a default stack size can be specified > + during by defining DEFAULT_THREAD_STACK_SIZE_IN_KB if the default stack for a platform is
Can you clarify what you mean here by "specified during"? I suspect you're missing some details.
> Source/WTF/wtf/Threading.cpp:53 > > +#if defined(DEFAULT_THREAD_STACK_SIZE_IN_KB) && DEFAULT_THREAD_STACK_SIZE_IN_KB > 0 > +static constexpr size_t defaultStackSize = DEFAULT_THREAD_STACK_SIZE_IN_KB * 1024; > +#else > +// Use the platform's default stack size > +static constexpr size_t defaultStackSize = 0; > +#endif
Just move this into Thread::create() and initialize an Optional<size_t> there.
> Source/WTF/wtf/Threading.cpp:162 > + // If the stack size is set to 0 then use the system default. Platforms can tune the values here.
Please add a comma after '0'.
> Source/WTF/wtf/Threading.h:247 > + bool establishHandle(NewThreadContext*, size_t);
Please use Optional<size_t> instead of size_t. Then we don't have to worry about the convention of a size of 0 meaning something special.
> Source/WTF/wtf/posix/ThreadingPOSIX.cpp:204 > +bool Thread::establishHandle(NewThreadContext* context, size_t stackSize)
Use Optional<size_t>.
> Source/WTF/wtf/win/ThreadingWin.cpp:156 > +bool Thread::establishHandle(NewThreadContext* data, size_t stackSize)
Use Optional<size_t>.
Mark Lam
Comment 6
2020-02-26 12:05:22 PST
Comment on
attachment 391762
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=391762&action=review
>> Source/WTF/wtf/Threading.cpp:53 >> +#endif > > Just move this into Thread::create() and initialize an Optional<size_t> there.
On 2nd thought, let's have a static defaultStackSize() function that returns an Optional<size_t>, and have Thread::create() call that.
Don Olmstead
Comment 7
2020-02-26 12:41:20 PST
Comment hidden (obsolete)
Created
attachment 391768
[details]
Patch Addressing review feedback
Don Olmstead
Comment 8
2020-02-26 12:42:39 PST
Created
attachment 391769
[details]
Patch Address review feedback
Mark Lam
Comment 9
2020-02-26 13:02:05 PST
Comment on
attachment 391769
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=391769&action=review
> Source/WTF/wtf/Threading.cpp:48 > +static Optional<size_t> defaultStackSize() {
WebKit style requires the { to be on the next line.
> Source/WTF/wtf/Threading.cpp:173 > +#if PLATFORM(PLAYSTATION) > + if (threadType == ThreadType::JavaScript) > + stackSize = 512 * 1024; > +#else > + UNUSED_PARAM(threadType); > +#endif
Hmmm ... further improvement: let rename defaultStackSize() to stackSize() and pass it the ThreadType. With that, you can move this logic in there, and we can have the computation of the stack size to use all in one place.
> Source/WTF/wtf/posix/ThreadingPOSIX.cpp:212 > + if (stackSize.hasValue())
You can just say "if (stackSize)" instead.
> Source/WTF/wtf/win/ThreadingWin.cpp:159 > + unsigned initFlag = stackSize.hasValue() ? STACK_SIZE_PARAM_IS_A_RESERVATION : 0;
Ditto: just use "staskSize ?" instead of "stackSize.hasValue() ?".
Don Olmstead
Comment 10
2020-02-26 13:13:30 PST
Created
attachment 391773
[details]
Patch More cleanup. Good idea with the stackSize function!
Yusuke Suzuki
Comment 11
2020-02-26 13:15:41 PST
Comment on
attachment 391769
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=391769&action=review
>> Source/WTF/wtf/Threading.cpp:173 >> +#endif > > Hmmm ... further improvement: let rename defaultStackSize() to stackSize() and pass it the ThreadType. With that, you can move this logic in there, and we can have the computation of the stack size to use all in one place.
Sounds better.
>> Source/WTF/wtf/win/ThreadingWin.cpp:159 >> + unsigned initFlag = stackSize.hasValue() ? STACK_SIZE_PARAM_IS_A_RESERVATION : 0; > > Ditto: just use "staskSize ?" instead of "stackSize.hasValue() ?".
Or, use `stackSize.valueOr(0)`.
Yusuke Suzuki
Comment 12
2020-02-26 13:16:54 PST
Comment on
attachment 391773
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=391773&action=review
r=me
> Source/WTF/wtf/Threading.cpp:174 > +
Remove this line.
Don Olmstead
Comment 13
2020-02-26 13:23:37 PST
Created
attachment 391774
[details]
Patch Patch for landing
WebKit Commit Bot
Comment 14
2020-02-26 15:27:23 PST
Comment on
attachment 391774
[details]
Patch Clearing flags on attachment: 391774 Committed
r257521
: <
https://trac.webkit.org/changeset/257521
>
WebKit Commit Bot
Comment 15
2020-02-26 15:27:26 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 16
2020-02-26 15:28:13 PST
<
rdar://problem/59824199
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug