{"record":{"id":"d39d91cafb739988","repo":"microsoft/FASTER","slug":"page-size-must-be-at-least-of-device-sector-size-sectorsize","errorCode":null,"errorMessage":"Page size must be at least of device sector size ({sectorSize} bytes). Set PageSizeBits accordingly.","messagePattern":"Page size must be at least of device sector size \\((.+?) bytes\\)\\. Set PageSizeBits accordingly\\.","errorType":"exception","errorClass":"FasterException","httpStatus":null,"severity":"error","filePath":"cs/src/core/Allocator/AllocatorBase.cs","lineNumber":1028,"sourceCode":"            if (SegmentSize < PageSize)\n                throw new FasterException($\"Segment ({SegmentSize}) must be at least of page size ({PageSize})\");\n\n            if ((LogTotalSizeBits != 0) && (LogTotalSizeBytes < PageSize))\n                throw new FasterException($\"Memory size ({LogTotalSizeBytes}) must be configured to be either 1 (i.e., 0 bits) or at least page size ({PageSize})\");\n\n            PageStatusIndicator = new FullPageStatus[BufferSize];\n\n            if (!IsNullDevice)\n            {\n                PendingFlush = new PendingFlushList[BufferSize];\n                for (int i = 0; i < BufferSize; i++)\n                    PendingFlush[i] = new PendingFlushList();\n            }\n            device = settings.LogDevice;\n            sectorSize = (int)device.SectorSize;\n\n            if (PageSize < sectorSize)\n                throw new FasterException($\"Page size must be at least of device sector size ({sectorSize} bytes). Set PageSizeBits accordingly.\");\n\n            AlignedPageSizeBytes = (PageSize + (sectorSize - 1)) & ~(sectorSize - 1);\n        }\n\n        /// <summary>\n        /// Number of extra overflow pages allocated\n        /// </summary>\n        internal abstract int OverflowPageCount { get; }\n\n\n        /// <summary>\n        /// Reset the hybrid log. WARNING: assumes that threads have drained out at this point.\n        /// </summary>\n        public virtual void Reset()\n        {\n            var newBeginAddress = GetTailAddress();\n\n            // Shift read-only addresses to tail without flushing","sourceCodeStart":1010,"sourceCodeEnd":1046,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/src/core/Allocator/AllocatorBase.cs#L1010-L1046","documentation":"FASTER aligns pages to the underlying device's sector size so I/O is done on sector boundaries. Each page (1 << PageSizeBits) must be at least as large as the log device's reported SectorSize; otherwise reads/writes cannot be aligned correctly. The allocator queries device.SectorSize at construction and throws if PageSize is smaller.","triggerScenarios":"Using a device with a large sector size (e.g. 4096-byte AzureStorageDevice or certain SSDs) while LogSettings.PageSizeBits is too small, e.g. PageSizeBits=8 (256 bytes) against a 4KB-sector device.","commonSituations":"Cloud-storage devices (Azure blob) report 4KB sectors while users configure small pages for unit tests; compressed/QCOW or network devices reporting non-512 sector sizes.","solutions":["Increase LogSettings.PageSizeBits so PageSize >= device.SectorSize (e.g. at least 12 bits for 4KB sectors).","Check the actual sector size of your device (device.SectorSize) before choosing PageSizeBits.","Use a device whose sector size matches your page configuration (e.g. a local emulation device with 512-byte sectors for small-page tests)."],"exampleFix":"// before\nvar settings = new LogSettings {\n  LogDevice = new AzureStorageDevice(\"...\"), // 4096-byte sectors\n  PageSizeBits = 9 // 512B < 4096B sector size\n};\n\n// after\nvar settings = new LogSettings {\n  LogDevice = new AzureStorageDevice(\"...\"),\n  PageSizeBits = 12 // 4KB >= sector size\n};","handlingStrategy":"validation","validationCode":"if ((1 << settings.PageSizeBits) < settings.LogDevice.SectorSize)\n    throw new ArgumentException($\"PageSize ({1 << settings.PageSizeBits}) must be >= device sector size ({settings.LogDevice.SectorSize})\");","typeGuard":"bool PageMeetsSector(LogSettings s) => s.LogDevice != null && (1L << s.PageSizeBits) >= s.LogDevice.SectorSize;","tryCatchPattern":"try { var fht = new FasterKV<K, V>(size, settings); }\ncatch (FasterException ex) when (ex.Message.Contains(\"device sector size\")) { /* increase PageSizeBits */ }","preventionTips":["Check device.SectorSize after creating the device and size PageSizeBits accordingly.","Use PageSizeBits >= 12 (4KB) for cloud/4K-sector devices.","Prefer small-sector local devices for small-page tests."],"tags":["csharp","configuration","faster","sector-alignment"],"backgroundTag":"invalid-config-value","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"}