Raymond Wilson created IGNITE-24634:
---------------------------------------

             Summary: Cache statistics do not track Gets from OffHeap
                 Key: IGNITE-24634
                 URL: https://issues.apache.org/jira/browse/IGNITE-24634
             Project: Ignite
          Issue Type: Bug
          Components: cache
    Affects Versions: 2.16
            Reporter: Raymond Wilson


When using the C# client on Ignite 2.16, statistics collection for caches 
appears to ignore Gets for element read from the OffHeap in-memory location.

When I run the included reproducer, I get the following output which appears to 
show no Gets were satisfied from OffHeap

Completed: Put count = 1000, Get Count = 2000, OffHeap Gets = 0, Off heap local 
peek count = 1000

If after running an initial time, I comment out the writing and reading 
sections and just perform the peek operations on a subsequent run I get this 
output which implies that even when no get operations have been performed, the 
local peek restricted to OffHeap is reporting the elements are present

Completed: Put count = 0, Get Count = 0, OffHeap Gets = 0, Off heap local peek 
count = 1000

Code for reproducer is as follows:


using System;
using System.Collections.Generic;
using System.IO;
using Apache.Ignite.Core;
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Configuration;

namespace OutOfMemoryReproducer
{
  static class Program
  {
    public static ICache<string, byte[]> cache;

    static void Main()
    {
      // Make the server
      var cfgServer = new IgniteConfiguration
      {
        IgniteInstanceName = "Server",
        JvmMaxMemoryMb = 1024,
        JvmInitialMemoryMb = 512,
        DataStorageConfiguration = new DataStorageConfiguration
        {
          WalMode = WalMode.Fsync,
          PageSize = 16 * 1024, // Failure does not occur when using default 
page size of 4096
          StoragePath = Path.Combine(@"c:\temp", "ErrorReproducer", 
"Persistence"),
          WalArchivePath = Path.Combine(@"c:\temp", "ErrorReproducer", 
"WalArchive"),
          WalPath = Path.Combine(@"c:\temp", "ErrorReproducer", "WalStore"),
          DefaultDataRegionConfiguration = new DataRegionConfiguration
          {
            Name = "Default",
            InitialSize = 64 * 1024 * 1024, // 128 MB
            MaxSize = 2L * 1024 * 1024 * 1024, // 2 GB

            PersistenceEnabled = true
          }
        },
        JvmOptions = new List<string>() {"-DIGNITE_QUIET=false", 
"-Djava.net.preferIPv4Stack=true", "-XX:+UseG1GC"},
        WorkDirectory = Path.Combine(@"c:\temp", "ErrorReproducer")
      };

      var igniteServer = Ignition.Start(cfgServer);

      // Activate the grid
      igniteServer.GetCluster().SetActive(true);

      // Set up the cache
      var cacheCfgServer = new CacheConfiguration {Name = "BufferQueueCache", 
KeepBinaryInStore = true, CacheMode = CacheMode.Partitioned, DataRegionName = 
"Default"};
      cache = igniteServer.GetOrCreateCache<string, byte[]>(cacheCfgServer);

      // Instruct the cache to collect operational statistics
      cache.EnableStatistics(true);

      var numEntriesToTest = 1000;

      // Write a series of elements
      for (var i = 0; i < numEntriesToTest; i++)
      {
        cache.Put($"Item {i}", new byte[1]);
        Console.WriteLine($"Put item {i} with 1 bytes");
      }

      // Read a series of elements
      for (var i = 0; i < numEntriesToTest; i++)
      {
        var x = cache.Get($"Item {i}");
        Console.WriteLine($"Get item {i} with {i} bytes");
      }

      // Read a series of elements for a second time
      for (var i = 0; i < numEntriesToTest; i++)
      {
        var x = cache.Get($"Item {i}");
        Console.WriteLine($"Get item {i} with {i} bytes");
      }

      var offHeapLocalPeekCount = 0;

      // Peek a series of elements
      for (var i = 0; i < numEntriesToTest; i++)
      {
        var result = cache.TryLocalPeek($"Item {i}", out var x, 
CachePeekMode.Offheap);
        Console.WriteLine($"Local peek for item {i} in off heap is {result}");

        if (result)
          offHeapLocalPeekCount++;
      }

      // Get the statistics
      var metrics = cache.GetLocalMetrics();
      Console.WriteLine($"Completed: Put count = {metrics.CachePuts}, Get Count 
= {metrics.CacheGets}, OffHeap Gets = {metrics.OffHeapGets}, Off heap local 
peek count = {offHeapLocalPeekCount}");
      Console.ReadKey();
    }
  }
}






--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to