• Resolved kn007

    (@kn007)


    Currently my site has over 17,000+ comments.

    When I open the edit-comments.php page, it’s slowly and using too much memory with high cpu usage.

    Information: edit-comments.php had 23 queries in 0.1978 seconds, page to load in 7.930 seconds, using 66.65MB memory.

    Always takes at least 65MB memory to load, and I also saw that had 2 queries from _prime_comment_caches(), it’s spent 0.1800+ seconds in this page since 4.4.

    Why _prime_comment_caches() rebuild the cache each time when I open edit-comments.php page?(using memcached object cache)

    Each time I open edit-comments.php page, _prime_comment_caches() do Memcached::Set 17,000+ time. It’s feeling so bad and wasted memory.

    Any suggestions to help me fix this?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter kn007

    (@kn007)

    I don’t know what to say.

    I found the problem in wp-includes/comment.php #L2490:

    wp_cache_add($comment->comment_ID, $comment, 'comment');

    The data($comment) could not be set to memcache.

    Maybe need apply some filters like update_option()?

    Thank you.

    Thread Starter kn007

    (@kn007)

    Actually _prime_comment_caches() do Memcached::Set 35,000+ time in first time.

    update_comment_cache() do Memcached::Set 17,000+ time.
    update_meta_cache() do Memcached::Set 17,000+ time.

    update_meta_cache() was successful, but all of keys value was same value(a:0:{}) because my site did not had any comment meta.

    Thread Starter kn007

    (@kn007)

    Anyone here?

    the problem is the memcache group bypass to set.

    i change the
    wp_cache_add($comment->comment_ID, $comment, 'comment');
    to
    wp_cache_add($comment->comment_ID, $comment, 'comments');

    it’s work, memcache can set&get all the value, but if want to change all the comment group was so confusing.

    so, any idea to fix it?

    i check the object-cache.php, $no_mc_groups was a empty array.

    i add ‘comment’ to $global_groups, but it’s still not work.

    Thread Starter kn007

    (@kn007)

    ok, i found the another problem, when i open home page(or another only had main loop pages).

    all comment of the page can using wp_cache_get get the ids, but Memcached::Get() get the ids false!?

    why?

    recently, i post the another question about $in_comment_loop do not working(always return null) after using wp_list_comments!?

    https://ww.wp.xz.cn/support/topic/comment-pagination-not-working-after-updating-to-wordpress-44?replies=2#post-7778080

    i hope fix it as quickly as possible.

    Thread Starter kn007

    (@kn007)

    i test this follow code in memcache/redis obj-cache :
    `
    <?php var_dump(wp_cache_add(‘test’, ‘test’, ‘comment’));?>
    <?php var_dump(wp_cache_get(‘test’, ‘comment’));?>
    <?php var_dump(wp_cache_set(‘test’, ‘test’, ‘comment’));?>
    <?php var_dump(wp_cache_get(‘test’, ‘comment’));?>
    `
    return
    bool(true)
    string(4) “test”
    bool(true)
    string(4) “test”

    but it could not find in memcache/redis.

    so, how it work when the group is comment?

    Thread Starter kn007

    (@kn007)

    maybe it’s add_to_internal_cache?

    i will check later

    Thread Starter kn007

    (@kn007)

    i saw the wordpress define $no_mc_groups
    [“no_mc_groups”]=>
    array(3) {
    [0]=>
    string(7) “comment”
    [1]=>
    string(6) “counts”
    [2]=>
    string(7) “plugins”
    }

    but i cannot find the code to define this. Where is it?

    Thread Starter kn007

    (@kn007)

    ok, i found.

    ./wp-includes/ms-blogs.php:659: wp_cache_add_non_persistent_groups( array( ‘comment’, ‘counts’, ‘plugins’ ) );
    ./wp-includes/ms-blogs.php:730: wp_cache_add_non_persistent_groups( array( ‘comment’, ‘counts’, ‘plugins’ ) );
    ./wp-includes/load.php:477: wp_cache_add_non_persistent_groups( array( ‘comment’, ‘counts’, ‘plugins’ ) );

    i change to
    wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );

    it ‘s work, now:
    Had 12 queries in 0.0158 seconds, page to load in 7.716 seconds, using 52.34MB memory.

    all right, memory using still large, but less queries.

    any idea to optimize the memory?

    Thread Starter kn007

    (@kn007)

    WTF, when i do this, my site only can see the parent(=0) comments, the children comments cannot see.

    why!?

    Jon (Kenshino)

    (@kenshino)

    Lord Jon

    Once you start altering core files, it’s difficult for anyone to help you.

    Post 1 question in each topic instead of going off with multiple posts. I don’t even know where to begin.

    Closing this so you can start something new.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘_prime_comment_caches() is using too much memory’ is closed to new replies.