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

GTEST: reduce stack usage in tests #10131

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

michal-shalev
Copy link
Contributor

What?

This PR reduces stack memory usage by converting stack allocations to heap in various UCX tests.

Why?

Customers with limited stack sizes have recently experienced stack overflow issues when running UCX.
The goal is to ensure that the entire UCX runs within a defined stack size threshold. By reducing the stack frame size in tests, this change helps in testing the runtime stack usage, ensuring that it starts within the threshold.

How?

This PR reduces stack usage by deferring complex logic to separate helper functions, minimizing the stack frame size during test execution.

@michal-shalev michal-shalev changed the title Reduce stack usage in tests GTEST: reduce stack usage in tests Sep 6, 2024
@openucx openucx deleted a comment from azure-pipelines bot Sep 16, 2024
ivankochin
ivankochin previously approved these changes Sep 18, 2024
@@ -353,6 +353,39 @@ void test_thread::mem_event(ucm_event_type_t event_type, ucm_event_t *event)
pthread_mutex_unlock(&m_stats_lock);
}

static void* perform_mmap(size_t size, char fill_value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
static void* perform_mmap(size_t size, char fill_value) {
static void *perform_mmap(size_t size, char fill_value) {


typedef ucs_status_t (*ucp_dispatch_func_t)(ucx_perf_context_t *perf);

static ucp_dispatch_func_t dispatchers[] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO better use std::vector here

@@ -301,7 +301,7 @@ class test_thread {
private:
typedef std::pair<void*, void*> range;

bool is_ptr_in_range(void *ptr, size_t size, const std::vector<range> &ranges) {
bool __attribute__((noinline)) is_ptr_in_range(void *ptr, size_t size, const std::vector<range> &ranges) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can use UCS_F_NOINLINE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants