# crypto \- threaded K12: separate context computation from thread spawning \(\#25793\) · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/ee4df4ad3edad160fb737a1935cd86bc2f9cfbbe)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: ee4df4ad3edad160fb737a1935cd86bc2f9cfbbe

Requested commit: ee4df4ad3edad160fb737a1935cd86bc2f9cfbbe

Commit: ee4df4ad3edad160fb737a1935cd86bc2f9cfbbe

Tree: 88a30b506f3d620a74adaf2b01dbb6f2c17d43c7

Author: Frank Denis

Committer: GitHub

## Message

```
crypto - threaded K12: separate context computation from thread spawning (#25793)

* threaded K12: separate context computation from thread spawning

Compute all contexts and store them in a pre-allocated array,
then spawn threads using the pre-computed contexts.

This ensures each context is fully materialized in memory with the
correct values before any thread tries to access it.

* kt128: unroll the permutation rounds only twice

This appears to deliver the best performance thanks to improved cache
utilization, and it’s consistent with what we already do for SHA3.
```

## Parents

- [afdd04356cbf7821e1f992d1f3aedf7226a7e564](https://git.cafe/gitcafe/zig/commit/afdd04356cbf7821e1f992d1f3aedf7226a7e564?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/ee4df4ad3edad160fb737a1935cd86bc2f9cfbbe?format=markdown)
