leveldb
leveldb copied to clipboard
Fix the issue that prevents compilation in C++11 environment
issue #1247 Commit 302786e introduced a definition std::is_standard_layout_v that is only supported starting from C++17, which now prevents the LevelDB project from compiling in a C++11 environment. This modification uses a C++11-compatible implementation, allowing compilation in a C++11 environment without changing the logic.
Replace std::is_standard_layout_v with std::is_standard_layout<T>::value to ensure compatibility with C++11 compilers. This change affects:
util/env_posix.cc
util/env_windows.cc
util/no_destructor.h
This fix is needed for projects that are still using C++11 and cannot upgrade to C++17. Although this change does not seem to have an impact on performance, some benchmark results are as follows: 1
./db_bench --benchmarks=fillseq,readrandom,readseq,readreverse,fillrandom,overwrite | cat
LevelDB: version 1.23
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
WARNING: Snappy compression is not enabled
------------------------------------------------
fillseq : 2.119 micros/op; 52.2 MB/s
readrandom : 1.189 micros/op; (1000000 of 1000000 found)
readseq : 0.049 micros/op; 2278.8 MB/s
readreverse : 0.121 micros/op; 914.2 MB/s
fillrandom : 3.665 micros/op; 30.2 MB/s
overwrite : 4.458 micros/op; 24.8 MB/s
2
./db_bench --benchmarks=fillsync,readwhilewriting --threads=4 | cat
LevelDB: version 1.23
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
RawSize: 110.6 MB (estimated)
FileSize: 62.9 MB (estimated)
WARNING: Snappy compression is not enabled
------------------------------------------------
fillsync : 6672.317 micros/op; 0.1 MB/s (1000 ops)
readwhilewriting : 2.982 micros/op; (217660 of 1000000 found)
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
Awesome, this is a common problem that a bunch of coders has encountered. This PR should be merged in master branch : )