2011-03-19 06:37:00 +08:00
|
|
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
//
|
|
|
|
// See port_example.h for documentation for the following types/functions.
|
|
|
|
|
|
|
|
#ifndef STORAGE_LEVELDB_PORT_PORT_POSIX_H_
|
|
|
|
#define STORAGE_LEVELDB_PORT_PORT_POSIX_H_
|
|
|
|
|
2018-03-17 10:10:13 +08:00
|
|
|
// port/port_config.h availability is automatically detected via __has_include
|
|
|
|
// in newer compilers. If LEVELDB_HAS_PORT_CONFIG_H is defined, it overrides the
|
|
|
|
// configuration detection.
|
|
|
|
#if defined(LEVELDB_HAS_PORT_CONFIG_H)
|
|
|
|
|
|
|
|
#if LEVELDB_HAS_PORT_CONFIG_H
|
|
|
|
#include "port/port_config.h"
|
|
|
|
#endif // LEVELDB_HAS_PORT_CONFIG_H
|
|
|
|
|
|
|
|
#elif defined(__has_include)
|
|
|
|
|
|
|
|
#if __has_include("port/port_config.h")
|
|
|
|
#include "port/port_config.h"
|
|
|
|
#endif // __has_include("port/port_config.h")
|
|
|
|
|
|
|
|
#endif // defined(LEVELDB_HAS_PORT_CONFIG_H)
|
2012-10-13 02:53:12 +08:00
|
|
|
|
2011-03-19 06:37:00 +08:00
|
|
|
#include <pthread.h>
|
2018-03-10 00:36:08 +08:00
|
|
|
#if HAVE_CRC32C
|
Replace SSE-optimized CRC32C in POSIX port with external library.
Maintaining a hardware-accelerated CRC32C implementation tailored for
all modern platforms deserves a repository of its own. We extracted the
implementation here into https://github.com/google/crc32c and improved
it in that repository. This CL removes the SSE-optimized implementation
from this codebase, and adds the ability to use the google/crc32c
library, if it is present on the system.
The benchmarks below show the performance impact of the change. In
summary, open source builds that use the google/crc32c library can
expect a 3x improvement in CRC32C throughput, whereas builds that do not
use the library will see a 50% drop in CRC32C throughput. This
translates in much smaller changes in overall leveldb performance.
Baseline, MacBookPro13,3 with Core i7 6920HQ:
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 3.064 micros/op; 36.1 MB/s
fillsync : 57.861 micros/op; 1.9 MB/s (1000 ops)
fillrandom : 3.887 micros/op; 28.5 MB/s
overwrite : 4.140 micros/op; 26.7 MB/s
readrandom : 7.433 micros/op; (1000000 of 1000000 found)
readrandom : 6.825 micros/op; (1000000 of 1000000 found)
readseq : 0.244 micros/op; 453.4 MB/s
readreverse : 0.387 micros/op; 285.8 MB/s
compact : 449707.000 micros/op;
readrandom : 4.196 micros/op; (1000000 of 1000000 found)
readseq : 0.228 micros/op; 485.8 MB/s
readreverse : 0.320 micros/op; 345.2 MB/s
fill100K : 562.556 micros/op; 169.6 MB/s (1000 ops)
crc32c : 0.768 micros/op; 5085.0 MB/s (4K per op)
snappycomp : 4.220 micros/op; 925.7 MB/s (output: 55.1%)
snappyuncomp : 0.635 micros/op; 6155.7 MB/s
acquireload : 13.054 micros/op; (each op is 1000 loads)
New with crc32c, MacBookPro13,3 with Core i7 6920HQ:
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 2.820 micros/op; 39.2 MB/s
fillsync : 51.988 micros/op; 2.1 MB/s (1000 ops)
fillrandom : 3.747 micros/op; 29.5 MB/s
overwrite : 4.047 micros/op; 27.3 MB/s
readrandom : 7.287 micros/op; (1000000 of 1000000 found)
readrandom : 6.927 micros/op; (1000000 of 1000000 found)
readseq : 0.253 micros/op; 437.5 MB/s
readreverse : 0.411 micros/op; 269.2 MB/s
compact : 440405.000 micros/op;
readrandom : 4.159 micros/op; (1000000 of 1000000 found)
readseq : 0.230 micros/op; 481.1 MB/s
readreverse : 0.320 micros/op; 345.9 MB/s
fill100K : 558.222 micros/op; 170.9 MB/s (1000 ops)
crc32c : 0.214 micros/op; 18263.5 MB/s (4K per op)
snappycomp : 4.471 micros/op; 873.7 MB/s (output: 55.1%)
snappyuncomp : 0.833 micros/op; 4688.5 MB/s
acquireload : 13.289 micros/op; (each op is 1000 loads)
New without crc32c, MacBookPro13,3 with Core i7 6920HQ
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 3.094 micros/op; 35.8 MB/s
fillsync : 52.160 micros/op; 2.1 MB/s (1000 ops)
fillrandom : 4.090 micros/op; 27.0 MB/s
overwrite : 4.006 micros/op; 27.6 MB/s
readrandom : 6.584 micros/op; (1000000 of 1000000 found)
readrandom : 6.676 micros/op; (1000000 of 1000000 found)
readseq : 0.280 micros/op; 395.2 MB/s
readreverse : 0.391 micros/op; 283.2 MB/s
compact : 433911.000 micros/op;
readrandom : 4.261 micros/op; (1000000 of 1000000 found)
readseq : 0.251 micros/op; 440.5 MB/s
readreverse : 0.356 micros/op; 310.9 MB/s
fill100K : 584.023 micros/op; 163.3 MB/s (1000 ops)
crc32c : 1.384 micros/op; 2822.3 MB/s (4K per op)
snappycomp : 4.763 micros/op; 820.1 MB/s (output: 55.1%)
snappyuncomp : 0.766 micros/op; 5098.6 MB/s
acquireload : 12.931 micros/op; (each op is 1000 loads)
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171667771
2017-10-10 21:05:17 +08:00
|
|
|
#include <crc32c/crc32c.h>
|
2018-03-10 00:36:08 +08:00
|
|
|
#endif // HAVE_CRC32C
|
|
|
|
#if HAVE_SNAPPY
|
2011-06-22 10:36:45 +08:00
|
|
|
#include <snappy.h>
|
2018-03-10 00:36:08 +08:00
|
|
|
#endif // HAVE_SNAPPY
|
2011-03-19 06:37:00 +08:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
2011-06-29 08:30:50 +08:00
|
|
|
#include "port/atomic_pointer.h"
|
2018-02-14 14:31:50 +08:00
|
|
|
#include "port/thread_annotations.h"
|
2011-06-29 08:30:50 +08:00
|
|
|
|
2012-05-31 00:45:46 +08:00
|
|
|
#ifndef PLATFORM_IS_LITTLE_ENDIAN
|
|
|
|
#define PLATFORM_IS_LITTLE_ENDIAN (__BYTE_ORDER == __LITTLE_ENDIAN)
|
2011-06-29 08:30:50 +08:00
|
|
|
#endif
|
|
|
|
|
2018-03-17 10:10:13 +08:00
|
|
|
#if !HAVE_FDATASYNC
|
2011-06-29 08:30:50 +08:00
|
|
|
#define fdatasync fsync
|
2018-03-17 10:10:13 +08:00
|
|
|
#endif // !HAVE_FDATASYNC
|
2012-05-31 00:45:46 +08:00
|
|
|
|
2011-03-19 06:37:00 +08:00
|
|
|
namespace leveldb {
|
|
|
|
namespace port {
|
|
|
|
|
2018-03-17 10:10:13 +08:00
|
|
|
static const bool kLittleEndian = !LEVELDB_IS_BIG_ENDIAN;
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
class CondVar;
|
|
|
|
|
2018-02-14 14:31:50 +08:00
|
|
|
class LOCKABLE Mutex {
|
2011-03-19 06:37:00 +08:00
|
|
|
public:
|
|
|
|
Mutex();
|
|
|
|
~Mutex();
|
|
|
|
|
2018-02-14 14:31:50 +08:00
|
|
|
void Lock() EXCLUSIVE_LOCK_FUNCTION();
|
|
|
|
void Unlock() UNLOCK_FUNCTION();
|
|
|
|
void AssertHeld() ASSERT_EXCLUSIVE_LOCK() { }
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class CondVar;
|
|
|
|
pthread_mutex_t mu_;
|
|
|
|
|
|
|
|
// No copying
|
|
|
|
Mutex(const Mutex&);
|
|
|
|
void operator=(const Mutex&);
|
|
|
|
};
|
|
|
|
|
|
|
|
class CondVar {
|
|
|
|
public:
|
|
|
|
explicit CondVar(Mutex* mu);
|
|
|
|
~CondVar();
|
|
|
|
void Wait();
|
|
|
|
void Signal();
|
|
|
|
void SignalAll();
|
|
|
|
private:
|
|
|
|
pthread_cond_t cv_;
|
|
|
|
Mutex* mu_;
|
|
|
|
};
|
|
|
|
|
2012-05-31 00:45:46 +08:00
|
|
|
typedef pthread_once_t OnceType;
|
|
|
|
#define LEVELDB_ONCE_INIT PTHREAD_ONCE_INIT
|
2018-03-13 00:14:44 +08:00
|
|
|
void InitOnce(OnceType* once, void (*initializer)());
|
2012-05-31 00:45:46 +08:00
|
|
|
|
2011-07-21 10:40:18 +08:00
|
|
|
inline bool Snappy_Compress(const char* input, size_t length,
|
2011-06-29 08:30:50 +08:00
|
|
|
::std::string* output) {
|
2018-03-10 00:36:08 +08:00
|
|
|
#if HAVE_SNAPPY
|
2011-07-21 10:40:18 +08:00
|
|
|
output->resize(snappy::MaxCompressedLength(length));
|
2011-06-22 10:36:45 +08:00
|
|
|
size_t outlen;
|
2011-07-21 10:40:18 +08:00
|
|
|
snappy::RawCompress(input, length, &(*output)[0], &outlen);
|
2011-06-22 10:36:45 +08:00
|
|
|
output->resize(outlen);
|
|
|
|
return true;
|
2018-03-10 00:36:08 +08:00
|
|
|
#endif // HAVE_SNAPPY
|
2011-06-22 10:36:45 +08:00
|
|
|
|
2011-03-23 07:24:02 +08:00
|
|
|
return false;
|
2011-03-19 06:37:00 +08:00
|
|
|
}
|
|
|
|
|
2011-07-21 10:40:18 +08:00
|
|
|
inline bool Snappy_GetUncompressedLength(const char* input, size_t length,
|
|
|
|
size_t* result) {
|
2018-03-10 00:36:08 +08:00
|
|
|
#if HAVE_SNAPPY
|
2011-07-21 10:40:18 +08:00
|
|
|
return snappy::GetUncompressedLength(input, length, result);
|
|
|
|
#else
|
|
|
|
return false;
|
2018-03-10 00:36:08 +08:00
|
|
|
#endif // HAVE_SNAPPY
|
2011-07-21 10:40:18 +08:00
|
|
|
}
|
2011-06-22 10:36:45 +08:00
|
|
|
|
2011-07-21 10:40:18 +08:00
|
|
|
inline bool Snappy_Uncompress(const char* input, size_t length,
|
|
|
|
char* output) {
|
2018-03-10 00:36:08 +08:00
|
|
|
#if HAVE_SNAPPY
|
2011-07-21 10:40:18 +08:00
|
|
|
return snappy::RawUncompress(input, length, output);
|
|
|
|
#else
|
2011-03-23 07:24:02 +08:00
|
|
|
return false;
|
2018-03-10 00:36:08 +08:00
|
|
|
#endif // HAVE_SNAPPY
|
2011-03-19 06:37:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Replace SSE-optimized CRC32C in POSIX port with external library.
Maintaining a hardware-accelerated CRC32C implementation tailored for
all modern platforms deserves a repository of its own. We extracted the
implementation here into https://github.com/google/crc32c and improved
it in that repository. This CL removes the SSE-optimized implementation
from this codebase, and adds the ability to use the google/crc32c
library, if it is present on the system.
The benchmarks below show the performance impact of the change. In
summary, open source builds that use the google/crc32c library can
expect a 3x improvement in CRC32C throughput, whereas builds that do not
use the library will see a 50% drop in CRC32C throughput. This
translates in much smaller changes in overall leveldb performance.
Baseline, MacBookPro13,3 with Core i7 6920HQ:
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 3.064 micros/op; 36.1 MB/s
fillsync : 57.861 micros/op; 1.9 MB/s (1000 ops)
fillrandom : 3.887 micros/op; 28.5 MB/s
overwrite : 4.140 micros/op; 26.7 MB/s
readrandom : 7.433 micros/op; (1000000 of 1000000 found)
readrandom : 6.825 micros/op; (1000000 of 1000000 found)
readseq : 0.244 micros/op; 453.4 MB/s
readreverse : 0.387 micros/op; 285.8 MB/s
compact : 449707.000 micros/op;
readrandom : 4.196 micros/op; (1000000 of 1000000 found)
readseq : 0.228 micros/op; 485.8 MB/s
readreverse : 0.320 micros/op; 345.2 MB/s
fill100K : 562.556 micros/op; 169.6 MB/s (1000 ops)
crc32c : 0.768 micros/op; 5085.0 MB/s (4K per op)
snappycomp : 4.220 micros/op; 925.7 MB/s (output: 55.1%)
snappyuncomp : 0.635 micros/op; 6155.7 MB/s
acquireload : 13.054 micros/op; (each op is 1000 loads)
New with crc32c, MacBookPro13,3 with Core i7 6920HQ:
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 2.820 micros/op; 39.2 MB/s
fillsync : 51.988 micros/op; 2.1 MB/s (1000 ops)
fillrandom : 3.747 micros/op; 29.5 MB/s
overwrite : 4.047 micros/op; 27.3 MB/s
readrandom : 7.287 micros/op; (1000000 of 1000000 found)
readrandom : 6.927 micros/op; (1000000 of 1000000 found)
readseq : 0.253 micros/op; 437.5 MB/s
readreverse : 0.411 micros/op; 269.2 MB/s
compact : 440405.000 micros/op;
readrandom : 4.159 micros/op; (1000000 of 1000000 found)
readseq : 0.230 micros/op; 481.1 MB/s
readreverse : 0.320 micros/op; 345.9 MB/s
fill100K : 558.222 micros/op; 170.9 MB/s (1000 ops)
crc32c : 0.214 micros/op; 18263.5 MB/s (4K per op)
snappycomp : 4.471 micros/op; 873.7 MB/s (output: 55.1%)
snappyuncomp : 0.833 micros/op; 4688.5 MB/s
acquireload : 13.289 micros/op; (each op is 1000 loads)
New without crc32c, MacBookPro13,3 with Core i7 6920HQ
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 3.094 micros/op; 35.8 MB/s
fillsync : 52.160 micros/op; 2.1 MB/s (1000 ops)
fillrandom : 4.090 micros/op; 27.0 MB/s
overwrite : 4.006 micros/op; 27.6 MB/s
readrandom : 6.584 micros/op; (1000000 of 1000000 found)
readrandom : 6.676 micros/op; (1000000 of 1000000 found)
readseq : 0.280 micros/op; 395.2 MB/s
readreverse : 0.391 micros/op; 283.2 MB/s
compact : 433911.000 micros/op;
readrandom : 4.261 micros/op; (1000000 of 1000000 found)
readseq : 0.251 micros/op; 440.5 MB/s
readreverse : 0.356 micros/op; 310.9 MB/s
fill100K : 584.023 micros/op; 163.3 MB/s (1000 ops)
crc32c : 1.384 micros/op; 2822.3 MB/s (4K per op)
snappycomp : 4.763 micros/op; 820.1 MB/s (output: 55.1%)
snappyuncomp : 0.766 micros/op; 5098.6 MB/s
acquireload : 12.931 micros/op; (each op is 1000 loads)
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171667771
2017-10-10 21:05:17 +08:00
|
|
|
inline uint32_t AcceleratedCRC32C(uint32_t crc, const char* buf, size_t size) {
|
2018-03-10 00:36:08 +08:00
|
|
|
#if HAVE_CRC32C
|
Replace SSE-optimized CRC32C in POSIX port with external library.
Maintaining a hardware-accelerated CRC32C implementation tailored for
all modern platforms deserves a repository of its own. We extracted the
implementation here into https://github.com/google/crc32c and improved
it in that repository. This CL removes the SSE-optimized implementation
from this codebase, and adds the ability to use the google/crc32c
library, if it is present on the system.
The benchmarks below show the performance impact of the change. In
summary, open source builds that use the google/crc32c library can
expect a 3x improvement in CRC32C throughput, whereas builds that do not
use the library will see a 50% drop in CRC32C throughput. This
translates in much smaller changes in overall leveldb performance.
Baseline, MacBookPro13,3 with Core i7 6920HQ:
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 3.064 micros/op; 36.1 MB/s
fillsync : 57.861 micros/op; 1.9 MB/s (1000 ops)
fillrandom : 3.887 micros/op; 28.5 MB/s
overwrite : 4.140 micros/op; 26.7 MB/s
readrandom : 7.433 micros/op; (1000000 of 1000000 found)
readrandom : 6.825 micros/op; (1000000 of 1000000 found)
readseq : 0.244 micros/op; 453.4 MB/s
readreverse : 0.387 micros/op; 285.8 MB/s
compact : 449707.000 micros/op;
readrandom : 4.196 micros/op; (1000000 of 1000000 found)
readseq : 0.228 micros/op; 485.8 MB/s
readreverse : 0.320 micros/op; 345.2 MB/s
fill100K : 562.556 micros/op; 169.6 MB/s (1000 ops)
crc32c : 0.768 micros/op; 5085.0 MB/s (4K per op)
snappycomp : 4.220 micros/op; 925.7 MB/s (output: 55.1%)
snappyuncomp : 0.635 micros/op; 6155.7 MB/s
acquireload : 13.054 micros/op; (each op is 1000 loads)
New with crc32c, MacBookPro13,3 with Core i7 6920HQ:
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 2.820 micros/op; 39.2 MB/s
fillsync : 51.988 micros/op; 2.1 MB/s (1000 ops)
fillrandom : 3.747 micros/op; 29.5 MB/s
overwrite : 4.047 micros/op; 27.3 MB/s
readrandom : 7.287 micros/op; (1000000 of 1000000 found)
readrandom : 6.927 micros/op; (1000000 of 1000000 found)
readseq : 0.253 micros/op; 437.5 MB/s
readreverse : 0.411 micros/op; 269.2 MB/s
compact : 440405.000 micros/op;
readrandom : 4.159 micros/op; (1000000 of 1000000 found)
readseq : 0.230 micros/op; 481.1 MB/s
readreverse : 0.320 micros/op; 345.9 MB/s
fill100K : 558.222 micros/op; 170.9 MB/s (1000 ops)
crc32c : 0.214 micros/op; 18263.5 MB/s (4K per op)
snappycomp : 4.471 micros/op; 873.7 MB/s (output: 55.1%)
snappyuncomp : 0.833 micros/op; 4688.5 MB/s
acquireload : 13.289 micros/op; (each op is 1000 loads)
New without crc32c, MacBookPro13,3 with Core i7 6920HQ
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 3.094 micros/op; 35.8 MB/s
fillsync : 52.160 micros/op; 2.1 MB/s (1000 ops)
fillrandom : 4.090 micros/op; 27.0 MB/s
overwrite : 4.006 micros/op; 27.6 MB/s
readrandom : 6.584 micros/op; (1000000 of 1000000 found)
readrandom : 6.676 micros/op; (1000000 of 1000000 found)
readseq : 0.280 micros/op; 395.2 MB/s
readreverse : 0.391 micros/op; 283.2 MB/s
compact : 433911.000 micros/op;
readrandom : 4.261 micros/op; (1000000 of 1000000 found)
readseq : 0.251 micros/op; 440.5 MB/s
readreverse : 0.356 micros/op; 310.9 MB/s
fill100K : 584.023 micros/op; 163.3 MB/s (1000 ops)
crc32c : 1.384 micros/op; 2822.3 MB/s (4K per op)
snappycomp : 4.763 micros/op; 820.1 MB/s (output: 55.1%)
snappyuncomp : 0.766 micros/op; 5098.6 MB/s
acquireload : 12.931 micros/op; (each op is 1000 loads)
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171667771
2017-10-10 21:05:17 +08:00
|
|
|
return ::crc32c::Extend(crc, reinterpret_cast<const uint8_t*>(buf), size);
|
|
|
|
#else
|
|
|
|
return 0;
|
2018-03-10 00:36:08 +08:00
|
|
|
#endif // HAVE_CRC32C
|
Replace SSE-optimized CRC32C in POSIX port with external library.
Maintaining a hardware-accelerated CRC32C implementation tailored for
all modern platforms deserves a repository of its own. We extracted the
implementation here into https://github.com/google/crc32c and improved
it in that repository. This CL removes the SSE-optimized implementation
from this codebase, and adds the ability to use the google/crc32c
library, if it is present on the system.
The benchmarks below show the performance impact of the change. In
summary, open source builds that use the google/crc32c library can
expect a 3x improvement in CRC32C throughput, whereas builds that do not
use the library will see a 50% drop in CRC32C throughput. This
translates in much smaller changes in overall leveldb performance.
Baseline, MacBookPro13,3 with Core i7 6920HQ:
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 3.064 micros/op; 36.1 MB/s
fillsync : 57.861 micros/op; 1.9 MB/s (1000 ops)
fillrandom : 3.887 micros/op; 28.5 MB/s
overwrite : 4.140 micros/op; 26.7 MB/s
readrandom : 7.433 micros/op; (1000000 of 1000000 found)
readrandom : 6.825 micros/op; (1000000 of 1000000 found)
readseq : 0.244 micros/op; 453.4 MB/s
readreverse : 0.387 micros/op; 285.8 MB/s
compact : 449707.000 micros/op;
readrandom : 4.196 micros/op; (1000000 of 1000000 found)
readseq : 0.228 micros/op; 485.8 MB/s
readreverse : 0.320 micros/op; 345.2 MB/s
fill100K : 562.556 micros/op; 169.6 MB/s (1000 ops)
crc32c : 0.768 micros/op; 5085.0 MB/s (4K per op)
snappycomp : 4.220 micros/op; 925.7 MB/s (output: 55.1%)
snappyuncomp : 0.635 micros/op; 6155.7 MB/s
acquireload : 13.054 micros/op; (each op is 1000 loads)
New with crc32c, MacBookPro13,3 with Core i7 6920HQ:
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 2.820 micros/op; 39.2 MB/s
fillsync : 51.988 micros/op; 2.1 MB/s (1000 ops)
fillrandom : 3.747 micros/op; 29.5 MB/s
overwrite : 4.047 micros/op; 27.3 MB/s
readrandom : 7.287 micros/op; (1000000 of 1000000 found)
readrandom : 6.927 micros/op; (1000000 of 1000000 found)
readseq : 0.253 micros/op; 437.5 MB/s
readreverse : 0.411 micros/op; 269.2 MB/s
compact : 440405.000 micros/op;
readrandom : 4.159 micros/op; (1000000 of 1000000 found)
readseq : 0.230 micros/op; 481.1 MB/s
readreverse : 0.320 micros/op; 345.9 MB/s
fill100K : 558.222 micros/op; 170.9 MB/s (1000 ops)
crc32c : 0.214 micros/op; 18263.5 MB/s (4K per op)
snappycomp : 4.471 micros/op; 873.7 MB/s (output: 55.1%)
snappyuncomp : 0.833 micros/op; 4688.5 MB/s
acquireload : 13.289 micros/op; (each op is 1000 loads)
New without crc32c, MacBookPro13,3 with Core i7 6920HQ
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 3.094 micros/op; 35.8 MB/s
fillsync : 52.160 micros/op; 2.1 MB/s (1000 ops)
fillrandom : 4.090 micros/op; 27.0 MB/s
overwrite : 4.006 micros/op; 27.6 MB/s
readrandom : 6.584 micros/op; (1000000 of 1000000 found)
readrandom : 6.676 micros/op; (1000000 of 1000000 found)
readseq : 0.280 micros/op; 395.2 MB/s
readreverse : 0.391 micros/op; 283.2 MB/s
compact : 433911.000 micros/op;
readrandom : 4.261 micros/op; (1000000 of 1000000 found)
readseq : 0.251 micros/op; 440.5 MB/s
readreverse : 0.356 micros/op; 310.9 MB/s
fill100K : 584.023 micros/op; 163.3 MB/s (1000 ops)
crc32c : 1.384 micros/op; 2822.3 MB/s (4K per op)
snappycomp : 4.763 micros/op; 820.1 MB/s (output: 55.1%)
snappyuncomp : 0.766 micros/op; 5098.6 MB/s
acquireload : 12.931 micros/op; (each op is 1000 loads)
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171667771
2017-10-10 21:05:17 +08:00
|
|
|
}
|
2017-02-28 06:29:18 +08:00
|
|
|
|
Replace SSE-optimized CRC32C in POSIX port with external library.
Maintaining a hardware-accelerated CRC32C implementation tailored for
all modern platforms deserves a repository of its own. We extracted the
implementation here into https://github.com/google/crc32c and improved
it in that repository. This CL removes the SSE-optimized implementation
from this codebase, and adds the ability to use the google/crc32c
library, if it is present on the system.
The benchmarks below show the performance impact of the change. In
summary, open source builds that use the google/crc32c library can
expect a 3x improvement in CRC32C throughput, whereas builds that do not
use the library will see a 50% drop in CRC32C throughput. This
translates in much smaller changes in overall leveldb performance.
Baseline, MacBookPro13,3 with Core i7 6920HQ:
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 3.064 micros/op; 36.1 MB/s
fillsync : 57.861 micros/op; 1.9 MB/s (1000 ops)
fillrandom : 3.887 micros/op; 28.5 MB/s
overwrite : 4.140 micros/op; 26.7 MB/s
readrandom : 7.433 micros/op; (1000000 of 1000000 found)
readrandom : 6.825 micros/op; (1000000 of 1000000 found)
readseq : 0.244 micros/op; 453.4 MB/s
readreverse : 0.387 micros/op; 285.8 MB/s
compact : 449707.000 micros/op;
readrandom : 4.196 micros/op; (1000000 of 1000000 found)
readseq : 0.228 micros/op; 485.8 MB/s
readreverse : 0.320 micros/op; 345.2 MB/s
fill100K : 562.556 micros/op; 169.6 MB/s (1000 ops)
crc32c : 0.768 micros/op; 5085.0 MB/s (4K per op)
snappycomp : 4.220 micros/op; 925.7 MB/s (output: 55.1%)
snappyuncomp : 0.635 micros/op; 6155.7 MB/s
acquireload : 13.054 micros/op; (each op is 1000 loads)
New with crc32c, MacBookPro13,3 with Core i7 6920HQ:
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 2.820 micros/op; 39.2 MB/s
fillsync : 51.988 micros/op; 2.1 MB/s (1000 ops)
fillrandom : 3.747 micros/op; 29.5 MB/s
overwrite : 4.047 micros/op; 27.3 MB/s
readrandom : 7.287 micros/op; (1000000 of 1000000 found)
readrandom : 6.927 micros/op; (1000000 of 1000000 found)
readseq : 0.253 micros/op; 437.5 MB/s
readreverse : 0.411 micros/op; 269.2 MB/s
compact : 440405.000 micros/op;
readrandom : 4.159 micros/op; (1000000 of 1000000 found)
readseq : 0.230 micros/op; 481.1 MB/s
readreverse : 0.320 micros/op; 345.9 MB/s
fill100K : 558.222 micros/op; 170.9 MB/s (1000 ops)
crc32c : 0.214 micros/op; 18263.5 MB/s (4K per op)
snappycomp : 4.471 micros/op; 873.7 MB/s (output: 55.1%)
snappyuncomp : 0.833 micros/op; 4688.5 MB/s
acquireload : 13.289 micros/op; (each op is 1000 loads)
New without crc32c, MacBookPro13,3 with Core i7 6920HQ
LevelDB: version 1.20
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
------------------------------------------------
fillseq : 3.094 micros/op; 35.8 MB/s
fillsync : 52.160 micros/op; 2.1 MB/s (1000 ops)
fillrandom : 4.090 micros/op; 27.0 MB/s
overwrite : 4.006 micros/op; 27.6 MB/s
readrandom : 6.584 micros/op; (1000000 of 1000000 found)
readrandom : 6.676 micros/op; (1000000 of 1000000 found)
readseq : 0.280 micros/op; 395.2 MB/s
readreverse : 0.391 micros/op; 283.2 MB/s
compact : 433911.000 micros/op;
readrandom : 4.261 micros/op; (1000000 of 1000000 found)
readseq : 0.251 micros/op; 440.5 MB/s
readreverse : 0.356 micros/op; 310.9 MB/s
fill100K : 584.023 micros/op; 163.3 MB/s (1000 ops)
crc32c : 1.384 micros/op; 2822.3 MB/s (4K per op)
snappycomp : 4.763 micros/op; 820.1 MB/s (output: 55.1%)
snappyuncomp : 0.766 micros/op; 5098.6 MB/s
acquireload : 12.931 micros/op; (each op is 1000 loads)
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171667771
2017-10-10 21:05:17 +08:00
|
|
|
} // namespace port
|
|
|
|
} // namespace leveldb
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
#endif // STORAGE_LEVELDB_PORT_PORT_POSIX_H_
|