Repository: microsoft/garnet
File: libs/server/Servers/GarnetServerOptions.cs (C#)

Code before:

        /// <summary>Max size of object store hash index (cache lines) after rounding down size in bytes to power of 2.</summary>
        public int AdjustedObjectStoreIndexMaxCacheLines;

        /// <summary>
        /// Directories on server from which custom command binaries can be loaded by admin users
        /// </summary>
        public string[] ExtensionBinPaths;

        /// <summary>
        /// Allow loading custom commands from digitally unsigned assemblies
        /// </summary>
        public bool ExtensionAllowUnsignedAssemblies;

        /// <summary>
        /// Constructor
        /// </summary>
        public GarnetServerOptions(ILogger logger = null) : base(logger)
        {
            this.logger = logger;
        }

        /// <summary>
        /// Get KVSettings for the main store log
        /// </summary>
        public KVSettings<SpanByte, SpanByte> GetSettings(ILoggerFactory loggerFactory, ILogger logger, out INamedDeviceFactory logFactory)
        {
            if (MutablePercent is < 10 or > 95)
                throw new Exception("MutablePercent must be between 10 and 95");

            KVSettings<SpanByte, SpanByte> kvSettings = new(baseDir: null, logger: logger);

            var indexCacheLines = IndexSizeCachelines("hash index size", IndexSize);
            kvSettings = new()
            {
                IndexSize = indexCacheLines * 64L,
                PreallocateLog = false,
                MutableFraction = MutablePercent / 100.0,
                PageSize = 1L << PageSizeBits(),
                loggerFactory = loggerFactory,
                logger = logger
            };

            logger?.LogInformation("[Store] Using page size of {PageSize}", PrettySize(kvSettings.PageSize));

            kvSettings.MemorySize = 1L << MemorySizeBits(MemorySize, PageSize, out var storeEmptyPageCount);
            kvSettings.MinEmptyPageCount = storeEmptyPageCount;

            long effectiveSize = kvSettings.MemorySize - storeEmptyPageCount * kvSettings.MemorySize;
            if (storeEmptyPageCount == 0)
                logger?.LogInformation("[Store] Using log memory size of {MemorySize}", PrettySize(kvSettings.MemorySize));

Review comment (suggestion):
Probably cleaner to instantiate the logger within this method as you're already supplying the logger factory. Also probably a good idea to either rename the out parameter or add an XML comment, since it might be confusing (loggerFactory vs. logFactory).

Code after:

        /// <summary>Max size of object store hash index (cache lines) after rounding down size in bytes to power of 2.</summary>
        public int AdjustedObjectStoreIndexMaxCacheLines;

        /// <summary>
        /// Directories on server from which custom command binaries can be loaded by admin users
        /// </summary>
        public string[] ExtensionBinPaths;

        /// <summary>
        /// Allow loading custom commands from digitally unsigned assemblies
        /// </summary>
        public bool ExtensionAllowUnsignedAssemblies;

        /// <summary>
        /// Constructor
        /// </summary>
        public GarnetServerOptions(ILogger logger = null) : base(logger)
        {
            this.logger = logger;
        }

        /// <summary>
        /// Get main store settings
        /// </summary>
        /// <param name="loggerFactory">Logger factory for debugging and error tracing</param>
        /// <param name="logFactory">Tsavorite Log factory instance</param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public KVSettings<SpanByte, SpanByte> GetSettings(ILoggerFactory loggerFactory, out INamedDeviceFactory logFactory)
        {
            if (MutablePercent is < 10 or > 95)
                throw new Exception("MutablePercent must be between 10 and 95");

            KVSettings<SpanByte, SpanByte> kvSettings = new(baseDir: null, logger: logger);

            var indexCacheLines = IndexSizeCachelines("hash index size", IndexSize);
            kvSettings = new()
            {
                IndexSize = indexCacheLines * 64L,
                PreallocateLog = false,
                MutableFraction = MutablePercent / 100.0,
                PageSize = 1L << PageSizeBits(),
                loggerFactory = loggerFactory,
                logger = loggerFactory?.CreateLogger("TsavoriteKV [main]")
            };

            logger?.LogInformation("[Store] Using page size of {PageSize}", PrettySize(kvSettings.PageSize));

            kvSettings.MemorySize = 1L << MemorySizeBits(MemorySize, PageSize, out var storeEmptyPageCount);
            kvSettings.MinEmptyPageCount = storeEmptyPageCount;