Skip to content

Conversation

l0rinc
Copy link
Contributor

@l0rinc l0rinc commented Jan 12, 2025

To help with to debugging and traceability (in alignment with displaying other non-default args such as Command-line arg: dbcache="10000") we can extend the LevelDB opening log with the used settings.

To avoid showing booleans as e.g. create_if_missing=1, I've added a local ToString lambda for bool.
I wanted to use util::Join at the end, but couldn't find any way that I liked.

Example output after the change:

025-01-16T10:47:35Z Opening LevelDB in /Users/lorinc/Library/Application Support/Bitcoin/blocks/index
2025-01-16T10:47:35Z Opened LevelDB successfully with options: options.compression=NoCompression, options.create_if_missing=true, options.max_file_size=33554432, options.paranoid_checks=true, options.write_buffer_size=524288, readoptions.fill_cache=false, readoptions.verify_checksums=true, writeoptions.sync=true
...
2025-01-16T10:47:51Z Opening LevelDB in /Users/lorinc/Library/Application Support/Bitcoin/chainstate
2025-01-16T10:47:51Z Opened LevelDB successfully with options: options.compression=NoCompression, options.create_if_missing=true, options.max_file_size=33554432, options.paranoid_checks=true, options.write_buffer_size=2097152, readoptions.fill_cache=false, readoptions.verify_checksums=true, writeoptions.sync=true

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 12, 2025

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31644.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

No conflicts as of last run.

@l0rinc l0rinc force-pushed the l0rinc/leveldb-options-logging branch from 64b1bf4 to 8af25b0 Compare January 12, 2025 17:45
@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed.
Debug: https://github.com/bitcoin/bitcoin/runs/35494695770

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

@luke-jr
Copy link
Member

luke-jr commented Jan 14, 2025

How is this useful?

@l0rinc
Copy link
Contributor Author

l0rinc commented Jan 16, 2025

How is this useful?

I've extended the description with more details.

Details
2025-01-16T10:47:35Z Opening LevelDB in /Users/lorinc/Library/Application Support/Bitcoin/blocks/index
2025-01-16T10:47:35Z Opened LevelDB successfully with options: options.compression=NoCompression, options.create_if_missing=true, options.max_file_size=33554432, options.paranoid_checks=true, options.write_buffer_size=524288, readoptions.fill_cache=false, readoptions.verify_checksums=true, writeoptions.sync=true
...
2025-01-16T10:47:51Z Opening LevelDB in /Users/lorinc/Library/Application Support/Bitcoin/chainstate
2025-01-16T10:47:51Z Opened LevelDB successfully with options: options.compression=NoCompression, options.create_if_missing=true, options.max_file_size=33554432, options.paranoid_checks=true, options.write_buffer_size=2097152, readoptions.fill_cache=false, readoptions.verify_checksums=true, writeoptions.sync=true

E.g. dbwrapper_tests/dbwrapper shows

options.compression=NoCompression, options.create_if_missing=true, options.max_file_size=33554432, options.paranoid_checks=true, options.write_buffer_size=262144, readoptions.fill_cache=false, readoptions.verify_checksums=true, writeoptions.sync=true

Logging the non-default LevelDB options during initialization makes it easier to understand and debug database behavior. For example, the blocks/index and chainstate databases already use different write_buffer_size values (512KiB vs. 2MiB) - optimized for their specific workloads (which are expected to diverge further the more we fine-tune them).

Logging these differences helps trace configuration changes, especially when command-line arguments (such as -dbcache or -dbbatchsize) can influence the settings.

Example output:
> Opened LevelDB successfully with options: options.compression=NoCompression, options.create_if_missing=true, options.max_file_size=33554432, options.paranoid_checks=true, options.write_buffer_size=524288, readoptions.fill_cache=false, readoptions.verify_checksums=true, writeoptions.sync=true
@l0rinc l0rinc force-pushed the l0rinc/leveldb-options-logging branch from 8af25b0 to aac1585 Compare July 28, 2025 21:04
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.

3 participants