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 2021/04/13 22:19:28 UTC

[GitHub] [geode] upthewaterspout commented on a change in pull request #6296: GEODE-9136: make RedisData implement Sizeable

upthewaterspout commented on a change in pull request #6296:
URL: https://github.com/apache/geode/pull/6296#discussion_r612810877



##########
File path: geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisHash.java
##########
@@ -58,6 +59,9 @@
   private ConcurrentHashMap<UUID, List<ByteArrayWrapper>> hScanSnapShots;
   private ConcurrentHashMap<UUID, Long> hScanSnapShotCreationTimes;
   private ScheduledExecutorService HSCANSnapshotExpirationExecutor = null;
+  private static final int PER_STRING_OVERHEAD = PER_OBJECT_OVERHEAD + 46;
+  private static final int PER_HASH_OVERHEAD = PER_OBJECT_OVERHEAD + 116;
+  private AtomicInteger hashSize = new AtomicInteger(PER_HASH_OVERHEAD);

Review comment:
       Does this need to be an `AtomicInteger` or will just an `int` do? I see all of our update methods are synchronized, and I don't think the HashMap is safe under concurrent modification.

##########
File path: geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisHash.java
##########
@@ -145,13 +148,15 @@ private void shutDownHscanSnapshotScheduledRemoval() {
   public synchronized void toData(DataOutput out, SerializationContext context) throws IOException {
     super.toData(out, context);
     DataSerializer.writeHashMap(hash, out);
+    DataSerializer.writeInteger(hashSize.get(), out);

Review comment:
       I wonder if we actually want to serialize this field or just recompute it during deserialization? 

##########
File path: geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisHash.java
##########
@@ -58,6 +59,9 @@
   private ConcurrentHashMap<UUID, List<ByteArrayWrapper>> hScanSnapShots;
   private ConcurrentHashMap<UUID, Long> hScanSnapShotCreationTimes;
   private ScheduledExecutorService HSCANSnapshotExpirationExecutor = null;
+  private static final int PER_STRING_OVERHEAD = PER_OBJECT_OVERHEAD + 46;
+  private static final int PER_HASH_OVERHEAD = PER_OBJECT_OVERHEAD + 116;

Review comment:
       I wonder if we need unit tests of these constants, so we remember to update them if someone changes the code?

##########
File path: geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisSet.java
##########
@@ -46,16 +47,23 @@
 import org.apache.geode.redis.internal.delta.RemsDeltaInfo;
 
 public class RedisSet extends AbstractRedisData {
-
   private HashSet<ByteArrayWrapper> members;
 
+  private static final int PER_MEMBER_OVERHEAD = PER_OBJECT_OVERHEAD + 70;
+  private static final int PER_SET_OVERHEAD = PER_OBJECT_OVERHEAD + 240;
+
+  private AtomicInteger setSize = new AtomicInteger(PER_SET_OVERHEAD);

Review comment:
       Some atomic question here.




-- 
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