Skip to content

Commit 23da6c1

Browse files
authored
ChaCha AVX512 fix hotpath in XOR (#11699)
1 parent 26ed08b commit 23da6c1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

ydb/core/blobstorage/crypto/crypto.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ static void Xor(void* destination, const void* a, const void* b, ui32 size) {
306306
++srcB;
307307
}
308308
#else
309-
if (NX86::HaveAVX512F()) {
309+
if (TStreamCypher::HasAVX512) {
310310
XorAVX512(destination, a, b, size);
311311
} else {
312312
ui8 *dst = (ui8*)destination;

ydb/core/blobstorage/crypto/crypto.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ using TT1ha0Avx2Hasher = TT1ha0HasherBase<ET1haFunc::T1HA0_AVX2>;
9898
////////////////////////////////////////////////////////////////////////////
9999

100100
class TStreamCypher {
101+
public:
102+
static const bool HasAVX512;
103+
private:
101104
alignas(16) ui8 Leftover[BLOCK_BYTES];
102105
alignas(16) ui64 Key[4];
103106
alignas(16) i64 Nonce;
104107
std::unique_ptr<std::variant<ChaChaVec, ChaCha512>> Cypher;
105108
ui32 UnusedBytes;
106-
static const bool HasAVX512;
107109
public:
108110
TStreamCypher();
109111
void SetKey(const ui64 &key);

0 commit comments

Comments
 (0)