mirror of
https://github.com/morluto/rea.git
synced 2026-10-27 01:45:32 +00:00
perf(entropy): separate physical reads from report resolution (#6950)
* perf(entropy): separate physical reads from report blocks * test(entropy): type the injected positional short-read boundary * test(entropy): retain full catalog transport capacity in task probe * docs(perf): record real entropy task costs and limits * docs(perf): record latest-main entropy qualification
This commit is contained in:
1 parent
b869fa762a
commit
b5c42dfc2a
7 files changed
+1973
-7
No files matched your search
@@ -241,7 +241,10 @@ export class ByteEntropyService {
|
||||
);
|
||||
const end = input.offset + length;
|
||||
const blocks: ByteEntropy["blocks"] = [];
|
||||
const buffer = Buffer.alloc(input.block_size);
|
||||
// Physical reads must not shrink with report resolution, including
|
||||
// outside the selected window. Every admitted power-of-two block
|
||||
// size divides this buffer, so only the window's final block is short.
|
||||
const buffer = Buffer.alloc(65_536);
|
||||
const counts = new Float64Array(256);
|
||||
const hash = createHash("sha256");
|
||||
let position = 0;
|
||||
@@ -250,7 +253,7 @@ export class ByteEntropyService {
|
||||
const selected = position >= input.offset && position < end;
|
||||
const boundary =
|
||||
position < input.offset ? input.offset : selected ? end : size;
|
||||
const wanted = Math.min(input.block_size, boundary - position);
|
||||
const wanted = Math.min(buffer.length, boundary - position);
|
||||
let filled = 0;
|
||||
while (filled < wanted) {
|
||||
assertArtifactReadActive(options?.signal);
|
||||
@@ -267,11 +270,18 @@ export class ByteEntropyService {
|
||||
hash.update(bytes);
|
||||
for (const byte of bytes) counts[byte] = (counts[byte] ?? 0) + 1;
|
||||
if (selected)
|
||||
blocks.push({
|
||||
offset: position,
|
||||
length: filled,
|
||||
entropy: computeBlockEntropy(bytes),
|
||||
});
|
||||
for (
|
||||
let offset = 0;
|
||||
offset < filled;
|
||||
offset += input.block_size
|
||||
) {
|
||||
const block = bytes.subarray(offset, offset + input.block_size);
|
||||
blocks.push({
|
||||
offset: position + offset,
|
||||
length: block.length,
|
||||
entropy: computeBlockEntropy(block),
|
||||
});
|
||||
}
|
||||
position += filled;
|
||||
}
|
||||
if (
|
||||
|
||||
Reference in new issue
Block a user