Function fromLimits [src]

Create parameters from ops and mem limits, where mem_limit given in bytes

Prototype

pub fn fromLimits(ops_limit: u64, mem_limit: usize) Self

Parameters

ops_limit: u64mem_limit: usize

Source

pub fn fromLimits(ops_limit: u64, mem_limit: usize) Self { const ops = @max(32768, ops_limit); const r: u30 = 8; if (ops < mem_limit / 32) { const max_n = ops / (r * 4); return Self{ .r = r, .p = 1, .ln = @as(u6, @intCast(math.log2(max_n))) }; } else { const max_n = mem_limit / (@as(usize, @intCast(r)) * 128); const ln = @as(u6, @intCast(math.log2(max_n))); const max_rp = @min(0x3fffffff, (ops / 4) / (@as(u64, 1) << ln)); return Self{ .r = r, .p = @as(u30, @intCast(max_rp / @as(u64, r))), .ln = ln }; } }