Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sha3 Hash Functions #696

Merged
merged 3 commits into from Jan 17, 2018
Merged

Add Sha3 Hash Functions #696

merged 3 commits into from Jan 17, 2018

Conversation

@tiehuis
Copy link
Member

@tiehuis tiehuis commented Jan 17, 2018

These are on the slower side and could be improved. No performance optimizations
yet have been done.

Cpu: Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz

Sha3-256

Zig --release-fast
    93 Mb/s
Zig --release-safe
    99 Mb/s
Zig
    4 Mb/s

Sha3-512

Zig --release-fast
    49 Mb/s
Zig --release-safe
    54 Mb/s
Zig
    2 Mb/s

Interestingly, release-safe is producing slightly better code than
release-fast.

Also, the blake numbers which I hadn't measured on their commit:

Blake2s

Zig --release-fast
    485 Mb/s
Zig --release-safe
    377 Mb/s
Zig
    11 Mb/s

Blake2b

Zig --release-fast
    616 Mb/s
Zig --release-safe
    573 Mb/s
Zig
    18 Mb/s
tiehuis added 3 commits Jan 17, 2018
Blake performance numbers for reference:

```
Cpu: Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
```

-- Blake2s

```
Zig --release-fast
    485 Mb/s
Zig --release-safe
    377 Mb/s
Zig
    11 Mb/s
```

-- Blake2b
```
Zig --release-fast
    616 Mb/s
Zig --release-safe
    573 Mb/s
Zig
    18 Mb/s
```
These are on the slower side and could be improved. No performance optimizations
yet have been done.

```
Cpu: Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
```

-- Sha3-256

```
Zig --release-fast
    93 Mb/s
Zig --release-safe
    99 Mb/s
Zig
    4 Mb/s
```

-- Sha3-512

```
Zig --release-fast
    49 Mb/s
Zig --release-safe
    54 Mb/s
Zig
    2 Mb/s
```

Interestingly, release-safe is producing slightly better code than
release-fast.
@andrewrk
Copy link
Member

@andrewrk andrewrk commented Jan 17, 2018

That's really strange. I can't think of any reason why release-safe could be faster than release-fast. I'll have to dig into the assembly.

// TODO: Cannot unroll all loops here due to comptime differences.
inline for (RC[0..no_rounds]) |round| {
// theta
x = 0; while (x < 5) : (x += 1) {
Copy link
Member Author

@tiehuis tiehuis Jan 17, 2018

I haven't been able to inline statements like these without getting wrong results in the tests. Is there any open issues relating to this or am I missing something? Or just a bug?

For example, making making y comptime and inline all the whiles results in bad results.

Copy link
Member

@andrewrk andrewrk Jan 17, 2018

It's probably a bug. I'm going to bed now but I'll have a look tomorrow. I'll prioritize this bug since it's a silently invalid code bug.

@andrewrk
Copy link
Member

@andrewrk andrewrk commented Jan 17, 2018

Code looks good. Feel free to merge when the tests pass (or if you already ran the tests before making the PR).

@tiehuis tiehuis merged commit 7a3fd89 into master Jan 17, 2018
2 of 4 checks passed
@tiehuis tiehuis deleted the sha3 branch Mar 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants