@@ -46,6 +46,7 @@ Created 11/11/1995 Heikki Tuuri
46
46
#include " ibuf0ibuf.h"
47
47
#include " log0log.h"
48
48
#include " os0file.h"
49
+ #include " os0sync.h"
49
50
#include " trx0sys.h"
50
51
#include " srv0mon.h"
51
52
#include " mysql/plugin.h"
@@ -1934,11 +1935,16 @@ buf_flush_LRU(
1934
1935
/* JAN: TODO: */
1935
1936
/* ******************************************************************/ /* */
1936
1937
extern int is_pgcomp_wrk_init_done (void );
1937
- extern int pgcomp_flush_work_items (int buf_pool_inst, int *pages_flushed,
1938
- int flush_type, int min_n, unsigned long long lsn_limit);
1938
+ extern int pgcomp_flush_work_items (
1939
+ int buf_pool_inst,
1940
+ int *pages_flushed,
1941
+ enum buf_flush flush_type,
1942
+ int min_n,
1943
+ lsn_t lsn_limit);
1939
1944
1940
1945
#define MT_COMP_WATER_MARK 50
1941
1946
1947
+ #ifdef UNIV_DEBUG
1942
1948
#include < time.h>
1943
1949
int timediff (struct timeval *g_time, struct timeval *s_time, struct timeval *d_time)
1944
1950
{
@@ -1959,8 +1965,15 @@ int timediff(struct timeval *g_time, struct timeval *s_time, struct timeval *d_t
1959
1965
1960
1966
return 0 ;
1961
1967
}
1968
+ #endif
1969
+
1970
+ static os_fast_mutex_t pgcomp_mtx;
1971
+
1972
+ void pgcomp_init (void )
1973
+ {
1974
+ os_fast_mutex_init (PFS_NOT_INSTRUMENTED, &pgcomp_mtx);
1975
+ }
1962
1976
1963
- static pthread_mutex_t pgcomp_mtx = PTHREAD_MUTEX_INITIALIZER;
1964
1977
/* ******************************************************************/ /* *
1965
1978
Multi-threaded version of buf_flush_list
1966
1979
*/
@@ -1983,7 +1996,10 @@ pgcomp_buf_flush_list(
1983
1996
{
1984
1997
ulint i;
1985
1998
bool success = true ;
1999
+ #ifdef UNIV_DEBUG
1986
2000
struct timeval p_start_time, p_end_time, d_time;
2001
+ #endif
2002
+ int cnt_flush[MTFLUSH_MAX_WORKER];
1987
2003
1988
2004
if (n_processed) {
1989
2005
*n_processed = 0 ;
@@ -2001,96 +2017,34 @@ pgcomp_buf_flush_list(
2001
2017
#ifdef UNIV_DEBUG
2002
2018
gettimeofday (&p_start_time, 0x0 );
2003
2019
#endif
2004
- if (is_pgcomp_wrk_init_done () && (min_n > MT_COMP_WATER_MARK)) {
2005
- int cnt_flush[32 ];
2006
-
2007
- // stack_trace();
2008
- pthread_mutex_lock (&pgcomp_mtx);
2009
- // gettimeofday(&p_start_time, 0x0);
2010
- // fprintf(stderr, "Calling into wrk-pgcomp [min:%lu]", min_n);
2011
- pgcomp_flush_work_items (srv_buf_pool_instances,
2012
- cnt_flush, BUF_FLUSH_LIST,
2013
- min_n, lsn_limit);
2014
-
2015
- for (i = 0 ; i < srv_buf_pool_instances; i++) {
2016
- if (n_processed) {
2017
- *n_processed += cnt_flush[i];
2018
- }
2019
- if (cnt_flush[i]) {
2020
- MONITOR_INC_VALUE_CUMULATIVE (
2021
- MONITOR_FLUSH_BATCH_TOTAL_PAGE,
2022
- MONITOR_FLUSH_BATCH_COUNT,
2023
- MONITOR_FLUSH_BATCH_PAGES,
2024
- cnt_flush[i]);
2025
-
2026
- }
2027
- }
2028
-
2029
- pthread_mutex_unlock (&pgcomp_mtx);
2020
+ os_fast_mutex_lock (&pgcomp_mtx);
2021
+ pgcomp_flush_work_items (srv_buf_pool_instances,
2022
+ cnt_flush, BUF_FLUSH_LIST,
2023
+ min_n, lsn_limit);
2024
+ os_fast_mutex_unlock (&pgcomp_mtx);
2030
2025
2031
- #ifdef UNIV_DEBUG
2032
- gettimeofday (&p_end_time, 0x0 );
2033
- timediff (&p_end_time, &p_start_time, &d_time);
2034
- fprintf (stderr, " [1] [*n_processed: (min:%lu)%lu %llu usec]\n " , (
2035
- min_n * srv_buf_pool_instances), *n_processed,
2036
- (unsigned long long )(d_time.tv_usec +(d_time.tv_sec *1000000 )));
2037
- #endif
2038
- return (success);
2039
- }
2040
- /* Flush to lsn_limit in all buffer pool instances */
2041
2026
for (i = 0 ; i < srv_buf_pool_instances; i++) {
2042
- buf_pool_t * buf_pool;
2043
- ulint page_count = 0 ;
2044
-
2045
- buf_pool = buf_pool_from_array (i);
2046
-
2047
- if (!buf_flush_start (buf_pool, BUF_FLUSH_LIST)) {
2048
- /* We have two choices here. If lsn_limit was
2049
- specified then skipping an instance of buffer
2050
- pool means we cannot guarantee that all pages
2051
- up to lsn_limit has been flushed. We can
2052
- return right now with failure or we can try
2053
- to flush remaining buffer pools up to the
2054
- lsn_limit. We attempt to flush other buffer
2055
- pools based on the assumption that it will
2056
- help in the retry which will follow the
2057
- failure. */
2058
- success = false ;
2059
-
2060
- continue ;
2061
- }
2062
-
2063
- page_count = buf_flush_batch (
2064
- buf_pool, BUF_FLUSH_LIST, min_n, lsn_limit);
2065
-
2066
- buf_flush_end (buf_pool, BUF_FLUSH_LIST);
2067
-
2068
- buf_flush_common (BUF_FLUSH_LIST, page_count);
2069
-
2070
2027
if (n_processed) {
2071
- *n_processed += page_count ;
2028
+ *n_processed += cnt_flush[i] ;
2072
2029
}
2073
-
2074
- if (page_count) {
2030
+ if (cnt_flush[i]) {
2075
2031
MONITOR_INC_VALUE_CUMULATIVE (
2076
2032
MONITOR_FLUSH_BATCH_TOTAL_PAGE,
2077
2033
MONITOR_FLUSH_BATCH_COUNT,
2078
2034
MONITOR_FLUSH_BATCH_PAGES,
2079
- page_count );
2035
+ cnt_flush[i] );
2080
2036
}
2081
2037
}
2082
-
2083
- #if UNIV_DEBUG
2038
+ #ifdef UNIV_DEBUG
2084
2039
gettimeofday (&p_end_time, 0x0 );
2085
2040
timediff (&p_end_time, &p_start_time, &d_time);
2086
-
2087
- fprintf (stderr, " [2] [*n_processed: (min:%lu)%lu %llu usec]\n " , (
2088
- min_n * srv_buf_pool_instances), *n_processed,
2089
- (unsigned long long )(d_time.tv_usec +(d_time.tv_sec *1000000 )));
2041
+ fprintf (stderr, " %s: [1] [*n_processed: (min:%lu)%lu %llu usec]\n " ,
2042
+ __FUNCTION__, (min_n * srv_buf_pool_instances), *n_processed,
2043
+ (unsigned long long )(d_time.tv_usec +(d_time.tv_sec *1000000 )));
2090
2044
#endif
2091
2045
return (success);
2092
2046
}
2093
- # endif
2047
+
2094
2048
/* JAN: TODO: END: */
2095
2049
2096
2050
/* ******************************************************************/ /* *
@@ -2292,18 +2246,21 @@ ulint
2292
2246
pgcomp_buf_flush_LRU_tail (void )
2293
2247
/* ====================*/
2294
2248
{
2249
+ #ifdef UNIV_DEBUG
2295
2250
struct timeval p_start_time, p_end_time, d_time;
2251
+ #endif
2296
2252
ulint total_flushed=0 , i=0 ;
2297
2253
int cnt_flush[32 ];
2298
2254
2299
- #if UNIV_DEBUG
2255
+ #ifdef UNIV_DEBUG
2300
2256
gettimeofday (&p_start_time, 0x0 );
2301
2257
#endif
2302
- assert (is_pgcomp_wrk_init_done ());
2258
+ ut_ad (is_pgcomp_wrk_init_done ());
2303
2259
2304
- pthread_mutex_lock (&pgcomp_mtx);
2260
+ os_fast_mutex_lock (&pgcomp_mtx);
2305
2261
pgcomp_flush_work_items (srv_buf_pool_instances,
2306
2262
cnt_flush, BUF_FLUSH_LRU, srv_LRU_scan_depth, 0 );
2263
+ os_fast_mutex_unlock (&pgcomp_mtx);
2307
2264
2308
2265
for (i = 0 ; i < srv_buf_pool_instances; i++) {
2309
2266
if (cnt_flush[i]) {
@@ -2317,8 +2274,6 @@ pgcomp_buf_flush_LRU_tail(void)
2317
2274
}
2318
2275
}
2319
2276
2320
- pthread_mutex_unlock (&pgcomp_mtx);
2321
-
2322
2277
#if UNIV_DEBUG
2323
2278
gettimeofday (&p_end_time, 0x0 );
2324
2279
timediff (&p_end_time, &p_start_time, &d_time);
@@ -2894,6 +2849,7 @@ buf_flush_validate(
2894
2849
}
2895
2850
2896
2851
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
2852
+ #endif /* !UNIV_HOTBACKUP */
2897
2853
2898
2854
2899
2855
#ifdef UNIV_DEBUG
0 commit comments