Skip to content

Commit

Permalink
Fixing issue where RamUsageEstimator is getting initialized for every…
Browse files Browse the repository at this point in the history
… key. Thanks to @peteralfonsi

Signed-off-by: Sagar Upadhyaya <[email protected]>
  • Loading branch information
sgup432 committed Jan 2, 2024
1 parent 25b12e5 commit 00091c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public final class IndicesRequestCache implements RemovalListener<IndicesRequest
Property.NodeScope
);

private final static long BASE_RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(Key.class);

private final ConcurrentMap<CleanupKey, Boolean> registeredClosedListeners = ConcurrentCollections.newConcurrentMap();
private final Set<CleanupKey> keysToClean = ConcurrentCollections.newConcurrentSet();
private final ByteSizeValue size;
Expand Down Expand Up @@ -265,8 +267,6 @@ interface CacheEntity extends Accountable, Writeable {
* @opensearch.internal
*/
class Key implements Accountable, Writeable {
private final long BASE_RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(Key.class);

public final CacheEntity entity; // use as identity equality
public final String readerCacheKeyId;
public final BytesReference value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ public class IndicesService extends AbstractLifecycleComponent
Property.Final
);

private static long BASE_RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(IndexShardCacheEntity.class);

/**
* The node's settings.
*/
Expand Down Expand Up @@ -1757,7 +1759,6 @@ private BytesReference cacheShardLevelResult(
* @opensearch.internal
*/
public final class IndexShardCacheEntity extends AbstractIndexShardCacheEntity {
private final long BASE_RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(IndexShardCacheEntity.class);
private final IndexShard indexShard;

public IndexShardCacheEntity(IndexShard indexShard) {
Expand Down

0 comments on commit 00091c3

Please sign in to comment.