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

[CBRD-24462] Improve the logic that determines the number of threads to be used when running the backupdb utility, and additionally print the number of threads specified by administrator #5537

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
9 changes: 4 additions & 5 deletions src/storage/external_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "server_support.h"
#include "thread_entry_task.hpp"
#include "thread_manager.hpp" // for thread_get_thread_entry_info and thread_sleep
#include "thread_worker_pool.hpp"

#include <functional>
// XXX: SHOULD BE THE LAST INCLUDE HEADER
Expand Down Expand Up @@ -1489,12 +1490,10 @@ sort_listfile (THREAD_ENTRY * thread_p, INT16 volid, int est_inp_pg_cnt, SORT_GE
#if defined(SERVER_MODE)
if (prm_enable_sort_parallel == true)
{
/* TODO - calc n, 2^^n get the number of CPUs TODO - fileio_os_sysconf really get #cores instead of #CPUs -
YeunjunLee marked this conversation as resolved.
Show resolved Hide resolved
* NEED MORE CONSIDERATION */
num_cpus = fileio_os_sysconf ();
num_cpus = cubthread::system_core_count ();

sort_param->px_height_max = (int) sqrt ((double) num_cpus); /* n */
sort_param->px_array_size = num_cpus; /* 2^^n */
sort_param->px_height_max = (int) sqrt ((double) num_cpus);
sort_param->px_array_size = num_cpus;

assert_release (sort_param->px_array_size == pow ((double) 2, (double) sort_param->px_height_max));
}
Expand Down
9 changes: 7 additions & 2 deletions src/storage/file_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
#include "log_common_impl.h"
#include "log_volids.hpp"
#include "fault_injection.h"
#include "thread_worker_pool.hpp"

#if defined (SERVER_MODE)
#include "vacuum.h"
#endif /* SERVER_MODE */
Expand Down Expand Up @@ -6644,15 +6646,16 @@ fileio_initialize_backup_thread (FILEIO_BACKUP_SESSION * session_p, int num_thre
}

/* get the number of CPUs */
num_cpus = fileio_os_sysconf ();
num_cpus = cubthread::system_core_count ();

/* check for the upper bound of threads */
if (num_threads == FILEIO_BACKUP_NUM_THREADS_AUTO)
{
thread_info_p->num_threads = num_cpus;
}
else
{
thread_info_p->num_threads = MIN (num_threads, num_cpus * 2);
thread_info_p->num_threads = MIN (num_threads, num_cpus);
}
thread_info_p->num_threads = MIN (thread_info_p->num_threads, NUM_NORMAL_TRANS);
#else /* SERVER_MODE */
Expand Down Expand Up @@ -11534,6 +11537,7 @@ fileio_lock_region (int fd, int cmd, int type, off_t offset, int whence, off_t l
}
#endif /* !WINDOWS */

#if defined(ENABLE_UNUSED_FUNCTION)
#if defined(SERVER_MODE)
/*
* fileio_os_sysconf () -
Expand Down Expand Up @@ -11563,6 +11567,7 @@ fileio_os_sysconf (void)
return (nprocs > 1) ? (int) nprocs : 1;
}
#endif /* SERVER_MODE */
#endif

/*
* fileio_initialize_res () -
Expand Down
2 changes: 2 additions & 0 deletions src/storage/file_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,11 @@ extern int fileio_symlink (const char *src, const char *dest, int overwrite);
extern int fileio_set_permission (const char *vlabel);
#endif /* !WINDOWS */

#if defined(ENABLE_UNUSED_FUNCTION)
#if defined(SERVER_MODE)
int fileio_os_sysconf (void);
#endif /* SERVER_MODE */
#endif

/* flush control related */
extern int fileio_flush_control_initialize (void);
Expand Down
3 changes: 2 additions & 1 deletion src/transaction/log_page_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -7865,7 +7865,8 @@ logpb_backup (THREAD_ENTRY * thread_p, int num_perm_vols, const char *allbackup_
}
fprintf (session.verbose_fp, "[ Database(%s) %s Backup start ]\n\n", boot_db_name (), str_tmp);

fprintf (session.verbose_fp, "- num-threads: %d\n\n", session.read_thread_info.num_threads);
fprintf (session.verbose_fp, "- num-threads: %d (user-requested: %d)\n\n", session.read_thread_info.num_threads,
num_threads);

if (zip_method == FILEIO_ZIP_NONE_METHOD)
{
Expand Down
Loading