zig icon indicating copy to clipboard operation
zig copied to clipboard

crypto/benchmark - replace testing allocator

Open kassane opened this issue 3 years ago • 7 comments

Recently in my latest tests there has been an error with "testing.allocator".

error: Cannot use testing allocator outside of test block
        @compileError("Cannot use testing allocator outside of test block");

cc: @jedisct1

kassane avatar Aug 06 '22 15:08 kassane

Why not use the GPA?

jedisct1 avatar Aug 06 '22 15:08 jedisct1

Why not use the GPA?

GPA does not affect performance?


Edit

I tried it with arena alloc but not comited.

kassane avatar Aug 06 '22 20:08 kassane

The function benchmarks scrypt and argon2. Both intentionally require a lot of memory. With a fixed buffer, they are likely to immediately return with an error, and I doubt the benchmark result is relevant.

jedisct1 avatar Aug 07 '22 18:08 jedisct1

The function benchmarks scrypt and argon2. Both intentionally require a lot of memory. With a fixed buffer, they are likely to immediately return with an error, and I doubt the benchmark result is relevant.

changed to arena.

kassane avatar Aug 07 '22 19:08 kassane

Found another error when trying to use stage2 during the build.

Returning this error:

benchmark.zig:186:39: error: cannot load runtime value in comptime block
            try Signature.verifyBatch(batch.len, batch);

I tried to make comptime var batch, however a runtime problem occurs with error: weakPublicKey on stage1.

And returning this error on stage2:

~/.local/lib/zig/std/crypto/scrypt.zig:465:47: error: cannot load runtime value in comptime block
        const salt = crypt_format.saltFromBin(salt_bin.len, salt_bin);

kassane avatar Aug 27 '22 13:08 kassane

Looks like a regression. batch.len should be (and used to be) known at comptime.

jedisct1 avatar Aug 27 '22 14:08 jedisct1

#12240

ominitay avatar Aug 27 '22 14:08 ominitay