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

Create a CMake flag to enable KVS Threadpool #1806

Merged
merged 33 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
cb3d148
create a cmake flag to enable kvs threadpool and pass it to the SDK
niyatim23 Sep 13, 2023
96a7e15
create a cmake flag to enable kvs threadpool and pass it to the SDK
niyatim23 Sep 13, 2023
937a024
Merge branch 'cmake_flag_threadpool' of github.com:awslabs/amazon-kin…
niyatim23 Sep 13, 2023
ab8b6ba
missed one spot
niyatim23 Sep 13, 2023
a4a8ceb
add debug logs to fix tests
niyatim23 Sep 13, 2023
9dcaf87
fix tests attempt 1 - initialize min and max for the threadpool
niyatim23 Sep 13, 2023
7a7516d
silly syntax error
niyatim23 Sep 13, 2023
f42890f
setting min value for threadpool in test fixture
jdelapla Sep 13, 2023
6afbb04
fix clang format
niyatim23 Sep 13, 2023
541b6d7
fixing client info initializations in other tests
jdelapla Sep 13, 2023
9112ee6
Merge branch 'cmake_flag_threadpool' of github.com:awslabs/amazon-kin…
jdelapla Sep 13, 2023
d0c755c
More initializations for tests
jdelapla Sep 13, 2023
13eb286
Add sleep at end of tests to avoid false flags of memory leaks as thr…
jdelapla Sep 13, 2023
2e349d3
add tsan supp
niyatim23 Sep 14, 2023
7d2158f
tsan sup -2
niyatim23 Sep 14, 2023
d5365fb
missing # in details in supp
niyatim23 Sep 14, 2023
3944a39
more sleeps to allow threadpool to close out all threads
jdelapla Sep 14, 2023
9566313
Merge branch 'cmake_flag_threadpool' of github.com:awslabs/amazon-kin…
jdelapla Sep 14, 2023
4d5ff0c
add suppressions to threadpool
niyatim23 Sep 14, 2023
55a8905
add suppressions to threadpool push
niyatim23 Sep 14, 2023
140a1a0
race:pthread_mutex_unlock
niyatim23 Sep 15, 2023
127cdc0
add test name instead of threadpool function names
niyatim23 Sep 15, 2023
bbed345
rename the cmake var to control only signaling threadpool
niyatim23 Sep 15, 2023
02fa0ae
try without . in the test name
niyatim23 Sep 15, 2023
3d3146d
use mutex instead of race
niyatim23 Sep 15, 2023
22b7001
remove mutex:lock
niyatim23 Sep 15, 2023
a55f878
add back mutex:lock
niyatim23 Sep 15, 2023
8ba3431
deadlock:iceServerConfigRefreshConnectedAuthExpiration
niyatim23 Sep 15, 2023
cda3a2f
deadlock:createSignalingSync
niyatim23 Sep 18, 2023
ba66ce6
Update producer dependency to include modified threadpool teardown
jdelapla Sep 18, 2023
69a9be7
Remove previous suppressions
jdelapla Sep 18, 2023
33b4b39
cleanup + rename
niyatim23 Sep 19, 2023
6add1bd
update git tag
niyatim23 Sep 20, 2023
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
2 changes: 1 addition & 1 deletion CMake/Dependencies/libkvsCommonLws-CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include(ExternalProject)

ExternalProject_Add(libkvsCommonLws-download
GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-producer-c.git
GIT_TAG 178109a5dbfc5288ba5cf7fab1dc1afd5e2e182b
GIT_TAG 75d53abcbac214e19d14afcb61dbf533056b560c
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX}
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ option(BUILD_LIBSRTP_HOST_PLATFORM "If buildng LibSRTP what is the current platf
option(BUILD_LIBSRTP_DESTINATION_PLATFORM "If buildng LibSRTP what is the destination platform" OFF)
option(BUILD_SAMPLE "Build available samples" ON)
option(ENABLE_DATA_CHANNEL "Enable support for data channel" ON)
option(ENABLE_KVS_THREADPOOL "Enable support for KVS thread pool in signaling" ON)
option(INSTRUMENTED_ALLOCATORS "Enable memory instrumentation" OFF)

# Developer Flags
Expand Down Expand Up @@ -98,6 +99,10 @@ message(STATUS "dependencies install path is ${OPEN_SRC_INSTALL_PREFIX}")
add_definitions(-DKVS_CA_CERT_PATH="${CMAKE_SOURCE_DIR}/certs/cert.pem")
add_definitions(-DCMAKE_DETECTED_CACERT_PATH)

if (ENABLE_KVS_THREADPOOL)
add_definitions(-DENABLE_KVS_THREADPOOL)
endif()

if(USE_OPENSSL)
add_definitions(-DKVS_USE_OPENSSL)
elseif(USE_MBEDTLS)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,7 @@ To build on a 32-bit Raspbian GNU/Linux 11 on 64-bit hardware, the OpenSSL libra

### Threadpool for Signaling Channel messages
The threadpool is enabled by default, and starts with 3 threads that it can increase up to 5 if all 3 are actively in use. To change these values to better match the resources of your use case
please edit samples/Samples.h defines `KVS_SIGNALING_THREADPOOL_MIN` and `KVS_SIGNALING_THREADPOOL_MAX`. You can also disable the threadpool to instead create and detach each thread
to handle signaling messages by commenting out `KVS_USE_SIGNALING_CHANNEL_THREADPOOL`.
please edit samples/Samples.h defines `KVS_SIGNALING_THREADPOOL_MIN` and `KVS_SIGNALING_THREADPOOL_MAX`. You can also disable the threadpool to instead create and detach each thread to handle signaling messages by disabling the flag `-DENABLE_KVS_THREADPOOL` while building with cmake.

## Documentation
All Public APIs are documented in our [Include.h](https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c/blob/master/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h), we also generate a [Doxygen](https://awslabs.github.io/amazon-kinesis-video-streams-webrtc-sdk-c/) each commit for easier navigation.
Expand Down
3 changes: 0 additions & 3 deletions samples/Samples.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ extern "C" {
#define KVS_SIGNALING_THREADPOOL_MIN 3
#define KVS_SIGNALING_THREADPOOL_MAX 5

// comment out this line to disable the feature
#define KVS_USE_SIGNALING_CHANNEL_THREADPOOL 1

/* Uncomment the following line in order to enable IoT credentials checks in the provided samples */
// #define IOT_CORE_ENABLE_CREDENTIALS 1

Expand Down
2 changes: 1 addition & 1 deletion src/source/Signaling/LwsApiCalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2011,7 +2011,7 @@ STATUS receiveLwsMessage(PSignalingClient pSignalingClient, PCHAR pMessage, UINT
DLOGW("Failed to validate the ICE server configuration received with an Offer");
}

#ifdef KVS_USE_SIGNALING_CHANNEL_THREADPOOL
#ifdef ENABLE_KVS_THREADPOOL
CHK_STATUS(threadpoolPush(pSignalingClient->pThreadpool, receiveLwsMessageWrapper, (PVOID) pSignalingMessageWrapper));
#else
// Issue the callback on a separate thread
Expand Down
6 changes: 4 additions & 2 deletions src/source/Signaling/Signaling.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ STATUS createSignalingSync(PSignalingClientInfoInternal pClientInfo, PChannelInf
CHK_STATUS(createValidateChannelInfo(pChannelInfo, &pSignalingClient->pChannelInfo));
CHK_STATUS(validateSignalingCallbacks(pSignalingClient, pCallbacks));
CHK_STATUS(validateSignalingClientInfo(pSignalingClient, pClientInfo));
#ifdef KVS_USE_SIGNALING_CHANNEL_THREADPOOL
#ifdef ENABLE_KVS_THREADPOOL
DLOGD("Going to crate the threadpool for signaling");
CHK_STATUS(threadpoolCreate(&pSignalingClient->pThreadpool, pClientInfo->signalingClientInfo.signalingMessagesMinimumThreads,
pClientInfo->signalingClientInfo.signalingMessagesMaximumThreads));
DLOGD("Successfully created the threadpool for signaling");
#endif

pSignalingClient->version = SIGNALING_CLIENT_CURRENT_VERSION;
Expand Down Expand Up @@ -225,7 +227,7 @@ STATUS freeSignaling(PSignalingClient* ppSignalingClient)

hashTableFree(pSignalingClient->diagnostics.pEndpointToClockSkewHashMap);

#ifdef KVS_USE_SIGNALING_CHANNEL_THREADPOOL
#ifdef ENABLE_KVS_THREADPOOL
threadpoolFree(pSignalingClient->pThreadpool);
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/source/Signaling/Signaling.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ typedef struct {
UINT64 deleteTime;
UINT64 connectTime;

#ifdef KVS_USE_SIGNALING_CHANNEL_THREADPOOL
#ifdef ENABLE_KVS_THREADPOOL
PThreadpool pThreadpool;
#endif
UINT64 offerTime;
Expand Down
Loading