phoenix-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PHOENIX-5069) Use asynchronous refresh to provide non-blocking Phoenix Stats Client Cache
Date Tue, 08 Jan 2019 01:27:00 GMT

    [ https://issues.apache.org/jira/browse/PHOENIX-5069?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16736561#comment-16736561
] 

ASF GitHub Bot commented on PHOENIX-5069:
-----------------------------------------

Github user karanmehta93 commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/425#discussion_r245853048
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/query/PhoenixStatsCacheLoader.java
---
    @@ -0,0 +1,73 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.phoenix.query;
    +
    +import com.google.common.cache.CacheLoader;
    +import com.google.common.util.concurrent.ListenableFuture;
    +import com.google.common.util.concurrent.ListenableFutureTask;
    +import org.apache.phoenix.schema.stats.GuidePostsInfo;
    +import org.apache.phoenix.schema.stats.GuidePostsKey;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.concurrent.Callable;
    +import java.util.concurrent.ExecutorService;
    +
    +/**
    + * {@link CacheLoader} implementation for the Phoenix Table Stats cache.
    + */
    +public class PhoenixStatsCacheLoader extends CacheLoader<GuidePostsKey, GuidePostsInfo>
{
    +    private static final Logger logger = LoggerFactory.getLogger(PhoenixStatsCacheLoader.class);
    +
    +    final private PhoenixStatsLoader statsLoader;
    +    final private ExecutorService executor;
    +
    +    public PhoenixStatsCacheLoader(PhoenixStatsLoader statsLoader, ExecutorService executor)
{
    +        super();
    +        this.statsLoader = statsLoader;
    +        this.executor = executor;
    +    }
    +
    +    @Override
    +    public GuidePostsInfo load(GuidePostsKey statsKey) throws Exception {
    +        return statsLoader.loadStats(statsKey, GuidePostsInfo.NO_GUIDEPOST);
    +    }
    +
    +    @Override
    +    public ListenableFuture<GuidePostsInfo> reload(
    +            final GuidePostsKey key,
    +            GuidePostsInfo prevGuidepostInfo)
    +    {
    +        // schedule asynchronous task
    +        ListenableFutureTask<GuidePostsInfo> task =
    --- End diff --
    
    Even though currently `StatsLoaderImpl#needsLoad()` is hardcoded to true, it still should
be called here first. 


> Use asynchronous refresh to provide non-blocking Phoenix Stats Client Cache
> ---------------------------------------------------------------------------
>
>                 Key: PHOENIX-5069
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-5069
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: Bin Shi
>            Assignee: Bin Shi
>            Priority: Major
>
> The current Phoenix Stats Cache uses TTL based eviction policy. A cached entry will expire
after a given amount of time (900s by default) passed since the entry's been created. This
will lead to cache miss when Compiler/Optimizer fetches stats from cache at the next time.
As you can see from the above graph, fetching stats from the cache is a blocking operation
— when there is cache miss, it has a round trip over the wire to scan the SYSTEM.STATS Table
and to get the latest stats info, rebuild the cache and finally return the stats to the Compiler/Optimizer.
Whenever there is a cache miss, this blocking call causes significant performance penalty and
see periodic spikes.
> *This Jira suggests to use asynchronous refresh mechanism to provide a non-blocking
cache. For details, please see the linked design document below.*
> [~karanmehta93] [~twdsilva@gmail.com] [~dbwong] [~elserj] [~ankit@apache.org] [~sergey
soldatov] 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message