{"record":{"id":"e2f60b7d8027bf15","repo":"microsoft/FASTER","slug":"invalid-index-size","errorCode":null,"errorMessage":"Invalid index size","messagePattern":"Invalid index size","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"cs/remote/src/FASTER.server/Servers/ServerOptions.cs","lineNumber":150,"sourceCode":"        /// <returns></returns>\n        public int SegmentSizeBits()\n        {\n            long size = ParseSize(SegmentSize);\n            long adjustedSize = PreviousPowerOf2(size);\n            if (size != adjustedSize)\n                logger?.LogInformation($\"Warning: using lower disk segment size than specified (power of 2)\");\n            return (int)Math.Log(adjustedSize, 2);\n        }\n\n        /// <summary>\n        /// Get index size\n        /// </summary>\n        /// <returns></returns>\n        public int IndexSizeCachelines()\n        {\n            long size = ParseSize(IndexSize);\n            long adjustedSize = PreviousPowerOf2(size);\n            if (adjustedSize < 64 || adjustedSize > (1L << 37)) throw new Exception(\"Invalid index size\");\n            if (size != adjustedSize)\n                logger?.LogInformation($\"Warning: using lower hash index size than specified (power of 2)\");\n            return (int)(adjustedSize / 64);\n        }\n\n        /// <summary>\n        /// Get log settings\n        /// </summary>\n        /// <param name=\"logSettings\"></param>\n        /// <param name=\"checkpointSettings\"></param>\n        /// <param name=\"indexSize\"></param>\n        public void GetSettings(out LogSettings logSettings, out CheckpointSettings checkpointSettings, out int indexSize)\n        {\n            logSettings = new LogSettings { PreallocateLog = false };\n\n            logSettings.PageSizeBits = PageSizeBits();\n            logger?.LogInformation($\"[Store] Using page size of {PrettySize((long)Math.Pow(2, logSettings.PageSizeBits))}\");\n","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/remote/src/FASTER.server/Servers/ServerOptions.cs#L132-L168","documentation":"ServerOptions.IndexSizeCachelines parses the IndexSize option and rounds it down to the previous power of two; if the adjusted hash index size is below 64 bytes or above 2^37 bytes it throws \"Invalid index size\". The hash index must be a power-of-2-sized table within a supported range because addressing masks the low bits of hashes.","triggerScenarios":"Setting ServerOptions.IndexSize to a value that parses to < 64 bytes (e.g. \"32\" or \"0\") or > 128GB (1L<<37), then building the server settings via GetSettings.","commonSituations":"Typo'd units (e.g. \"64k\" interpreted as 64 bytes for a tiny index); misconfigured memory budget strings; copying a log-size value into IndexSize; leaving IndexSize empty or invalid such that ParseSize yields 0.","solutions":["Set IndexSize to a valid power-of-2 byte size between 64 and 128GB, e.g. \"1g\" or \"268435456\".","Compute the index size from expected key count (roughly 64B per ~64 entries * overhead) and keep it comfortably above the 64-byte floor.","Log/inspect the parsed value of IndexSize before server start to catch unit/parse mistakes."],"exampleFix":"// before\noptions.IndexSize = \"32\"; // too small -> throws\n// after\noptions.IndexSize = \"1g\"; // valid power-of-2 index size","handlingStrategy":"validation","validationCode":"long bytes = ParseSize(options.IndexSize);\nif (bytes < 64 || bytes > (1L << 37) || (bytes & (bytes - 1)) != 0)\n    throw new ArgumentException($\"IndexSize must be a power-of-2 between 64 and 128GB, got {options.IndexSize}\");","typeGuard":null,"tryCatchPattern":"try { settings = options.GetSettings(); } catch (Exception) { options.IndexSize = \"1g\"; settings = options.GetSettings(); }","preventionTips":["Always specify IndexSize as an explicit power-of-2 byte size with units (e.g. \"1g\").","Validate config values at startup before constructing the server."],"tags":["csharp","faster","server-options","config","out-of-range"],"backgroundTag":"value-out-of-range","analyzedSha":"321d872eabda6a0345c8bd76419f89723ed864ae","analyzedAt":"2026-09-15T22:18:00.693Z","contentChangedAt":"2026-09-15T22:18:00.693Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}