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

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMake/Dependencies/libkvsCommonLws-CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ExternalProject_Add(libkvsCommonLws-download
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DUSE_OPENSSL=${USE_OPENSSL}
-DUSE_MBEDTLS=${USE_MBEDTLS}
-DKVS_DEFAULT_STACK_SIZE=${KVS_DEFAULT_STACK_SIZE}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DBUILD_STATIC=${BUILD_STATIC}
BUILD_ALWAYS TRUE
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ execute_process(
add_definitions(-DSDK_VERSION=\"${GIT_COMMIT_HASH}\")
add_definitions(-DVERSION_STRING=\"${PROJECT_VERSION}\")
add_definitions(-DDETECTED_GIT_HASH)
if(NOT KVS_STACK_SIZE OR KVS_STACK_SIZE STREQUAL "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than checking for an empty string, can we validate that it is a numeric value with something like:

if(KVS_STACK_SIZE MATCHES "^[+-]?[0-9]+$")

Copy link
Contributor Author

@sirknightj sirknightj Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking of removing this section actually. Because when I ran Producer-C with the thread stacksize changes, I was able to pass it in via producer-c's CMake command:

Producer-C/build $ cmake .. -DBUILD_DEPENDENCIES=OFF -DKVS_DEFAULT_STACK_SIZE= 524288 -DCONSTRAINED_DEVICE=ON
...
CMake Error at dependency/libkvspic/kvspic-src/CMakeLists.txt:62 (message):
  Conflicting parameters: KVS_DEFAULT_STACK_SIZE and CONSTRAINED_DEVICE
  cannot both be set.

-- Configuring incomplete, errors occurred!

Which would indicate this section is redundant.

message(STATUS "Setting default stack size to platform specific stack size")
set(KVS_DEFAULT_STACK_SIZE 0)
add_definitions(-DKVS_DEFAULT_STACK_SIZE=0)
else()
message(STATUS "Setting default stack size to provided value")
set(KVS_DEFAULT_STACK_SIZE ${KVS_STACK_SIZE})
add_definitions(-DKVS_DEFAULT_STACK_SIZE=${KVS_STACK_SIZE})
endif()

if(NOT OPEN_SRC_INSTALL_PREFIX OR OPEN_SRC_INSTALL_PREFIX STREQUAL "")
set(OPEN_SRC_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/open-source" CACHE PATH "Libraries will be downloaded and built in this directory.")
Expand Down Expand Up @@ -254,6 +263,7 @@ set(BUILD_ARGS
-DBUILD_STATIC=${BUILD_STATIC_LIBS}
-DUSE_OPENSSL=${USE_OPENSSL}
-DUSE_MBEDTLS=${USE_MBEDTLS}
-DKVS_DEFAULT_STACK_SIZE=${KVS_DEFAULT_STACK_SIZE}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
build_dependency(kvsCommonLws ${BUILD_ARGS})

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ You can pass the following options to `cmake ..`.
* `-DUNDEFINED_BEHAVIOR_SANITIZER` -- Build with UndefinedBehaviorSanitizer
* `-DCMAKE_BUILD_TYPE` -- Build Release/Debug libraries. By default, the SDK generates Release build. The standard options are listed [here](https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#default-and-custom-configurations)
* `-DLINK_PROFILER` -- Link with gperftools (available profiler options are listed [here](https://github.com/gperftools/gperftools))
* `-DKVS_STACK_SIZE` -- Default stack size for threads created using THREAD_CREATE()
* `-DPKG_CONFIG_EXECUTABLE` -- Set pkg config path. This might be required to find gstreamer's pkg config specifically on Windows.
* `-DENABLE_KVS_THREADPOOL` -- Enable the KVS threadpool which is off by default.

Expand Down Expand Up @@ -571,6 +572,9 @@ CHK_STATUS(peerConnectionOnSenderBandwidthEstimation(pSampleStreamingSession->pP
By default, our SDK enables TWCC listener. The SDK has a sample implementation to integrate TWCC into the Gstreamer pipeline via the `sampleSenderBandwidthEstimationHandler` callback. To get more details, look for this specific callback.


### Thread stack sizes
The default thread stack size for the KVS WebRTC SDK is the system's default. You can change it for all the threads using `-DKVS_STACK_SIZE` CMake flag, and adjust stack sizes for individual threads with `THREAD_CREATE_WITH_PARAMS`. Notable stack sizes that may need to be changed for your specific application will be the ConnectionListener Receiver thread and the media sender threads. Please modify the stack sizes for these media dependent threads to be suitable for the media your application is processing.

### Setting ICE related timeouts

There are some default timeout values set for different steps in ICE in the [KvsRtcConfiguration](https://awslabs.github.io/amazon-kinesis-video-streams-webrtc-sdk-c/structKvsRtcConfiguration.html). These are configurable in the application. While the defaults are generous, there could be applications that might need more flexibility to improve chances of connection establishment because of poor network.
Expand Down
Loading