Merge pull request #2538 from alexmiller-apple/hashlittle2-to-crc32c

Convert more hashlittle{,2} uses to crc32c_append
This commit is contained in:
Evan Tschannen 2020-01-23 17:54:38 -08:00 committed by GitHub
commit 76e192d490
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 23 additions and 22 deletions

View File

@ -37,7 +37,7 @@
#include "flow/Knobs.h"
#include "flow/UnitTest.h"
#include <stdio.h>
#include "flow/Hash3.h"
#include "flow/crc32c.h"
#include "flow/genericactors.actor.h"
#include "flow/actorcompiler.h" // This must be the last #include.
@ -733,7 +733,7 @@ void AsyncFileKAIO::KAIOLogBlockEvent(FILE *logFile, IOBlock *ioblock, OpLogEntr
// Log a checksum for Writes up to the Complete stage or Reads starting from the Complete stage
if( (op == OpLogEntry::WRITE && stage <= OpLogEntry::COMPLETE) || (op == OpLogEntry::READ && stage >= OpLogEntry::COMPLETE) )
e.checksum = hashlittle(ioblock->buf, ioblock->nbytes, 0xab12fd93);
e.checksum = crc32c_append(0xab12fd93, ioblock->buf, ioblock->nbytes);
else
e.checksum = 0;

View File

@ -19,6 +19,7 @@
*/
#include "fdbrpc/IAsyncFile.h"
#include "flow/crc32c.h"
#if VALGRIND
#include <memcheck.h>
@ -116,7 +117,7 @@ private:
}
while(page < pageEnd) {
uint32_t checksum = hashlittle(start, checksumHistoryPageSize, 0xab12fd93);
uint32_t checksum = crc32c_append(0xab12fd93, start, checksumHistoryPageSize);
WriteInfo &history = checksumHistory[page];
//printf("%d %d %u %u\n", write, page, checksum, history.checksum);

View File

@ -9,7 +9,6 @@ set(FDBRPC_SRCS
AsyncFileNonDurable.actor.cpp
AsyncFileWriteChecker.cpp
batcher.actor.h
crc32c.cpp
FailureMonitor.actor.cpp
FlowTransport.actor.cpp
genericactors.actor.h

View File

@ -25,7 +25,7 @@
#include <memcheck.h>
#endif
#include "fdbrpc/crc32c.h"
#include "flow/crc32c.h"
#include "fdbrpc/fdbrpc.h"
#include "fdbrpc/FailureMonitor.h"
#include "fdbrpc/genericactors.actor.h"

View File

@ -20,8 +20,6 @@
<ActorCompiler Include="genericactors.actor.cpp" />
<ActorCompiler Include="FlowTransport.actor.cpp" />
<ActorCompiler Include="IAsyncFile.actor.cpp" />
<ClCompile Include="crc32c.cpp" />
<ClCompile Include="generated-constants.cpp" />
<ClCompile Include="Platform.cpp" />
<ClCompile Include="AsyncFileWriteChecker.cpp" />
<ClCompile Include="libcoroutine\Common.c" />
@ -73,7 +71,6 @@
</ActorCompiler>
<ClInclude Include="AsyncFileWriteChecker.h" />
<ClInclude Include="ContinuousSample.h" />
<ClInclude Include="crc32c.h" />
<ClInclude Include="FailureMonitor.h" />
<ActorCompiler Include="LoadBalance.actor.h">
<EnableCompile>false</EnableCompile>

View File

@ -78,7 +78,6 @@
<ClCompile Include="ReplicationTypes.cpp" />
<ClCompile Include="ReplicationPolicy.cpp" />
<ClCompile Include="crc32c.cpp" />
<ClCompile Include="generated-constants.cpp" />
<ClCompile Include="AsyncFileWriteChecker.cpp" />
<ClCompile Include="ReplicationUtils.cpp" />
</ItemGroup>

View File

@ -26,7 +26,7 @@
#include "fdbrpc/IAsyncFile.h"
#include "fdbrpc/AsyncFileCached.actor.h"
#include "fdbrpc/AsyncFileNonDurable.actor.h"
#include "flow/Hash3.h"
#include "flow/crc32c.h"
#include "fdbrpc/TraceFileIO.h"
#include "flow/FaultInjection.h"
#include "flow/network.h"
@ -90,7 +90,7 @@ class hash<Endpoint> {
public:
size_t operator()(const Endpoint &s) const
{
return hashlittle(&s, sizeof(s), 0);
return crc32c_append(0, (const uint8_t*)&s, sizeof(s));
}
};
}
@ -568,8 +568,7 @@ private:
}
if (randLog) {
uint32_t a=0, b=0;
hashlittle2( data, read_bytes, &a, &b );
uint32_t a = crc32c_append( 0, (const uint8_t*)data, read_bytes );
fprintf( randLog, "SFR2 %s %s %s %d %d\n", self->dbgId.shortString().c_str(), self->filename.c_str(), opId.shortString().c_str(), read_bytes, a );
}
@ -584,8 +583,7 @@ private:
ACTOR static Future<Void> write_impl( SimpleFile* self, StringRef data, int64_t offset ) {
state UID opId = deterministicRandom()->randomUniqueID();
if (randLog) {
uint32_t a=0, b=0;
hashlittle2( data.begin(), data.size(), &a, &b );
uint32_t a = crc32c_append( 0, data.begin(), data.size() );
fprintf( randLog, "SFW1 %s %s %s %d %d %" PRId64 "\n", self->dbgId.shortString().c_str(), self->filename.c_str(), opId.shortString().c_str(), a, data.size(), offset );
}

View File

@ -22,7 +22,7 @@
#include "fdbrpc/IAsyncFile.h"
#include "fdbserver/Knobs.h"
#include "fdbrpc/simulator.h"
#include "fdbrpc/crc32c.h"
#include "flow/crc32c.h"
#include "flow/genericactors.actor.h"
#include "flow/actorcompiler.h" // This must be the last #include.

View File

@ -20,7 +20,7 @@
#define SQLITE_THREADSAFE 0 // also in sqlite3.amalgamation.c!
#include "fdbrpc/crc32c.h"
#include "flow/crc32c.h"
#include "fdbserver/IKeyValueStore.h"
#include "fdbserver/CoroFlow.h"
#include "fdbserver/Knobs.h"

View File

@ -27,7 +27,7 @@
#include "flow/UnitTest.h"
#include "fdbserver/IPager.h"
#include "fdbrpc/IAsyncFile.h"
#include "fdbrpc/crc32c.h"
#include "flow/crc32c.h"
#include "flow/ActorCollection.h"
#include <map>
#include <vector>

View File

@ -63,6 +63,8 @@ set(FLOW_SRCS
XmlTraceLogFormatter.h
XmlTraceLogFormatter.cpp
actorcompiler.h
crc32c.h
crc32c.cpp
error_definitions.h
${CMAKE_CURRENT_BINARY_DIR}/SourceVersion.h
flat_buffers.h

View File

@ -24,6 +24,7 @@
#include "flow/Trace.h"
#include "flow/Error.h"
#include "flow/Knobs.h"
#include "flow/crc32c.h"
#include "flow/flow.h"
#include <cstdint>
@ -143,9 +144,9 @@ void recordAllocation( void *ptr, size_t size ) {
#error Instrumentation not supported on this platform
#endif
uint32_t a = 0, b = 0;
uint32_t a = 0;
if( nptrs > 0 ) {
hashlittle2( buffer, nptrs * sizeof(void *), &a, &b );
a = crc32c_append( 0xfdbeefdb, buffer, nptrs * sizeof(void *));
}
double countDelta = std::max(1.0, ((double)SAMPLE_BYTES) / size);

View File

@ -25,7 +25,7 @@
#define _CRT_SECURE_NO_WARNINGS
#endif
#include "fdbrpc/crc32c.h"
#include "flow/crc32c.h"
#define NOMINMAX
@ -35,7 +35,7 @@
#include <random>
#include <algorithm>
#include "fdbrpc/Platform.h"
#include "generated-constants.cpp"
#include "crc32c-generated-constants.cpp"
static uint32_t append_trivial(uint32_t crc, const uint8_t * input, size_t length)
{

View File

@ -13,6 +13,8 @@
<ItemGroup>
<ActorCompiler Include="ActorCollection.actor.cpp" />
<ActorCompiler Include="CompressedInt.actor.cpp" />
<ClCompile Include="crc32c.cpp" />
<ClCompile Include="crc32c-generated-constants.cpp" />
<ClCompile Include="DeterministicRandom.cpp" />
<ClCompile Include="Deque.cpp" />
<ClCompile Include="Error.cpp" />
@ -56,6 +58,7 @@
<ClInclude Include="actorcompiler.h" />
<ClInclude Include="Arena.h" />
<ClInclude Include="AsioReactor.h" />
<ClInclude Include="crc32c.h" />
<ClInclude Include="Deque.h" />
<ClInclude Include="DeterministicRandom.h" />
<ClInclude Include="Error.h" />

View File

@ -14,6 +14,7 @@
<ActorCompiler Include="TDMetric.actor.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="crc32c-generated-constants.cpp" />
<ClCompile Include="DeterministicRandom.cpp" />
<ClCompile Include="Error.cpp" />
<ClCompile Include="FastAlloc.cpp" />