[ 
https://issues.apache.org/jira/browse/HIVE-21686?focusedWorklogId=241487&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-241487
 ]

ASF GitHub Bot logged work on HIVE-21686:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 14/May/19 03:49
            Start Date: 14/May/19 03:49
    Worklog Time Spent: 10m 
      Work Description: b-slim commented on pull request #626: [HIVE-21686] 
ensure that memory allocator does not evict using brute …
URL: https://github.com/apache/hive/pull/626#discussion_r283616699
 
 

 ##########
 File path: 
llap-server/src/test/org/apache/hadoop/hive/llap/cache/TestCacheAllocationsEvictionsCycles.java
 ##########
 @@ -0,0 +1,324 @@
+/*
+ * 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.hadoop.hive.llap.cache;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.common.io.Allocator;
+import org.apache.hadoop.hive.common.io.encoded.MemoryBuffer;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.llap.io.metadata.MetadataCache;
+import org.apache.hadoop.hive.llap.metrics.LlapDaemonCacheMetrics;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Test the full cycle of allocation/accounting/eviction interactions.
+ */
+public class TestCacheAllocationsEvictionsCycles {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(TestCacheAllocationsEvictionsCycles.class);
+  private static final LlapDaemonCacheMetrics cacheMetrics = 
LlapDaemonCacheMetrics.create("testCache", "testSession");
+
+  private final long maxSize = 1024;
+  private final LowLevelCache dataCache = Mockito.mock(LowLevelCache.class);
+  private final SerDeLowLevelCacheImpl serdCache = 
Mockito.mock(SerDeLowLevelCacheImpl.class);
+  private final MetadataCache metaDataCache = 
Mockito.mock(MetadataCache.class);
+
+  private BuddyAllocator allocator;
+  private MemoryManager memoryManager;
+  private LowLevelCachePolicy cachePolicy;
+  private EvictionTracker evictionTracker;
+
+  @Before public void setUp() throws Exception {
+    Configuration conf = new Configuration();
+    // Set lambda to 1 so the heap size becomes 1 (LRU).
+    conf.setDouble(HiveConf.ConfVars.LLAP_LRFU_LAMBDA.varname, 1.0f);
+    int minBufferSize = 1;
+    cachePolicy = new LowLevelLrfuCachePolicy(minBufferSize, maxSize, conf);
+    memoryManager = new LowLevelCacheMemoryManager(maxSize, cachePolicy, 
cacheMetrics);
+    int maxAllocationSize = 1024;
+    int minAllocationSize = 8;
+    allocator =
+        new BuddyAllocator(true,
+            false,
+            minAllocationSize,
+            maxAllocationSize,
+            1,
+            maxSize,
+            0,
+            null,
+            memoryManager,
+            cacheMetrics,
+            "no-force-eviction",
+            true, 1024 * 1024 * 128);
+    EvictionDispatcher evictionDispatcher = new EvictionDispatcher(dataCache, 
serdCache, metaDataCache, allocator);
+    evictionTracker = new EvictionTracker(evictionDispatcher);
+    cachePolicy.setEvictionListener(evictionTracker);
+  }
+
+  @After public void tearDown() throws Exception {
+    LOG.info("Purge the cache on tear down");
+    cachePolicy.purge();
+    allocator = null;
+    memoryManager = null;
+    cachePolicy = null;
+  }
+
+  /**
+   * Test case to ensure that deallocate it does merge small blocks into 
bigger ones.
+   */
+  @Test(timeout = 6_000L) public void TestMergeOfBlocksAfterDeallocate() {
 
 Review comment:
   fixed.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 241487)
    Time Spent: 3.5h  (was: 3h 20m)

> Brute Force eviction can lead to a random uncontrolled eviction pattern.
> ------------------------------------------------------------------------
>
>                 Key: HIVE-21686
>                 URL: https://issues.apache.org/jira/browse/HIVE-21686
>             Project: Hive
>          Issue Type: Bug
>            Reporter: slim bouguerra
>            Assignee: slim bouguerra
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: Cache_hitrate_improvement.csv, HIVE-21686.2.patch, 
> HIVE-21686.patch
>
>          Time Spent: 3.5h
>  Remaining Estimate: 0h
>
> Current logic used by brute force eviction can lead to a perpetual random 
> eviction pattern.
> For instance if the cache build a small pocket of free memory where the total 
> size is greater than incoming allocation request, the allocator will randomly 
> evict block that fits a particular size.
> This can happen over and over therefore all the eviction will be random.
> In Addition this random eviction will lead a leak in the linked list 
> maintained by the policy since it does not know anymore about what is evicted 
> and what not.
> The improvement of this patch is very substantial  to TPC-DS benchmark. I 
> have tested it with 10TB scale 9 llap nodes and 32GB cache size per node.  
> The patch has showed very noticeable difference in the Hit rate for raw 
> number  [^Cache_hitrate_improvement.csv] 



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

Reply via email to