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-25454] performance enhancement at TRACE ON (#5313) #5964

Open
wants to merge 1 commit into
base: release/10.2
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
1 change: 1 addition & 0 deletions cs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ target_include_directories(cubridcs PRIVATE ${CMAKE_SOURCE_DIR}/src/heaplayers/u
if(UNIX)
target_link_libraries(cubridcs LINK_PRIVATE -Wl,-whole-archive cas ${EP_LIBS} -Wl,-no-whole-archive)
target_link_libraries(cubridcs LINK_PUBLIC ${CURSES_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
target_link_libraries(cubridcs LINK_PUBLIC rt)
else(UNIX)
target_link_libraries(cubridcs LINK_PRIVATE cas ${EP_LIBS})
endif(UNIX)
Expand Down
1 change: 1 addition & 0 deletions cubrid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ target_include_directories(cubrid PRIVATE ${CMAKE_SOURCE_DIR}/src/heaplayers/uti
if(UNIX)
target_link_libraries(cubrid LINK_PRIVATE -Wl,-whole-archive ${EP_LIBS} -Wl,-no-whole-archive)
target_link_libraries(cubrid LINK_PUBLIC ${CURSES_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
target_link_libraries(cubrid PUBLIC rt)
else(UNIX)
target_link_libraries(cubrid LINK_PRIVATE ${EP_LIBS})
endif(UNIX)
Expand Down
1 change: 1 addition & 0 deletions sa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ if(UNIX)
# find out what this means:
# target_link_libraries(cubridsa LINK_PRIVATE -Wl,-whole-archive cas ${EP_LIBS} -Wl,-no-whole-archive)
target_link_libraries(cubridsa LINK_PUBLIC ${CURSES_LIBRARIES} ${CMAKE_DL_LIBS})
target_link_libraries(cubridsa PUBLIC rt)
endif(UNIX)

add_dependencies(cubridsa gen_csql_grammar gen_csql_lexer gen_loader_grammar gen_loader_lexer)
Expand Down
20 changes: 18 additions & 2 deletions src/base/perf_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

#if defined (SERVER_MODE)
#include "connection_error.h"
#endif /* SERVER_MODE */
#endif

#if !defined(SERVER_MODE)
#define pthread_mutex_init(a, b)
Expand Down Expand Up @@ -1019,8 +1019,24 @@ UINT64
perfmon_get_from_statistic (THREAD_ENTRY * thread_p, const int statistic_id)
{
UINT64 *stats;
int tran_index;

tran_index = LOG_FIND_THREAD_TRAN_INDEX (thread_p);
assert (tran_index >= 0);

if (tran_index >= pstat_Global.n_trans)
{
return 0;
}

/* This routine is called from the query execute scan routine in TRACE ON state.
* Therefore, there is no need to call perfmon_get_peek_stats,
* which retrieves overall statistical information,
* because the server's overall statistical information is not needed,
* and only I/O fetch and time information are needed.
*/
stats = pstat_Global.tran_stats[tran_index];

stats = perfmon_server_get_stats (thread_p);
if (stats != NULL)
{
int offset = pstat_Metadata[statistic_id].start_offset;
Expand Down
8 changes: 8 additions & 0 deletions src/base/tsc_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,15 @@ tsc_getticks (TSC_TICKS * tck)
}
else
{
#if defined (WINDOWS)
gettimeofday (&(tck->tv), NULL);
#else
struct timespec ts;
/* replace gettimeofday with clock_gettime for performance */
clock_gettime (CLOCK_REALTIME_COARSE, &ts);
tck->tv.tv_sec = ts.tv_sec;
tck->tv.tv_usec = ts.tv_nsec / 1000;
#endif
}
return;
}
Expand Down
7 changes: 5 additions & 2 deletions src/base/tsc_timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
do { \
(total).tv_usec += (diff).tv_usec; \
(total).tv_sec += (diff).tv_sec; \
(total).tv_sec += (total).tv_usec / 1000000; \
(total).tv_usec %= 1000000; \
if ((total).tv_usec >= 1000000) \
{ \
(total).tv_sec++; \
(total).tv_usec -= 1000000; \
} \
} while (0)

typedef UINT64 TSC_UINT64;
Expand Down
1 change: 1 addition & 0 deletions util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ target_compile_definitions(csql PRIVATE ${COMMON_DEFS})
target_include_directories(csql PRIVATE ${EP_INCLUDES})
if(UNIX)
target_link_libraries(csql LINK_PRIVATE ${CMAKE_DL_LIBS})
target_link_libraries(csql LINK_PUBLIC rt)
else(UNIX)
target_compile_definitions(csql PRIVATE _CONSOLE)
target_link_libraries(csql LINK_PRIVATE ws2_32)
Expand Down