@@ -1248,14 +1248,10 @@ inline void dict_sys_t::add(dict_table_t* table)
1248
1248
ut_ad (dict_lru_validate ());
1249
1249
}
1250
1250
1251
- /* *********************************************************************/ /* *
1252
- Test whether a table can be evicted from the LRU cache.
1253
- @return TRUE if table can be evicted. */
1254
- static
1255
- ibool
1256
- dict_table_can_be_evicted (
1257
- /* ======================*/
1258
- dict_table_t * table) /* !< in: table to test */
1251
+ /* * Test whether a table can be evicted from dict_sys.table_LRU.
1252
+ @param table table to be considered for eviction
1253
+ @return whether the table can be evicted */
1254
+ static bool dict_table_can_be_evicted (dict_table_t *table)
1259
1255
{
1260
1256
ut_d (dict_sys.assert_locked ());
1261
1257
ut_a (table->can_be_evicted );
@@ -1269,25 +1265,26 @@ dict_table_can_be_evicted(
1269
1265
the table instance is in "use". */
1270
1266
1271
1267
if (lock_table_has_locks (table)) {
1272
- return ( FALSE ) ;
1268
+ return false ;
1273
1269
}
1274
1270
1275
1271
#ifdef BTR_CUR_HASH_ADAPT
1276
1272
/* We cannot really evict the table if adaptive hash
1277
1273
index entries are pointing to any of its indexes. */
1278
- for (dict_index_t * index = dict_table_get_first_index (table);
1279
- index != NULL ;
1280
- index = dict_table_get_next_index (index)) {
1274
+ for (const dict_index_t * index
1275
+ = dict_table_get_first_index (table) ;
1276
+ index; index = dict_table_get_next_index (index)) {
1281
1277
if (index->n_ahi_pages ()) {
1282
- return ( FALSE ) ;
1278
+ return false ;
1283
1279
}
1284
1280
}
1285
1281
#endif /* BTR_CUR_HASH_ADAPT */
1286
1282
1287
- return (TRUE );
1283
+ ut_ad (!table->fts );
1284
+ return true ;
1288
1285
}
1289
1286
1290
- return ( FALSE ) ;
1287
+ return false ;
1291
1288
}
1292
1289
1293
1290
#ifdef BTR_CUR_HASH_ADAPT
@@ -1354,64 +1351,49 @@ dict_index_t *dict_index_t::clone_if_needed()
1354
1351
}
1355
1352
#endif /* BTR_CUR_HASH_ADAPT */
1356
1353
1357
- /* *********************************************************************/ /* *
1358
- Make room in the table cache by evicting an unused table. The unused table
1359
- should not be part of FK relationship and currently not used in any user
1360
- transaction. There is no guarantee that it will remove a table.
1361
- @return number of tables evicted. If the number of tables in the dict_LRU
1362
- is less than max_tables it will not do anything. */
1363
- ulint
1364
- dict_make_room_in_cache (
1365
- /* ====================*/
1366
- ulint max_tables, /* !< in: max tables allowed in cache */
1367
- ulint pct_check) /* !< in: max percent to check */
1354
+ /* * Evict unused, unlocked tables from table_LRU.
1355
+ @param half whether to consider half the tables only (instead of all)
1356
+ @return number of tables evicted */
1357
+ ulint dict_sys_t::evict_table_LRU (bool half)
1368
1358
{
1369
- ulint i;
1370
- ulint len;
1371
- dict_table_t * table;
1372
- ulint check_up_to;
1373
- ulint n_evicted = 0 ;
1359
+ #ifdef MYSQL_DYNAMIC_PLUGIN
1360
+ constexpr ulint max_tables = 400 ;
1361
+ #else
1362
+ extern ulong tdc_size;
1363
+ const ulint max_tables = tdc_size;
1364
+ #endif
1365
+ ulint n_evicted = 0 ;
1374
1366
1375
- ut_a (pct_check > 0 );
1376
- ut_a (pct_check <= 100 );
1377
- ut_d (dict_sys.assert_locked ());
1367
+ lock (SRW_LOCK_CALL);
1378
1368
ut_ad (dict_lru_validate ());
1379
1369
1380
- i = len = UT_LIST_GET_LEN (dict_sys. table_LRU );
1370
+ const ulint len = UT_LIST_GET_LEN (table_LRU);
1381
1371
1382
1372
if (len < max_tables) {
1383
- return (0 );
1373
+ func_exit:
1374
+ unlock ();
1375
+ return (n_evicted);
1384
1376
}
1385
1377
1386
- check_up_to = len - ((len * pct_check) / 100 );
1387
-
1388
- /* Check for overflow */
1389
- ut_a (i == 0 || check_up_to <= i);
1378
+ const ulint check_up_to = half ? len / 2 : 0 ;
1379
+ ulint i = len;
1390
1380
1391
1381
/* Find a suitable candidate to evict from the cache. Don't scan the
1392
1382
entire LRU list. Only scan pct_check list entries. */
1393
1383
1394
- for (table = UT_LIST_GET_LAST (dict_sys.table_LRU );
1395
- table != NULL
1396
- && i > check_up_to
1397
- && (len - n_evicted) > max_tables;
1398
- --i) {
1399
-
1400
- dict_table_t * prev_table;
1401
-
1402
- prev_table = UT_LIST_GET_PREV (table_LRU, table);
1384
+ for (dict_table_t *table = UT_LIST_GET_LAST (table_LRU);
1385
+ table && i > check_up_to && (len - n_evicted) > max_tables; --i) {
1386
+ dict_table_t * prev_table = UT_LIST_GET_PREV (table_LRU, table);
1403
1387
1404
1388
if (dict_table_can_be_evicted (table)) {
1405
- ut_ad (!table->fts );
1406
- dict_sys.remove (table, true );
1407
-
1389
+ remove (table, true );
1408
1390
++n_evicted;
1409
1391
}
1410
1392
1411
1393
table = prev_table;
1412
1394
}
1413
1395
1414
- return (n_evicted) ;
1396
+ goto func_exit ;
1415
1397
}
1416
1398
1417
1399
/* * Looks for an index with the given id given a table instance.
@@ -3411,7 +3393,7 @@ dict_get_referenced_table(
3411
3393
/* Values; 0 = Store and compare as given; case sensitive
3412
3394
1 = Store and compare in lower; case insensitive
3413
3395
2 = Store as given, compare in lower; case semi-sensitive */
3414
- if (innobase_get_lower_case_table_names () == 2 ) {
3396
+ if (lower_case_table_names == 2 ) {
3415
3397
innobase_casedn_str (ref);
3416
3398
*table = dict_table_get_low (ref);
3417
3399
memcpy (ref, database_name, database_name_len);
@@ -3420,7 +3402,7 @@ dict_get_referenced_table(
3420
3402
3421
3403
} else {
3422
3404
#ifndef _WIN32
3423
- if (innobase_get_lower_case_table_names () == 1 ) {
3405
+ if (lower_case_table_names == 1 ) {
3424
3406
innobase_casedn_str (ref);
3425
3407
}
3426
3408
#else
0 commit comments