~thomir-deactivatedaccount/drizzle/drizzle-fix-bug653747

« back to all changes in this revision

Viewing changes to plugin/innobase/buf/buf0buf.c

  • Committer: Brian Aker
  • Date: 2010-10-10 02:07:52 UTC
  • mfrom: (1827.2.3 staging)
  • Revision ID: brian@tangent.org-20101010020752-ktv73isay5dxtvp3
Merge in switch on table_share_instance inheritance.

Show diffs side-by-side

added added

removed removed

Lines of Context:
837
837
        block = chunk->blocks;
838
838
 
839
839
        for (i = chunk->size; i--; block++) {
840
 
                ibool   ready;
841
 
 
842
 
                switch (buf_block_get_state(block)) {
843
 
                case BUF_BLOCK_ZIP_FREE:
844
 
                case BUF_BLOCK_ZIP_PAGE:
845
 
                case BUF_BLOCK_ZIP_DIRTY:
846
 
                        /* The uncompressed buffer pool should never
847
 
                        contain compressed block descriptors. */
848
 
                        ut_error;
849
 
                        break;
850
 
                case BUF_BLOCK_NOT_USED:
851
 
                case BUF_BLOCK_READY_FOR_USE:
852
 
                case BUF_BLOCK_MEMORY:
853
 
                case BUF_BLOCK_REMOVE_HASH:
854
 
                        /* Skip blocks that are not being used for
855
 
                        file pages. */
856
 
                        break;
857
 
                case BUF_BLOCK_FILE_PAGE:
858
 
                        mutex_enter(&block->mutex);
859
 
                        ready = buf_flush_ready_for_replace(&block->page);
 
840
                mutex_enter(&block->mutex);
 
841
 
 
842
                if (buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE
 
843
                    && !buf_flush_ready_for_replace(&block->page)) {
 
844
 
860
845
                        mutex_exit(&block->mutex);
861
 
 
862
 
                        if (!ready) {
863
 
 
864
 
                                return(block);
865
 
                        }
866
 
 
867
 
                        break;
 
846
                        return(block);
868
847
                }
 
848
 
 
849
                mutex_exit(&block->mutex);
869
850
        }
870
851
 
871
852
        return(NULL);
985
966
                buf_pool->no_flush[i] = os_event_create(NULL);
986
967
        }
987
968
 
 
969
        buf_pool->ulint_clock = 1;
 
970
 
988
971
        /* 3. Initialize LRU fields
989
972
        --------------------------- */
990
973
        /* All fields are initialized by mem_zalloc(). */
1020
1003
                os_mem_free_large(chunk->mem, chunk->mem_size);
1021
1004
        }
1022
1005
 
1023
 
        mem_free(buf_pool->chunks);
1024
 
        hash_table_free(buf_pool->page_hash);
1025
 
        hash_table_free(buf_pool->zip_hash);
1026
 
        mem_free(buf_pool);
1027
 
        buf_pool = NULL;
 
1006
        buf_pool->n_chunks = 0;
1028
1007
}
1029
1008
 
1030
1009
/********************************************************************//**
1167
1146
#ifdef UNIV_LRU_DEBUG
1168
1147
                /* buf_pool->LRU_old must be the first item in the LRU list
1169
1148
                whose "old" flag is set. */
1170
 
                ut_a(buf_pool->LRU_old->old);
1171
1149
                ut_a(!UT_LIST_GET_PREV(LRU, buf_pool->LRU_old)
1172
1150
                     || !UT_LIST_GET_PREV(LRU, buf_pool->LRU_old)->old);
1173
1151
                ut_a(!UT_LIST_GET_NEXT(LRU, buf_pool->LRU_old)
1174
1152
                     || UT_LIST_GET_NEXT(LRU, buf_pool->LRU_old)->old);
1175
 
        } else {
1176
 
                /* Check that the "old" flag is consistent in
1177
 
                the block and its neighbours. */
1178
 
                buf_page_set_old(dpage, buf_page_is_old(dpage));
1179
1153
#endif /* UNIV_LRU_DEBUG */
1180
1154
        }
1181
1155
 
1497
1471
}
1498
1472
 
1499
1473
/********************************************************************//**
 
1474
Moves the block to the start of the LRU list if there is a danger
 
1475
that the block would drift out of the buffer pool. */
 
1476
UNIV_INLINE
 
1477
void
 
1478
buf_block_make_young(
 
1479
/*=================*/
 
1480
        buf_page_t*     bpage)  /*!< in: block to make younger */
 
1481
{
 
1482
        ut_ad(!buf_pool_mutex_own());
 
1483
 
 
1484
        /* Note that we read freed_page_clock's without holding any mutex:
 
1485
        this is allowed since the result is used only in heuristics */
 
1486
 
 
1487
        if (buf_page_peek_if_too_old(bpage)) {
 
1488
 
 
1489
                buf_pool_mutex_enter();
 
1490
                /* There has been freeing activity in the LRU list:
 
1491
                best to move to the head of the LRU list */
 
1492
 
 
1493
                buf_LRU_make_block_young(bpage);
 
1494
                buf_pool_mutex_exit();
 
1495
        }
 
1496
}
 
1497
 
 
1498
/********************************************************************//**
1500
1499
Moves a page to the start of the buffer pool LRU list. This high-level
1501
 
function can be used to prevent an important page from slipping out of
 
1500
function can be used to prevent an important page from from slipping out of
1502
1501
the buffer pool. */
1503
1502
UNIV_INTERN
1504
1503
void
1516
1515
}
1517
1516
 
1518
1517
/********************************************************************//**
1519
 
Sets the time of the first access of a page and moves a page to the
1520
 
start of the buffer pool LRU list if it is too old.  This high-level
1521
 
function can be used to prevent an important page from slipping
1522
 
out of the buffer pool. */
1523
 
static
1524
 
void
1525
 
buf_page_set_accessed_make_young(
1526
 
/*=============================*/
1527
 
        buf_page_t*     bpage,          /*!< in/out: buffer block of a
1528
 
                                        file page */
1529
 
        unsigned        access_time)    /*!< in: bpage->access_time
1530
 
                                        read under mutex protection,
1531
 
                                        or 0 if unknown */
1532
 
{
1533
 
        ut_ad(!buf_pool_mutex_own());
1534
 
        ut_a(buf_page_in_file(bpage));
1535
 
 
1536
 
        if (buf_page_peek_if_too_old(bpage)) {
1537
 
                buf_pool_mutex_enter();
1538
 
                buf_LRU_make_block_young(bpage);
1539
 
                buf_pool_mutex_exit();
1540
 
        } else if (!access_time) {
1541
 
                ulint   time_ms = ut_time_ms();
1542
 
                buf_pool_mutex_enter();
1543
 
                buf_page_set_accessed(bpage, time_ms);
1544
 
                buf_pool_mutex_exit();
1545
 
        }
1546
 
}
1547
 
 
1548
 
/********************************************************************//**
1549
1518
Resets the check_index_page_at_flush field of a page if found in the buffer
1550
1519
pool. */
1551
1520
UNIV_INTERN
1676
1645
        buf_page_t*     bpage;
1677
1646
        mutex_t*        block_mutex;
1678
1647
        ibool           must_read;
1679
 
        unsigned        access_time;
1680
1648
 
1681
1649
#ifndef UNIV_LOG_DEBUG
1682
1650
        ut_ad(!ibuf_inside());
1683
1651
#endif
1684
 
        buf_pool->stat.n_page_gets++;
 
1652
        buf_pool->n_page_gets++;
1685
1653
 
1686
1654
        for (;;) {
1687
1655
                buf_pool_mutex_enter();
1744
1712
 
1745
1713
got_block:
1746
1714
        must_read = buf_page_get_io_fix(bpage) == BUF_IO_READ;
1747
 
        access_time = buf_page_is_accessed(bpage);
1748
1715
 
1749
1716
        buf_pool_mutex_exit();
1750
1717
 
 
1718
        buf_page_set_accessed(bpage, TRUE);
 
1719
 
1751
1720
        mutex_exit(block_mutex);
1752
1721
 
1753
 
        buf_page_set_accessed_make_young(bpage, access_time);
 
1722
        buf_block_make_young(bpage);
1754
1723
 
1755
1724
#ifdef UNIV_DEBUG_FILE_ACCESSES
1756
1725
        ut_a(!bpage->file_page_was_freed);
1843
1812
        switch (fil_page_get_type(frame)) {
1844
1813
        case FIL_PAGE_INDEX:
1845
1814
                if (page_zip_decompress(&block->page.zip,
1846
 
                                        block->frame, TRUE)) {
 
1815
                                        block->frame)) {
1847
1816
                        return(TRUE);
1848
1817
                }
1849
1818
 
2031
2000
        mtr_t*          mtr)    /*!< in: mini-transaction */
2032
2001
{
2033
2002
        buf_block_t*    block;
2034
 
        unsigned        access_time;
 
2003
        ibool           accessed;
2035
2004
        ulint           fix_type;
2036
2005
        ibool           must_read;
2037
2006
 
2047
2016
#ifndef UNIV_LOG_DEBUG
2048
2017
        ut_ad(!ibuf_inside() || ibuf_page(space, zip_size, offset, NULL));
2049
2018
#endif
2050
 
        buf_pool->stat.n_page_gets++;
 
2019
        buf_pool->n_page_gets++;
2051
2020
loop:
2052
2021
        block = guess;
2053
2022
        buf_pool_mutex_enter();
2274
2243
        UNIV_MEM_ASSERT_RW(&block->page, sizeof block->page);
2275
2244
 
2276
2245
        buf_block_buf_fix_inc(block, file, line);
 
2246
        buf_pool_mutex_exit();
 
2247
 
 
2248
        /* Check if this is the first access to the page */
 
2249
 
 
2250
        accessed = buf_page_is_accessed(&block->page);
 
2251
 
 
2252
        buf_page_set_accessed(&block->page, TRUE);
2277
2253
 
2278
2254
        mutex_exit(&block->mutex);
2279
2255
 
2280
 
        /* Check if this is the first access to the page */
2281
 
 
2282
 
        access_time = buf_page_is_accessed(&block->page);
2283
 
 
2284
 
        buf_pool_mutex_exit();
2285
 
 
2286
 
        buf_page_set_accessed_make_young(&block->page, access_time);
 
2256
        buf_block_make_young(&block->page);
2287
2257
 
2288
2258
#ifdef UNIV_DEBUG_FILE_ACCESSES
2289
2259
        ut_a(!block->page.file_page_was_freed);
2336
2306
 
2337
2307
        mtr_memo_push(mtr, block, fix_type);
2338
2308
 
2339
 
        if (!access_time) {
 
2309
        if (!accessed) {
2340
2310
                /* In the case of a first access, try to apply linear
2341
2311
                read-ahead */
2342
2312
 
2366
2336
        ulint           line,   /*!< in: line where called */
2367
2337
        mtr_t*          mtr)    /*!< in: mini-transaction */
2368
2338
{
2369
 
        unsigned        access_time;
 
2339
        ibool           accessed;
2370
2340
        ibool           success;
2371
2341
        ulint           fix_type;
2372
2342
 
2383
2353
        }
2384
2354
 
2385
2355
        buf_block_buf_fix_inc(block, file, line);
 
2356
        accessed = buf_page_is_accessed(&block->page);
 
2357
        buf_page_set_accessed(&block->page, TRUE);
2386
2358
 
2387
2359
        mutex_exit(&block->mutex);
2388
2360
 
2389
 
        /* Check if this is the first access to the page.
2390
 
        We do a dirty read on purpose, to avoid mutex contention.
2391
 
        This field is only used for heuristic purposes; it does not
2392
 
        affect correctness. */
 
2361
        buf_block_make_young(&block->page);
2393
2362
 
2394
 
        access_time = buf_page_is_accessed(&block->page);
2395
 
        buf_page_set_accessed_make_young(&block->page, access_time);
 
2363
        /* Check if this is the first access to the page */
2396
2364
 
2397
2365
        ut_ad(!ibuf_inside()
2398
2366
              || ibuf_page(buf_block_get_space(block),
2444
2412
#ifdef UNIV_DEBUG_FILE_ACCESSES
2445
2413
        ut_a(block->page.file_page_was_freed == FALSE);
2446
2414
#endif
2447
 
        if (UNIV_UNLIKELY(!access_time)) {
 
2415
        if (UNIV_UNLIKELY(!accessed)) {
2448
2416
                /* In the case of a first access, try to apply linear
2449
2417
                read-ahead */
2450
2418
 
2457
2425
        ut_a(ibuf_count_get(buf_block_get_space(block),
2458
2426
                            buf_block_get_page_no(block)) == 0);
2459
2427
#endif
2460
 
        buf_pool->stat.n_page_gets++;
 
2428
        buf_pool->n_page_gets++;
2461
2429
 
2462
2430
        return(TRUE);
2463
2431
}
2505
2473
 
2506
2474
        mutex_exit(&block->mutex);
2507
2475
 
2508
 
        if (mode == BUF_MAKE_YOUNG && buf_page_peek_if_too_old(&block->page)) {
2509
 
                buf_pool_mutex_enter();
2510
 
                buf_LRU_make_block_young(&block->page);
2511
 
                buf_pool_mutex_exit();
2512
 
        } else if (!buf_page_is_accessed(&block->page)) {
2513
 
                /* Above, we do a dirty read on purpose, to avoid
2514
 
                mutex contention.  The field buf_page_t::access_time
2515
 
                is only used for heuristic purposes.  Writes to the
2516
 
                field must be protected by mutex, however. */
2517
 
                ulint   time_ms = ut_time_ms();
2518
 
 
2519
 
                buf_pool_mutex_enter();
2520
 
                buf_page_set_accessed(&block->page, time_ms);
2521
 
                buf_pool_mutex_exit();
 
2476
        if (mode == BUF_MAKE_YOUNG) {
 
2477
                buf_block_make_young(&block->page);
2522
2478
        }
2523
2479
 
2524
2480
        ut_ad(!ibuf_inside() || (mode == BUF_KEEP_OLD));
2557
2513
             || (ibuf_count_get(buf_block_get_space(block),
2558
2514
                                buf_block_get_page_no(block)) == 0));
2559
2515
#endif
2560
 
        buf_pool->stat.n_page_gets++;
 
2516
        buf_pool->n_page_gets++;
2561
2517
 
2562
2518
        return(TRUE);
2563
2519
}
2633
2589
#endif /* UNIV_DEBUG_FILE_ACCESSES */
2634
2590
        buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
2635
2591
 
2636
 
        buf_pool->stat.n_page_gets++;
 
2592
        buf_pool->n_page_gets++;
2637
2593
 
2638
2594
#ifdef UNIV_IBUF_COUNT_DEBUG
2639
2595
        ut_a(ibuf_count_get(buf_block_get_space(block),
2652
2608
        buf_page_t*     bpage)  /*!< in: block to init */
2653
2609
{
2654
2610
        bpage->flush_type = BUF_FLUSH_LRU;
 
2611
        bpage->accessed = FALSE;
2655
2612
        bpage->io_fix = BUF_IO_NONE;
2656
2613
        bpage->buf_fix_count = 0;
2657
2614
        bpage->freed_page_clock = 0;
2658
 
        bpage->access_time = 0;
2659
2615
        bpage->newest_modification = 0;
2660
2616
        bpage->oldest_modification = 0;
2661
2617
        HASH_INVALIDATE(bpage, hash);
2951
2907
        buf_frame_t*    frame;
2952
2908
        buf_block_t*    block;
2953
2909
        buf_block_t*    free_block      = NULL;
2954
 
        ulint           time_ms         = ut_time_ms();
2955
2910
 
2956
2911
        ut_ad(mtr);
2957
2912
        ut_ad(space || !zip_size);
2998
2953
        buf_LRU_add_block(&block->page, FALSE);
2999
2954
 
3000
2955
        buf_block_buf_fix_inc(block, __FILE__, __LINE__);
3001
 
        buf_pool->stat.n_pages_created++;
 
2956
        buf_pool->n_pages_created++;
3002
2957
 
3003
2958
        if (zip_size) {
3004
2959
                void*   data;
3035
2990
                rw_lock_x_unlock(&block->lock);
3036
2991
        }
3037
2992
 
3038
 
        buf_page_set_accessed(&block->page, time_ms);
3039
 
 
3040
2993
        buf_pool_mutex_exit();
3041
2994
 
3042
2995
        mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX);
3043
2996
 
 
2997
        buf_page_set_accessed(&block->page, TRUE);
 
2998
 
3044
2999
        mutex_exit(&block->mutex);
3045
3000
 
3046
3001
        /* Delete possible entries for the page from the insert buffer:
3246
3201
 
3247
3202
                ut_ad(buf_pool->n_pend_reads > 0);
3248
3203
                buf_pool->n_pend_reads--;
3249
 
                buf_pool->stat.n_pages_read++;
 
3204
                buf_pool->n_pages_read++;
3250
3205
 
3251
3206
                if (uncompressed) {
3252
3207
                        rw_lock_x_unlock_gen(&((buf_block_t*) bpage)->lock,
3266
3221
                                             BUF_IO_WRITE);
3267
3222
                }
3268
3223
 
3269
 
                buf_pool->stat.n_pages_written++;
 
3224
                buf_pool->n_pages_written++;
3270
3225
 
3271
3226
                break;
3272
3227
 
3296
3251
buf_pool_invalidate(void)
3297
3252
/*=====================*/
3298
3253
{
3299
 
        ibool           freed;
3300
 
        enum buf_flush  i;
3301
 
 
3302
 
        buf_pool_mutex_enter();
3303
 
 
3304
 
        for (i = BUF_FLUSH_LRU; i < BUF_FLUSH_N_TYPES; i++) {
3305
 
 
3306
 
                /* As this function is called during startup and
3307
 
                during redo application phase during recovery, InnoDB
3308
 
                is single threaded (apart from IO helper threads) at
3309
 
                this stage. No new write batch can be in intialization
3310
 
                stage at this point. */
3311
 
                ut_ad(buf_pool->init_flush[i] == FALSE);
3312
 
 
3313
 
                /* However, it is possible that a write batch that has
3314
 
                been posted earlier is still not complete. For buffer
3315
 
                pool invalidation to proceed we must ensure there is NO
3316
 
                write activity happening. */
3317
 
                if (buf_pool->n_flush[i] > 0) {
3318
 
                        buf_pool_mutex_exit();
3319
 
                        buf_flush_wait_batch_end(i);
3320
 
                        buf_pool_mutex_enter();
3321
 
                }
3322
 
        }
3323
 
 
3324
 
        buf_pool_mutex_exit();
 
3254
        ibool   freed;
3325
3255
 
3326
3256
        ut_ad(buf_all_freed());
3327
3257
 
3336
3266
        ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0);
3337
3267
        ut_ad(UT_LIST_GET_LEN(buf_pool->unzip_LRU) == 0);
3338
3268
 
3339
 
        buf_pool->freed_page_clock = 0;
3340
 
        buf_pool->LRU_old = NULL;
3341
 
        buf_pool->LRU_old_len = 0;
3342
 
        buf_pool->LRU_flush_ended = 0;
3343
 
 
3344
 
        memset(&buf_pool->stat, 0x00, sizeof(buf_pool->stat));
3345
 
        buf_refresh_io_stats();
3346
 
 
3347
3269
        buf_pool_mutex_exit();
3348
3270
}
3349
3271
 
3606
3528
                "n pending decompressions %lu\n"
3607
3529
                "n pending reads %lu\n"
3608
3530
                "n pending flush LRU %lu list %lu single page %lu\n"
3609
 
                "pages made young %lu, not young %lu\n"
3610
3531
                "pages read %lu, created %lu, written %lu\n",
3611
3532
                (ulong) size,
3612
3533
                (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
3617
3538
                (ulong) buf_pool->n_flush[BUF_FLUSH_LRU],
3618
3539
                (ulong) buf_pool->n_flush[BUF_FLUSH_LIST],
3619
3540
                (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE],
3620
 
                (ulong) buf_pool->stat.n_pages_made_young,
3621
 
                (ulong) buf_pool->stat.n_pages_not_made_young,
3622
 
                (ulong) buf_pool->stat.n_pages_read,
3623
 
                (ulong) buf_pool->stat.n_pages_created,
3624
 
                (ulong) buf_pool->stat.n_pages_written);
 
3541
                (ulong) buf_pool->n_pages_read, buf_pool->n_pages_created,
 
3542
                (ulong) buf_pool->n_pages_written);
3625
3543
 
3626
3544
        /* Count the number of blocks belonging to each index in the buffer */
3627
3545
 
3826
3744
{
3827
3745
        time_t  current_time;
3828
3746
        double  time_elapsed;
3829
 
        ulint   n_gets_diff;
 
3747
        ulint   size;
3830
3748
 
3831
3749
        ut_ad(buf_pool);
 
3750
        size = buf_pool->curr_size;
3832
3751
 
3833
3752
        buf_pool_mutex_enter();
3834
3753
 
3836
3755
                "Buffer pool size   %lu\n"
3837
3756
                "Free buffers       %lu\n"
3838
3757
                "Database pages     %lu\n"
3839
 
                "Old database pages %lu\n"
3840
3758
                "Modified db pages  %lu\n"
3841
3759
                "Pending reads %lu\n"
3842
3760
                "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
3843
 
                (ulong) buf_pool->curr_size,
 
3761
                (ulong) size,
3844
3762
                (ulong) UT_LIST_GET_LEN(buf_pool->free),
3845
3763
                (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
3846
 
                (ulong) buf_pool->LRU_old_len,
3847
3764
                (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
3848
3765
                (ulong) buf_pool->n_pend_reads,
3849
3766
                (ulong) buf_pool->n_flush[BUF_FLUSH_LRU]
3855
3772
        current_time = time(NULL);
3856
3773
        time_elapsed = 0.001 + difftime(current_time,
3857
3774
                                        buf_pool->last_printout_time);
 
3775
        buf_pool->last_printout_time = current_time;
3858
3776
 
3859
3777
        fprintf(file,
3860
 
                "Pages made young %lu, not young %lu\n"
3861
 
                "%.2f youngs/s, %.2f non-youngs/s\n"
3862
3778
                "Pages read %lu, created %lu, written %lu\n"
3863
3779
                "%.2f reads/s, %.2f creates/s, %.2f writes/s\n",
3864
 
                (ulong) buf_pool->stat.n_pages_made_young,
3865
 
                (ulong) buf_pool->stat.n_pages_not_made_young,
3866
 
                (buf_pool->stat.n_pages_made_young
3867
 
                 - buf_pool->old_stat.n_pages_made_young)
3868
 
                / time_elapsed,
3869
 
                (buf_pool->stat.n_pages_not_made_young
3870
 
                 - buf_pool->old_stat.n_pages_not_made_young)
3871
 
                / time_elapsed,
3872
 
                (ulong) buf_pool->stat.n_pages_read,
3873
 
                (ulong) buf_pool->stat.n_pages_created,
3874
 
                (ulong) buf_pool->stat.n_pages_written,
3875
 
                (buf_pool->stat.n_pages_read
3876
 
                 - buf_pool->old_stat.n_pages_read)
3877
 
                / time_elapsed,
3878
 
                (buf_pool->stat.n_pages_created
3879
 
                 - buf_pool->old_stat.n_pages_created)
3880
 
                / time_elapsed,
3881
 
                (buf_pool->stat.n_pages_written
3882
 
                 - buf_pool->old_stat.n_pages_written)
 
3780
                (ulong) buf_pool->n_pages_read,
 
3781
                (ulong) buf_pool->n_pages_created,
 
3782
                (ulong) buf_pool->n_pages_written,
 
3783
                (buf_pool->n_pages_read - buf_pool->n_pages_read_old)
 
3784
                / time_elapsed,
 
3785
                (buf_pool->n_pages_created - buf_pool->n_pages_created_old)
 
3786
                / time_elapsed,
 
3787
                (buf_pool->n_pages_written - buf_pool->n_pages_written_old)
3883
3788
                / time_elapsed);
3884
3789
 
3885
 
        n_gets_diff = buf_pool->stat.n_page_gets - buf_pool->old_stat.n_page_gets;
3886
 
 
3887
 
        if (n_gets_diff) {
3888
 
                fprintf(file,
3889
 
                        "Buffer pool hit rate %lu / 1000,"
3890
 
                        " young-making rate %lu / 1000 not %lu / 1000\n",
3891
 
                        (ulong)
3892
 
                        (1000 - ((1000 * (buf_pool->stat.n_pages_read
3893
 
                                          - buf_pool->old_stat.n_pages_read))
3894
 
                                 / (buf_pool->stat.n_page_gets
3895
 
                                    - buf_pool->old_stat.n_page_gets))),
3896
 
                        (ulong)
3897
 
                        (1000 * (buf_pool->stat.n_pages_made_young
3898
 
                                 - buf_pool->old_stat.n_pages_made_young)
3899
 
                         / n_gets_diff),
3900
 
                        (ulong)
3901
 
                        (1000 * (buf_pool->stat.n_pages_not_made_young
3902
 
                                 - buf_pool->old_stat.n_pages_not_made_young)
3903
 
                         / n_gets_diff));
 
3790
        if (buf_pool->n_page_gets > buf_pool->n_page_gets_old) {
 
3791
                fprintf(file, "Buffer pool hit rate %lu / 1000\n",
 
3792
                        (ulong)
 
3793
                        (1000 - ((1000 * (buf_pool->n_pages_read
 
3794
                                          - buf_pool->n_pages_read_old))
 
3795
                                 / (buf_pool->n_page_gets
 
3796
                                    - buf_pool->n_page_gets_old))));
3904
3797
        } else {
3905
3798
                fputs("No buffer pool page gets since the last printout\n",
3906
3799
                      file);
3907
3800
        }
3908
3801
 
3909
 
        /* Statistics about read ahead algorithm */
3910
 
        fprintf(file, "Pages read ahead %.2f/s,"
3911
 
                " evicted without access %.2f/s\n",
3912
 
                (buf_pool->stat.n_ra_pages_read
3913
 
                - buf_pool->old_stat.n_ra_pages_read)
3914
 
                / time_elapsed,
3915
 
                (buf_pool->stat.n_ra_pages_evicted
3916
 
                - buf_pool->old_stat.n_ra_pages_evicted)
3917
 
                / time_elapsed);
 
3802
        buf_pool->n_page_gets_old = buf_pool->n_page_gets;
 
3803
        buf_pool->n_pages_read_old = buf_pool->n_pages_read;
 
3804
        buf_pool->n_pages_created_old = buf_pool->n_pages_created;
 
3805
        buf_pool->n_pages_written_old = buf_pool->n_pages_written;
3918
3806
 
3919
3807
        /* Print some values to help us with visualizing what is
3920
3808
        happening with LRU eviction. */
3926
3814
                buf_LRU_stat_sum.io, buf_LRU_stat_cur.io,
3927
3815
                buf_LRU_stat_sum.unzip, buf_LRU_stat_cur.unzip);
3928
3816
 
3929
 
        buf_refresh_io_stats();
3930
3817
        buf_pool_mutex_exit();
3931
3818
}
3932
3819
 
3938
3825
/*======================*/
3939
3826
{
3940
3827
        buf_pool->last_printout_time = time(NULL);
3941
 
        buf_pool->old_stat = buf_pool->stat;
 
3828
        buf_pool->n_page_gets_old = buf_pool->n_page_gets;
 
3829
        buf_pool->n_pages_read_old = buf_pool->n_pages_read;
 
3830
        buf_pool->n_pages_created_old = buf_pool->n_pages_created;
 
3831
        buf_pool->n_pages_written_old = buf_pool->n_pages_written;
3942
3832
}
3943
3833
 
3944
3834
/*********************************************************************//**