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/16 20:15:23 UTC

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

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