microsoft/FASTER · error · ArgumentException
Size is not 32-bit
Error message
Size {0} is not 32-bit What it means
FASTER's hash table size must be both a power of 2 and representable so that index arithmetic fits in 32 bits; this check in FASTERBase verifies Utility.Is32Bit(size). The library throws ArgumentException because a size violating this invariant cannot be used as the index table size. It is a constructor-argument validation failure, thrown before any store state is created.
Solutions
- Reduce the index size argument so Utility.Is32Bit(size) holds (size below the 2^31 boundary).
- Check size with Utility.Is32Bit(size) && Utility.IsPowerOfTwo(size) before constructing the store.
- If a larger index is required, use multiple store instances or overflow to disk (ReadCopyOptions/segments) instead of one oversized index.
Example fix
// before
var store = new FasterKV<long, long>(1L << 40);
// after
long size = 1L << 28; // power of 2 and 32-bit safe
if (!Utility.Is32Bit(size) || !Utility.IsPowerOfTwo(size))
throw new InvalidOperationException("Index size must be a 32-bit power of 2");
var store = new FasterKV<long, long>(size); Defensive patterns
Strategy: validation
Validate before calling
long size = /* configured index size */;
if (!Utility.IsPowerOfTwo(size) || !Utility.Is32Bit(size))
throw new ArgumentException($"Index size {size} must be a power of 2 and 32-bit representable");
var store = new FasterKV<long, long>(size); Type guard
bool IsValidIndexSize(long size) => size > 0 && Utility.IsPowerOfTwo(size) && Utility.Is32Bit(size);
Try / catch
try { store = new FasterKV<long, long>(size); }
catch (ArgumentException ex) when (ex.Message.Contains("not 32-bit") || ex.Message.Contains("power of 2"))
{ logger.LogError(ex, "Invalid index size {Size}", size); throw new ConfigurationException("Index size must be a 32-bit power of 2", ex); } Prevention
- Clamp user-supplied index sizes to a known-safe maximum (e.g. 2^28) in configuration code.
- Always validate IsPowerOfTwo and Is32Bit before constructing FasterKV.
- Document the 32-bit sizing constraint next to the config key that feeds index size.
When it happens
Trigger: Calling the FasterKV/index constructor (Initialize size path in FASTERBase.cs) with a size that is a power of 2 but exceeds the 32-bit constraint (e.g. size >= 2^31 or values whose derived table size overflows int).
Common situations: Configuring very large in-memory indexes (e.g. '1:1' memory sizing with a huge entry count) or computing size programmatically from available memory and passing a long that exceeds the 32-bit limit.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- LogSettings.LogDevice needs to be specified (e.g., use…
- Segment ( ) must be at least of page size ( )
- Memory size ( ) must be configured to be either 1 (i.e., 0…
- Page size must be at least of device sector size
- Local memory device must have a capacity!
AI-assisted analysis of microsoft/FASTER@321d872eab (2026-09-15).
Data as JSON: /api/errors/bcd698428d195635.
Report an issue: GitHub.
Appendix: source
Thrown at cs/src/core/Index/FASTER/FASTERBase.cs:404
if (state[version].tableHandle.IsAllocated)
state[version].tableHandle.Free();
#endif
}
/// <summary>
/// Initialize
/// </summary>
/// <param name="size"></param>
/// <param name="sector_size"></param>
public void Initialize(long size, int sector_size)
{
if (!Utility.IsPowerOfTwo(size))
{
throw new ArgumentException("Size {0} is not a power of 2");
}
if (!Utility.Is32Bit(size))
{
throw new ArgumentException("Size {0} is not 32-bit");
}
minTableSize = size;
resizeInfo = default;
resizeInfo.status = ResizeOperationStatus.DONE;
resizeInfo.version = 0;
Initialize(resizeInfo.version, size, sector_size);
}
/// <summary>
/// Initialize
/// </summary>
/// <param name="version"></param>
/// <param name="size"></param>
/// <param name="sector_size"></param>
internal void Initialize(int version, long size, int sector_size)
{
long size_bytes = size * sizeof(HashBucket);View on GitHub (pinned to 321d872eab)