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

Conversation

Projects
None yet
2 participants
@tiehuis
Member

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 some commits Jan 17, 2018

Add throughput test program
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
```
Add Sha3 hashing functions
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

This comment has been minimized.

Member

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) {

This comment has been minimized.

@tiehuis

tiehuis Jan 17, 2018

Member

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.

This comment has been minimized.

@andrewrk

andrewrk Jan 17, 2018

Member

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

This comment has been minimized.

Member

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

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details

@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