You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/11/05 18:45:38 UTC

[GitHub] [geode-native] gaussianrecurrence opened a new pull request #687: GEODE-8537: Solve memory increase when LRU eviction is enabled

gaussianrecurrence opened a new pull request #687:
URL: https://github.com/apache/geode-native/pull/687


   - Whenever LRU eviction was enabled it was noted an slight increase in the memory usage.
     Specifically in an scenario in which a set of entries are continously created and destroyed.
   - Problem was that entries within LRUList where inserted but not removed until LRU
      eviction happened and in the described case above, that was never.
   - Solution was to replace the LRUList by a refactored version called LRUQueue and
     also to remove the entries from the queue upon destroy or invalidation.
   - Also a dead-lock between EvictionController and EvictionThread has been solved.
     However this part is asking for a refactor.
   - Unit tests have been added for the LRUQueue.
   - Integration test have been added in the new integration test for the LRU eviction.
   - Also a wrongly implemented LRU eviction test was removed from the old integration tests.
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode-native] gaussianrecurrence commented on a change in pull request #687: GEODE-8537: Solve memory increase when LRU eviction is enabled

Posted by GitBox <gi...@apache.org>.
gaussianrecurrence commented on a change in pull request #687:
URL: https://github.com/apache/geode-native/pull/687#discussion_r524585761



##########
File path: cppcache/src/LRUQueue.hpp
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#ifndef GEODE_LRUQUEUE_H_
+#define GEODE_LRUQUEUE_H_
+
+#include <list>
+#include <memory>
+
+#include <geode/internal/geode_globals.hpp>
+
+#include "util/concurrent/spinlock_mutex.hpp"
+
+namespace apache {
+namespace geode {
+namespace client {
+
+class MapEntryImpl;
+
+/**
+ * This class holds a queue of entries sorted by its use order
+ * @note All accesses to the queue are mutually exclusive
+ */
+class LRUQueue {

Review comment:
       Regarding why it is needed a custom written queue. There are several reason why:
   
   1. I wanted to encapsulate LRUProperties iterator management inside a class, so any code using the LRUQueue does not have to take care of that.
   2. Usually, queues does not allow to remove entries at a random position, which would not make possible to clear deleted entries, which is the whole point of this PR.
   3. There is no queue implementation that allows to take an entry and move it to its end.
   
   What I am not sure about is wether to use a spinlock, an standard mutex or put some effort and try to write a completly lock-free thread-safe LRU queue :S




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode-native] pdxcodemonkey commented on a change in pull request #687: GEODE-8537: Solve memory increase when LRU eviction is enabled

Posted by GitBox <gi...@apache.org>.
pdxcodemonkey commented on a change in pull request #687:
URL: https://github.com/apache/geode-native/pull/687#discussion_r525526299



##########
File path: cppcache/src/LRUQueue.hpp
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#ifndef GEODE_LRUQUEUE_H_
+#define GEODE_LRUQUEUE_H_
+
+#include <list>
+#include <memory>
+
+#include <geode/internal/geode_globals.hpp>
+
+#include "util/concurrent/spinlock_mutex.hpp"
+
+namespace apache {
+namespace geode {
+namespace client {
+
+class MapEntryImpl;
+
+/**
+ * This class holds a queue of entries sorted by its use order
+ * @note All accesses to the queue are mutually exclusive
+ */
+class LRUQueue {

Review comment:
       I'd just use a standard mutex.  Thanks for the clarification on the need for the LRUQueue, I hadn't paid close enough attention to what it was doing and missed the random-access feature.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode-native] gaussianrecurrence commented on pull request #687: GEODE-8537: Solve memory increase when LRU eviction is enabled

Posted by GitBox <gi...@apache.org>.
gaussianrecurrence commented on pull request #687:
URL: https://github.com/apache/geode-native/pull/687#issuecomment-725326162


   Maybe @moleske @pivotal-jbarrett @mreddington @pdxcodemonkey you could throw some comments?
   
   Thanks!


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode-native] codecov-io commented on pull request #687: GEODE-8537: Solve memory increase when LRU eviction is enabled

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #687:
URL: https://github.com/apache/geode-native/pull/687#issuecomment-729161638


   # [Codecov](https://codecov.io/gh/apache/geode-native/pull/687?src=pr&el=h1) Report
   > Merging [#687](https://codecov.io/gh/apache/geode-native/pull/687?src=pr&el=desc) (98a14aa) into [develop](https://codecov.io/gh/apache/geode-native/commit/0e9463d69e7be5455a351eae23b87cef9b2382ac?el=desc) (0e9463d) will **decrease** coverage by `0.39%`.
   > The diff coverage is `89.42%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/geode-native/pull/687/graphs/tree.svg?width=650&height=150&src=pr&token=plpAqoqGag)](https://codecov.io/gh/apache/geode-native/pull/687?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff             @@
   ##           develop     #687      +/-   ##
   ===========================================
   - Coverage    74.37%   73.97%   -0.40%     
   ===========================================
     Files          644      644              
     Lines        51189    51054     -135     
   ===========================================
   - Hits         38070    37767     -303     
   - Misses       13119    13287     +168     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/geode-native/pull/687?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [cppcache/integration-test/testRegionMap.cpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvaW50ZWdyYXRpb24tdGVzdC90ZXN0UmVnaW9uTWFwLmNwcA==) | `100.00% <ø> (ø)` | |
   | [cppcache/src/EvictionController.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL0V2aWN0aW9uQ29udHJvbGxlci5ocHA=) | `100.00% <ø> (ø)` | |
   | [cppcache/src/LRUEntriesMap.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL0xSVUVudHJpZXNNYXAuaHBw) | `76.92% <ø> (ø)` | |
   | [cppcache/src/LRUExpMapEntry.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL0xSVUV4cE1hcEVudHJ5LmhwcA==) | `11.76% <ø> (ø)` | |
   | [cppcache/src/LRUMapEntry.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL0xSVU1hcEVudHJ5LmhwcA==) | `80.00% <ø> (ø)` | |
   | [cppcache/src/LocalRegion.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL0xvY2FsUmVnaW9uLmhwcA==) | `86.36% <ø> (ø)` | |
   | [cppcache/src/RegionInternal.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL1JlZ2lvbkludGVybmFsLmhwcA==) | `100.00% <ø> (ø)` | |
   | [cppcache/test/mock/MapEntryImplMock.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvdGVzdC9tb2NrL01hcEVudHJ5SW1wbE1vY2suaHBw) | `44.44% <44.44%> (ø)` | |
   | [cppcache/src/LRUEntriesMap.cpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL0xSVUVudHJpZXNNYXAuY3Bw) | `60.08% <63.63%> (+8.10%)` | :arrow_up: |
   | [cppcache/src/LRUEntryProperties.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL0xSVUVudHJ5UHJvcGVydGllcy5ocHA=) | `88.88% <88.88%> (ø)` | |
   | ... and [32 more](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/geode-native/pull/687?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/geode-native/pull/687?src=pr&el=footer). Last update [0791032...98a14aa](https://codecov.io/gh/apache/geode-native/pull/687?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode-native] codecov-io edited a comment on pull request #687: GEODE-8537: Solve memory increase when LRU eviction is enabled

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #687:
URL: https://github.com/apache/geode-native/pull/687#issuecomment-729161638


   # [Codecov](https://codecov.io/gh/apache/geode-native/pull/687?src=pr&el=h1) Report
   > Merging [#687](https://codecov.io/gh/apache/geode-native/pull/687?src=pr&el=desc) (f57fbc7) into [develop](https://codecov.io/gh/apache/geode-native/commit/96faa995c4e61e464f5366693a1d2616f2c28508?el=desc) (96faa99) will **decrease** coverage by `0.10%`.
   > The diff coverage is `89.42%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/geode-native/pull/687/graphs/tree.svg?width=650&height=150&src=pr&token=plpAqoqGag)](https://codecov.io/gh/apache/geode-native/pull/687?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff             @@
   ##           develop     #687      +/-   ##
   ===========================================
   - Coverage    74.10%   74.00%   -0.11%     
   ===========================================
     Files          644      644              
     Lines        51084    50949     -135     
   ===========================================
   - Hits         37854    37703     -151     
   - Misses       13230    13246      +16     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/geode-native/pull/687?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [cppcache/integration-test/testRegionMap.cpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvaW50ZWdyYXRpb24tdGVzdC90ZXN0UmVnaW9uTWFwLmNwcA==) | `100.00% <ø> (ø)` | |
   | [cppcache/src/EvictionController.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL0V2aWN0aW9uQ29udHJvbGxlci5ocHA=) | `100.00% <ø> (ø)` | |
   | [cppcache/src/LRUEntriesMap.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL0xSVUVudHJpZXNNYXAuaHBw) | `76.92% <ø> (ø)` | |
   | [cppcache/src/LRUExpMapEntry.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL0xSVUV4cE1hcEVudHJ5LmhwcA==) | `11.76% <ø> (ø)` | |
   | [cppcache/src/LRUMapEntry.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL0xSVU1hcEVudHJ5LmhwcA==) | `80.00% <ø> (ø)` | |
   | [cppcache/src/LocalRegion.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL0xvY2FsUmVnaW9uLmhwcA==) | `86.36% <ø> (ø)` | |
   | [cppcache/src/RegionInternal.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL1JlZ2lvbkludGVybmFsLmhwcA==) | `100.00% <ø> (ø)` | |
   | [cppcache/test/mock/MapEntryImplMock.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvdGVzdC9tb2NrL01hcEVudHJ5SW1wbE1vY2suaHBw) | `44.44% <44.44%> (ø)` | |
   | [cppcache/src/LRUEntriesMap.cpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL0xSVUVudHJpZXNNYXAuY3Bw) | `60.08% <63.63%> (+8.10%)` | :arrow_up: |
   | [cppcache/src/LRUEntryProperties.hpp](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree#diff-Y3BwY2FjaGUvc3JjL0xSVUVudHJ5UHJvcGVydGllcy5ocHA=) | `88.88% <88.88%> (ø)` | |
   | ... and [23 more](https://codecov.io/gh/apache/geode-native/pull/687/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/geode-native/pull/687?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/geode-native/pull/687?src=pr&el=footer). Last update [96faa99...f57fbc7](https://codecov.io/gh/apache/geode-native/pull/687?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode-native] pdxcodemonkey commented on a change in pull request #687: GEODE-8537: Solve memory increase when LRU eviction is enabled

Posted by GitBox <gi...@apache.org>.
pdxcodemonkey commented on a change in pull request #687:
URL: https://github.com/apache/geode-native/pull/687#discussion_r524527337



##########
File path: cppcache/src/LRUQueue.hpp
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#ifndef GEODE_LRUQUEUE_H_
+#define GEODE_LRUQUEUE_H_
+
+#include <list>
+#include <memory>
+
+#include <geode/internal/geode_globals.hpp>
+
+#include "util/concurrent/spinlock_mutex.hpp"
+
+namespace apache {
+namespace geode {
+namespace client {
+
+class MapEntryImpl;
+
+/**
+ * This class holds a queue of entries sorted by its use order
+ * @note All accesses to the queue are mutually exclusive
+ */
+class LRUQueue {

Review comment:
       boost::lockfree::queue, maybe?  If this is just a generic thread-safe queue implementation, we really shouldn't be writing our own.  This one uses our own hand-rolled mutex for locking, as well, which is _also_ a thing that we should never have written, that should be removed from the codebase altogether.  

##########
File path: cppcache/src/EvictionController.hpp
##########
@@ -75,29 +73,27 @@ class EvictionController {
 
   void svc(void);
 
-  void updateRegionHeapInfo(int64_t info);
-  void registerRegion(const std::string& name);
-  void deregisterRegion(const std::string& name);
-  void evict(int32_t percentage);
+  void evict(float percentage);
+  void inc_heap_size(int64_t delta);
+  void register_region(const std::string& name);
+  void unregister_region(const std::string& name);

Review comment:
       The style guide (I re-learned after reviewing it) dictates snake case for variables and setter/getter functions, and mixed case otherwise.  I prefer the mixed case for method names, for consistency if nothing else - can we change the instances of this in the PR?

##########
File path: cppcache/src/LRUQueue.hpp
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#ifndef GEODE_LRUQUEUE_H_
+#define GEODE_LRUQUEUE_H_
+
+#include <list>
+#include <memory>
+
+#include <geode/internal/geode_globals.hpp>
+
+#include "util/concurrent/spinlock_mutex.hpp"
+
+namespace apache {
+namespace geode {
+namespace client {
+
+class MapEntryImpl;
+
+/**
+ * This class holds a queue of entries sorted by its use order
+ * @note All accesses to the queue are mutually exclusive
+ */
+class LRUQueue {

Review comment:
       Let us know if there's some reason here we can't use an off-the-shelf queue solution.  Otherwise, let's use one of those.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode-native] gaussianrecurrence edited a comment on pull request #687: GEODE-8537: Solve memory increase when LRU eviction is enabled

Posted by GitBox <gi...@apache.org>.
gaussianrecurrence edited a comment on pull request #687:
URL: https://github.com/apache/geode-native/pull/687#issuecomment-725326162


   Maybe @moleske @pivotal-jbarrett @mreddington @pdxcodemonkey @mivanac you could throw some comments?
   
   Thanks!


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode-native] pdxcodemonkey merged pull request #687: GEODE-8537: Solve memory increase when LRU eviction is enabled

Posted by GitBox <gi...@apache.org>.
pdxcodemonkey merged pull request #687:
URL: https://github.com/apache/geode-native/pull/687


   


----------------------------------------------------------------
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:
users@infra.apache.org