@@ -293,7 +293,7 @@ UNIV_INTERN double srv_adaptive_flushing_lwm = 10.0;
293
293
UNIV_INTERN ulong srv_flushing_avg_loops = 30 ;
294
294
295
295
/* The number of purge threads to use.*/
296
- UNIV_INTERN ulong srv_n_purge_threads = 1 ;
296
+ UNIV_INTERN ulong srv_n_purge_threads;
297
297
298
298
/* the number of pages to purge in one batch */
299
299
UNIV_INTERN ulong srv_purge_batch_size = 20 ;
@@ -490,16 +490,16 @@ UNIV_INTERN uint srv_simulate_comp_failures = 0;
490
490
491
491
/* * Acquire the system_mutex. */
492
492
#define srv_sys_mutex_enter () do { \
493
- mutex_enter (&srv_sys-> mutex ); \
493
+ mutex_enter (&srv_sys. mutex ); \
494
494
} while (0 )
495
495
496
496
/* * Test if the system mutex is owned. */
497
- #define srv_sys_mutex_own () (mutex_own(&srv_sys-> mutex) \
497
+ #define srv_sys_mutex_own () (mutex_own(&srv_sys. mutex) \
498
498
&& !srv_read_only_mode)
499
499
500
500
/* * Release the system mutex. */
501
501
#define srv_sys_mutex_exit () do { \
502
- mutex_exit (&srv_sys-> mutex ); \
502
+ mutex_exit (&srv_sys. mutex ); \
503
503
} while (0 )
504
504
505
505
#define fetch_lock_wait_timeout (trx ) \
@@ -591,7 +591,7 @@ struct srv_sys_t{
591
591
ulint n_sys_threads; /* !< size of the sys_threads
592
592
array */
593
593
594
- srv_slot_t * sys_threads; /* !< server thread table;
594
+ srv_slot_t sys_threads[ 32 + 1 ]; /* !< server thread table;
595
595
os_event_set() and
596
596
os_event_reset() on
597
597
sys_threads[]->event are
@@ -611,7 +611,7 @@ struct srv_sys_t{
611
611
UNIV_INTERN ib_mutex_t server_mutex;
612
612
#endif /* !HAVE_ATOMIC_BUILTINS */
613
613
614
- static srv_sys_t * srv_sys = NULL ;
614
+ static srv_sys_t srv_sys;
615
615
616
616
/* * Event to signal srv_monitor_thread. Not protected by a mutex.
617
617
Set after setting srv_print_innodb_monitor. */
@@ -633,10 +633,10 @@ and/or load it during startup. */
633
633
UNIV_INTERN char srv_buffer_pool_dump_at_shutdown = FALSE ;
634
634
UNIV_INTERN char srv_buffer_pool_load_at_startup = FALSE ;
635
635
636
- /* * Slot index in the srv_sys-> sys_threads array for the purge thread. */
636
+ /* * Slot index in the srv_sys. sys_threads array for the purge thread. */
637
637
static const ulint SRV_PURGE_SLOT = 1 ;
638
638
639
- /* * Slot index in the srv_sys-> sys_threads array for the master thread. */
639
+ /* * Slot index in the srv_sys. sys_threads array for the master thread. */
640
640
static const ulint SRV_MASTER_SLOT = 0 ;
641
641
642
642
/* ********************************************************************/ /* *
@@ -737,21 +737,21 @@ srv_reserve_slot(
737
737
738
738
switch (type) {
739
739
case SRV_MASTER:
740
- slot = &srv_sys-> sys_threads [SRV_MASTER_SLOT];
740
+ slot = &srv_sys. sys_threads [SRV_MASTER_SLOT];
741
741
break ;
742
742
743
743
case SRV_PURGE:
744
- slot = &srv_sys-> sys_threads [SRV_PURGE_SLOT];
744
+ slot = &srv_sys. sys_threads [SRV_PURGE_SLOT];
745
745
break ;
746
746
747
747
case SRV_WORKER:
748
748
/* Find an empty slot, skip the master and purge slots. */
749
- for (slot = &srv_sys-> sys_threads [2 ];
749
+ for (slot = &srv_sys. sys_threads [2 ];
750
750
slot->in_use ;
751
751
++slot) {
752
752
753
- ut_a (slot < &srv_sys-> sys_threads [
754
- srv_sys-> n_sys_threads ]);
753
+ ut_a (slot < &srv_sys. sys_threads [
754
+ srv_sys. n_sys_threads ]);
755
755
}
756
756
break ;
757
757
@@ -767,7 +767,7 @@ srv_reserve_slot(
767
767
768
768
ut_ad (srv_slot_get_type (slot) == type);
769
769
770
- ++srv_sys-> n_threads_active [type];
770
+ ++srv_sys. n_threads_active [type];
771
771
772
772
srv_sys_mutex_exit ();
773
773
@@ -797,27 +797,27 @@ srv_suspend_thread_low(
797
797
case SRV_MASTER:
798
798
/* We have only one master thread and it
799
799
should be the first entry always. */
800
- ut_a (srv_sys-> n_threads_active [type] == 1 );
800
+ ut_a (srv_sys. n_threads_active [type] == 1 );
801
801
break ;
802
802
803
803
case SRV_PURGE:
804
804
/* We have only one purge coordinator thread
805
805
and it should be the second entry always. */
806
- ut_a (srv_sys-> n_threads_active [type] == 1 );
806
+ ut_a (srv_sys. n_threads_active [type] == 1 );
807
807
break ;
808
808
809
809
case SRV_WORKER:
810
810
ut_a (srv_n_purge_threads > 1 );
811
- ut_a (srv_sys-> n_threads_active [type] > 0 );
811
+ ut_a (srv_sys. n_threads_active [type] > 0 );
812
812
break ;
813
813
}
814
814
815
815
ut_a (!slot->suspended );
816
816
slot->suspended = TRUE ;
817
817
818
- ut_a (srv_sys-> n_threads_active [type] > 0 );
818
+ ut_a (srv_sys. n_threads_active [type] > 0 );
819
819
820
- srv_sys-> n_threads_active [type]--;
820
+ srv_sys. n_threads_active [type]--;
821
821
822
822
return (os_event_reset (slot->event ));
823
823
}
@@ -872,7 +872,7 @@ srv_resume_thread(srv_slot_t* slot, ib_int64_t sig_count = 0, bool wait = true,
872
872
ut_ad (slot->suspended );
873
873
874
874
slot->suspended = FALSE ;
875
- ++srv_sys-> n_threads_active [slot->type ];
875
+ ++srv_sys. n_threads_active [slot->type ];
876
876
srv_sys_mutex_exit ();
877
877
return (timeout);
878
878
}
@@ -894,8 +894,8 @@ srv_release_threads(enum srv_thread_type type, ulint n)
894
894
895
895
srv_sys_mutex_enter ();
896
896
897
- for (ulint i = 0 ; i < srv_sys-> n_sys_threads ; i++) {
898
- srv_slot_t * slot = &srv_sys-> sys_threads [i];
897
+ for (ulint i = 0 ; i < srv_sys. n_sys_threads ; i++) {
898
+ srv_slot_t * slot = &srv_sys. sys_threads [i];
899
899
900
900
if (!slot->in_use || srv_slot_get_type (slot) != type) {
901
901
continue ;
@@ -915,7 +915,7 @@ srv_release_threads(enum srv_thread_type type, ulint n)
915
915
should be the first entry always. */
916
916
ut_a (n == 1 );
917
917
ut_a (i == SRV_MASTER_SLOT);
918
- ut_a (srv_sys-> n_threads_active [type] == 0 );
918
+ ut_a (srv_sys. n_threads_active [type] == 0 );
919
919
break ;
920
920
921
921
case SRV_PURGE:
@@ -924,12 +924,12 @@ srv_release_threads(enum srv_thread_type type, ulint n)
924
924
ut_a (n == 1 );
925
925
ut_a (i == SRV_PURGE_SLOT);
926
926
ut_a (srv_n_purge_threads > 0 );
927
- ut_a (srv_sys-> n_threads_active [type] == 0 );
927
+ ut_a (srv_sys. n_threads_active [type] == 0 );
928
928
break ;
929
929
930
930
case SRV_WORKER:
931
931
ut_a (srv_n_purge_threads > 1 );
932
- ut_a (srv_sys-> n_threads_active [type]
932
+ ut_a (srv_sys. n_threads_active [type]
933
933
< srv_n_purge_threads - 1 );
934
934
break ;
935
935
}
@@ -967,39 +967,26 @@ void
967
967
srv_init (void )
968
968
/* ==========*/
969
969
{
970
- ulint n_sys_threads = 0 ;
971
- ulint srv_sys_sz = sizeof (*srv_sys);
972
-
973
970
#ifndef HAVE_ATOMIC_BUILTINS
974
971
mutex_create (server_mutex_key, &server_mutex, SYNC_ANY_LATCH);
975
972
#endif /* !HAVE_ATOMIC_BUILTINS */
976
973
977
974
mutex_create (srv_innodb_monitor_mutex_key,
978
975
&srv_innodb_monitor_mutex, SYNC_NO_ORDER_CHECK);
979
976
980
- if (!srv_read_only_mode) {
981
-
982
- /* Number of purge threads + master thread */
983
- n_sys_threads = srv_n_purge_threads + 1 ;
984
-
985
- srv_sys_sz += n_sys_threads * sizeof (*srv_sys->sys_threads );
986
- }
987
-
988
- srv_sys = static_cast <srv_sys_t *>(mem_zalloc (srv_sys_sz));
989
-
990
- srv_sys->n_sys_threads = n_sys_threads;
977
+ srv_sys.n_sys_threads = srv_read_only_mode
978
+ ? 0
979
+ : srv_n_purge_threads + 1 /* purge coordinator */ ;
991
980
992
981
if (!srv_read_only_mode) {
993
982
994
- mutex_create (srv_sys_mutex_key, &srv_sys-> mutex , SYNC_THREADS);
983
+ mutex_create (srv_sys_mutex_key, &srv_sys. mutex , SYNC_THREADS);
995
984
996
985
mutex_create (srv_sys_tasks_mutex_key,
997
- &srv_sys->tasks_mutex , SYNC_ANY_LATCH);
998
-
999
- srv_sys->sys_threads = (srv_slot_t *) &srv_sys[1 ];
986
+ &srv_sys.tasks_mutex , SYNC_ANY_LATCH);
1000
987
1001
- for (ulint i = 0 ; i < srv_sys-> n_sys_threads ; ++i) {
1002
- srv_slot_t * slot = &srv_sys-> sys_threads [i];
988
+ for (ulint i = 0 ; i < srv_sys. n_sys_threads ; ++i) {
989
+ srv_slot_t * slot = &srv_sys. sys_threads [i];
1003
990
1004
991
slot->event = os_event_create ();
1005
992
@@ -1048,10 +1035,8 @@ srv_free(void)
1048
1035
{
1049
1036
srv_conc_free ();
1050
1037
1051
- /* The mutexes srv_sys-> mutex and srv_sys-> tasks_mutex should have
1038
+ /* The mutexes srv_sys. mutex and srv_sys. tasks_mutex should have
1052
1039
been freed by sync_close() already. */
1053
- mem_free (srv_sys);
1054
- srv_sys = NULL ;
1055
1040
1056
1041
trx_i_s_cache_free (trx_i_s_cache);
1057
1042
@@ -1882,7 +1867,7 @@ void
1882
1867
srv_inc_activity_count (void )
1883
1868
/* ========================*/
1884
1869
{
1885
- srv_sys-> activity_count .inc ();
1870
+ srv_sys. activity_count .inc ();
1886
1871
}
1887
1872
1888
1873
/* *********************************************************************/ /* *
@@ -1904,7 +1889,7 @@ srv_get_active_thread_type(void)
1904
1889
srv_sys_mutex_enter ();
1905
1890
1906
1891
for (ulint i = SRV_WORKER; i <= SRV_MASTER; ++i) {
1907
- if (srv_sys-> n_threads_active [i] != 0 ) {
1892
+ if (srv_sys. n_threads_active [i] != 0 ) {
1908
1893
ret = static_cast <srv_thread_type>(i);
1909
1894
break ;
1910
1895
}
@@ -1977,12 +1962,12 @@ srv_active_wake_master_thread(void)
1977
1962
1978
1963
srv_inc_activity_count ();
1979
1964
1980
- if (srv_sys-> n_threads_active [SRV_MASTER] == 0 ) {
1965
+ if (srv_sys. n_threads_active [SRV_MASTER] == 0 ) {
1981
1966
srv_slot_t * slot;
1982
1967
1983
1968
srv_sys_mutex_enter ();
1984
1969
1985
- slot = &srv_sys-> sys_threads [SRV_MASTER_SLOT];
1970
+ slot = &srv_sys. sys_threads [SRV_MASTER_SLOT];
1986
1971
1987
1972
/* Only if the master thread has been started. */
1988
1973
@@ -2009,7 +1994,7 @@ srv_wake_purge_thread_if_not_active(void)
2009
1994
ut_ad (!srv_sys_mutex_own ());
2010
1995
2011
1996
if (purge_sys->state == PURGE_STATE_RUN
2012
- && srv_sys-> n_threads_active [SRV_PURGE] == 0 ) {
1997
+ && srv_sys. n_threads_active [SRV_PURGE] == 0 ) {
2013
1998
2014
1999
srv_release_threads (SRV_PURGE, 1 );
2015
2000
}
@@ -2038,7 +2023,7 @@ ulint
2038
2023
srv_get_activity_count (void )
2039
2024
/* ========================*/
2040
2025
{
2041
- return (srv_sys-> activity_count );
2026
+ return (srv_sys. activity_count );
2042
2027
}
2043
2028
2044
2029
/* ******************************************************************/ /* *
@@ -2050,7 +2035,7 @@ srv_check_activity(
2050
2035
/* ===============*/
2051
2036
ulint old_activity_count) /* !< in: old activity count */
2052
2037
{
2053
- return (srv_sys-> activity_count != old_activity_count);
2038
+ return (srv_sys. activity_count != old_activity_count);
2054
2039
}
2055
2040
2056
2041
/* *******************************************************************/ /* *
@@ -2415,7 +2400,7 @@ DECLARE_THREAD(srv_master_thread)(
2415
2400
srv_main_thread_id = os_thread_pf (os_thread_get_curr_id ());
2416
2401
2417
2402
slot = srv_reserve_slot (SRV_MASTER);
2418
- ut_a (slot == srv_sys-> sys_threads );
2403
+ ut_a (slot == srv_sys. sys_threads );
2419
2404
2420
2405
last_print_time = ut_time ();
2421
2406
loop:
@@ -2505,18 +2490,18 @@ srv_task_execute(void)
2505
2490
ut_ad (!srv_read_only_mode);
2506
2491
ut_a (srv_force_recovery < SRV_FORCE_NO_BACKGROUND);
2507
2492
2508
- mutex_enter (&srv_sys-> tasks_mutex );
2493
+ mutex_enter (&srv_sys. tasks_mutex );
2509
2494
2510
- if (UT_LIST_GET_LEN (srv_sys-> tasks ) > 0 ) {
2495
+ if (UT_LIST_GET_LEN (srv_sys. tasks ) > 0 ) {
2511
2496
2512
- thr = UT_LIST_GET_FIRST (srv_sys-> tasks );
2497
+ thr = UT_LIST_GET_FIRST (srv_sys. tasks );
2513
2498
2514
2499
ut_a (que_node_get_type (thr->child ) == QUE_NODE_PURGE);
2515
2500
2516
- UT_LIST_REMOVE (queue, srv_sys-> tasks , thr);
2501
+ UT_LIST_REMOVE (queue, srv_sys. tasks , thr);
2517
2502
}
2518
2503
2519
- mutex_exit (&srv_sys-> tasks_mutex );
2504
+ mutex_exit (&srv_sys. tasks_mutex );
2520
2505
2521
2506
if (thr != NULL ) {
2522
2507
@@ -2556,7 +2541,7 @@ DECLARE_THREAD(srv_worker_thread)(
2556
2541
2557
2542
srv_sys_mutex_enter ();
2558
2543
2559
- ut_a (srv_sys-> n_threads_active [SRV_WORKER] < srv_n_purge_threads);
2544
+ ut_a (srv_sys. n_threads_active [SRV_WORKER] < srv_n_purge_threads);
2560
2545
2561
2546
srv_sys_mutex_exit ();
2562
2547
@@ -2885,11 +2870,11 @@ srv_que_task_enqueue_low(
2885
2870
que_thr_t * thr) /* !< in: query thread */
2886
2871
{
2887
2872
ut_ad (!srv_read_only_mode);
2888
- mutex_enter (&srv_sys-> tasks_mutex );
2873
+ mutex_enter (&srv_sys. tasks_mutex );
2889
2874
2890
- UT_LIST_ADD_LAST (queue, srv_sys-> tasks , thr);
2875
+ UT_LIST_ADD_LAST (queue, srv_sys. tasks , thr);
2891
2876
2892
- mutex_exit (&srv_sys-> tasks_mutex );
2877
+ mutex_exit (&srv_sys. tasks_mutex );
2893
2878
2894
2879
srv_release_threads (SRV_WORKER, 1 );
2895
2880
}
@@ -2906,11 +2891,11 @@ srv_get_task_queue_length(void)
2906
2891
2907
2892
ut_ad (!srv_read_only_mode);
2908
2893
2909
- mutex_enter (&srv_sys-> tasks_mutex );
2894
+ mutex_enter (&srv_sys. tasks_mutex );
2910
2895
2911
- n_tasks = UT_LIST_GET_LEN (srv_sys-> tasks );
2896
+ n_tasks = UT_LIST_GET_LEN (srv_sys. tasks );
2912
2897
2913
- mutex_exit (&srv_sys-> tasks_mutex );
2898
+ mutex_exit (&srv_sys. tasks_mutex );
2914
2899
2915
2900
return (n_tasks);
2916
2901
}
0 commit comments