bdeggleston commented on code in PR #2144:
URL: https://github.com/apache/cassandra/pull/2144#discussion_r1127012212


##########
src/java/org/apache/cassandra/service/accord/AccordStateCache.java:
##########
@@ -149,17 +145,12 @@ public NamedMap(String name)
         }
     }
 
-    public final Map<Object, Node<?, ?>> active = new HashMap<>();
     private final Map<Object, Node<?, ?>> cache = new HashMap<>();
-    private final Map<Object, WriteOnlyGroup<?, ?>> pendingWriteOnly = new 
HashMap<>();
-    private final Set<Instance<?, ?>> instances = new HashSet<>();
-
-    private final NamedMap<Object, Future<?>> loadFutures = new 
NamedMap<>("loadFutures");
-    private final NamedMap<Object, Future<?>> saveFutures = new 
NamedMap<>("saveFutures");
+    private final Set<Instance<?, ?, ?>> instances = new HashSet<>();
 
-    private final NamedMap<Object, Future<Data>> readFutures = new 
NamedMap<>("readFutures");
-    private final NamedMap<Object, Future<?>> writeFutures = new 
NamedMap<>("writeFutures");
+    private final NamedMap<Object, AsyncResult<Void>> saveResults = new 
NamedMap<>("saveResults");
 
+    private int linked = 0;

Review Comment:
   So from the expected cache behavior perspective, we should be inserting into 
this list as soon as it becomes unreferenced, because it’s tracking the least 
recently used objects
   
   Jumping over a handful of stragglers isn’t optimal, but still qualifies as 
negligible I think. 
   The full/empty case is more of a concern though, and something that would be 
more likely with smaller cache sizes. I haven't thought of any solutions that 
don't cause their own problems. 
   The extra link idea doesn’t really work because the cache passively updates 
it’s state by iterating over the linked list, so that additional link would 
never be made.
   
   WDYT about calling maybeEvict periodically, instead as part of 
reference/release? That would at least bound the amount of wasted work in 
extreme cases without adding any complexity to the cache



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to