Skip to content

Bcrypt large speed regression #13510

@Daimanta

Description

@Daimanta

Zig Version

0.10.0

Steps to Reproduce and Observed Behavior

The speed of Bcrypt with equal/similar parameters as Zig 0.9.x has regressed by about a factor 10 in 0.10.0. This severely reduces the usability of the implementation as we have this now.

Code as tested:

const std2 = @import("std");
const bcrypt = std2.crypto.pwhash.bcrypt;
const time = std2.time;
const begin = time.milliTimestamp();
var params: bcrypt.Params = .{ .rounds_log = 10 };
var hash_options: bcrypt.HashOptions = .{ .allocator = std2.heap.page_allocator, .params = params, .encoding = std2.crypto.pwhash.Encoding.crypt };
var buffer: [bcrypt.hash_length]u8 = undefined;
_ = try bcrypt.strHash("password", hash_options, buffer[0..]);
const end = time.milliTimestamp();
const diff = end - begin;
std2.debug.print("{d}\n", .{diff});

This code on my machine has around the following results:
Zig 0.9: 392ms
Zig 0.10: 5128ms

Expected Behavior

The speed of the algorithm should be similar the speed in Zig 0.9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.optimizationregressionIt worked in a previous version of Zig, but stopped working.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions