Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issue that prevents compilation in C++11 environment #1251

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JalanChao
Copy link

@JalanChao JalanChao commented Feb 13, 2025

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::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)

Copy link

google-cla bot commented Feb 13, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant