Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to specify stack size to pthread_create #2073

Merged
merged 18 commits into from
Nov 22, 2024

Conversation

sirknightj
Copy link
Contributor

@sirknightj sirknightj commented Oct 29, 2024

What was changed?

  • See Thread stack sizes #1924 and Default stack size change and Rolling buffer config rework #2011 for the original PRs.
  • Add an option KVS_STACK_SIZE to specify the thread stack size of threads. By default, THREAD_CREATE (defined in PIC, which calls pthread_create), will use the system default settings (ulimit -s). These changes allow the user to set the stack sizes for threads created by the SDK without needing to change system defaults.
  • For backwards compatibility, if the option is not present, the SDK will continue to use the system default stack sizes.
  • Users can also control stack size for individual threads by using THREAD_CREATE_WITH_PARAMS API instead of THREAD_CREATE. (Added in PIC#243)

Why was it changed?

  • Reduce unused stack memory.

How was it changed?

  • KVS_STACK_SIZE option will get passed to kvsCommonLws (Producer-C), who forwards it to PIC, which contains the thread creation definitions.

What testing was done for the changes?

  • See the original pull requests for more details.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

jdelapla and others added 3 commits October 29, 2024 12:57
* Working reduced stack sizes. Adjusted default stack size to 64kb, moved Offer/Answer messages to be on heap instead of stack

* Custom stack sizes in Common.c

* CMake flag working and added to README

* Adjust connection listener stack size for datachannels

* Change stack size for media related threads and connection listener again. Add README notes to highlight this potential problem threads for other applications

* Unnecessary memset

* nit picks

* Update CMakeLists.txt

fix for ZLIB since it is not found on Windows, that way we can verify the stack side change on Windows platform, previously it was not running at all due to build fail.

* Update CMake dependency back to develop since the other PRs have merged

* README update

---------

Co-authored-by: Hassan Sahibzada <[email protected]>
Co-authored-by: Divya Sampath Kumar <[email protected]>
@sirknightj
Copy link
Contributor Author

Perfect

 cmake .. -DKVS_STACK_SIZE=65536asdf -DBUILD_TEST=ON -DUSE_OPENSSL=OFF -DUSE_MBEDTLS=ON
CMake Error at CMakeLists.txt:64 (message):
  KVS_STACK_SIZE must be a numeric value, but got: 65536asdf

-- Configuring incomplete, errors occurred!

@sirknightj
Copy link
Contributor Author

Need to change from develop to v1.5.4 after it's released.

@sirknightj sirknightj marked this pull request as ready for review November 22, 2024 17:49
README.md Outdated Show resolved Hide resolved
@sirknightj sirknightj merged commit fe0a6d9 into develop Nov 22, 2024
28 checks passed
@sirknightj sirknightj deleted the stack-size-option branch November 22, 2024 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants