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

Prevents Table Cache to open same files more times #6707

Closed
wants to merge 1 commit into from

Conversation

koldat
Copy link
Contributor

@koldat koldat commented Apr 15, 2020

In highly concurrent requests table cache opens same file more times which lowers purpose of max_open_files. Fixes (#6699)

@koldat
Copy link
Contributor Author

koldat commented Apr 15, 2020

@pdillinger @siying please take a look and comment

util/mutexlock.h Outdated
}

private:
std::vector<T> locks_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put those locks in different cache lines to prevent false sharing? We do something like this in other places:

struct ALIGN_AS(CACHE_LINE_SIZE) StatisticsData {

Copy link
Contributor Author

@koldat koldat Apr 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review if I got that correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I forgot destructor. Sorry...

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@siying has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@siying siying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to test this in unit test?

@@ -62,14 +62,17 @@ void AppendVarint64(IterKey* key, uint64_t v) {

} // namespace

#define LOAD_CONCURENCY 128
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be a const instead of a macro? The memory is dynamically allocated anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can. I was waiting for feedback if you want it in options (I would not put it there). And I saw other macros as well. But yes can change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@koldat
Copy link
Contributor Author

koldat commented Apr 15, 2020

I have unit test in Java. Unfortunately I did not get check points framework. But if you require I will try to learn it.

@siying
Copy link
Contributor

siying commented Apr 15, 2020

Test might be a little bit hard to write though. If you run Linux, can you try to run "make crash_test" and see whether it can pass"? (it takes several hours).

@koldat
Copy link
Contributor Author

koldat commented Apr 15, 2020

I was testing in debugger to stop threads at correct place and it works as expected. Java multithread test I attached to issue also works as expected after fix. I have deployed build on our stress test and will start test you have mentioned. I will keep you posted.

@koldat
Copy link
Contributor Author

koldat commented Apr 16, 2020

I have run the make crash_test. It was running many hours as you have said. Basically it looks to me it was running in some cycle some tool. So it was repeating some command. All of them looks like this (hopefully it is ok):

Running db_stress with pid=4710: ./db_stress --acquire_snapshot_one_in=10000 --avoid_unnecessary_blocking_io=1 --block_size=16384 --bloom_bits=6.08920299324703 --bottommost_compression_type=disable --cache_index_and_filter_blocks=0 --cache_size=1048576 --checkpoint_one_in=1000000 --checksum_type=kxxHash --clear_column_family_one_in=0 --compact_files_one_in=1000000 --compact_range_one_in=1000000 --compaction_ttl=0 --compression_max_dict_bytes=16384 --compression_type=bzip2 --compression_zstd_max_train_bytes=0 --continuous_verification_interval=0 --db=/tmp/rocksdb_crashtest_blackbox9sb1kq8p --db_write_buffer_size=134217728 --delpercent=5 --delrangepercent=0 --destroy_db_initially=0 --enable_pipelined_write=1 --expected_values_path=/tmp/tmpimwgqhkc --flush_one_in=1000000 --format_version=5 --get_current_wal_file_one_in=0 --get_live_files_one_in=1000000 --get_sorted_wal_files_one_in=0 --index_block_restart_interval=11 --index_type=0 --key_len_percent_dist=1,30,69 --level_compaction_dynamic_level_bytes=True --long_running_snapshots=0 --max_background_compactions=20 --max_bytes_for_level_base=10485760 --max_key=100000000 --max_key_len=3 --max_manifest_file_size=1073741824 --max_write_batch_group_size_bytes=1048576 --max_write_buffer_number=3 --memtablerep=skip_list --mmap_read=1 --nooverwritepercent=1 --open_files=500000 --ops_per_thread=100000000 --partition_filters=0 --pause_background_one_in=1000000 --periodic_compaction_seconds=0 --prefixpercent=5 --progress_reports=0 --read_fault_one_in=0 --readpercent=45 --recycle_log_file_num=1 --reopen=20 --set_options_one_in=10000 --snapshot_hold_ops=100000 --subcompactions=3 --sync=0 --target_file_size_base=2097152 --target_file_size_multiplier=2 --test_batches_snapshots=1 --use_direct_io_for_flush_and_compaction=0 --use_direct_reads=0 --use_full_merge_v1=1 --use_merge=0 --use_multiget=0 --verify_checksum=1 --verify_checksum_one_in=1000000 --verify_db_one_in=100000 --write_buffer_size=4194304 --write_dbid_to_manifest=1 --writepercent=35


2020/04/16-06:24:02  Initializing db_stress
RocksDB version           : 6.9
Format version            : 5
TransactionDB             : false
BlobDB                    : false
Read only mode            : false
Atomic flush              : false
Column families           : 10
Number of threads         : 32
Ops per thread            : 100000000
Time to live(sec)         : unused
Read percentage           : 45%
Prefix percentage         : 5%
Write percentage          : 35%
Delete percentage         : 5%
Delete range percentage   : 0%
No overwrite percentage   : 1%
Iterate percentage        : 10%
DB-write-buffer-size      : 134217728
Write-buffer-size         : 4194304
Iterations                : 10
Max key                   : 100000000
Ratio #ops/#keys          : 32.000000
Num times DB reopens      : 20
Batches/snapshots         : 1
Do update in place        : 0
Num keys per lock         : 4
Compression               : BZip2
Bottommost Compression    : DisableOption
Checksum type             : kxxHash
Bloom bits / key          : 6.089203
Max subcompactions        : 3
Use MultiGet              : false
Memtablerep               : skip_list
Test kill odd             : 0
Periodic Compaction Secs  : 0
Compaction TTL            : 0
Background Purge          : 1
Write DB ID to manifest   : 1
Max Write Batch Group Size: 1048576
Use dynamic level         : 1
Read fault one in         : 0
------------------------------------------------
DB path: [/tmp/rocksdb_crashtest_blackbox9sb1kq8p]
Choosing random keys with no overwrite
No lock creation because test_batches_snapshots set
2020/04/16-06:24:06  Initializing worker threads
Crash-recovery verification passed :)
2020/04/16-06:24:06  Starting database operations
KILLED 4710

@koldat
Copy link
Contributor Author

koldat commented Apr 16, 2020

Our stress test does not show any deviation in response times and NO_FILES_OPENS looks beautiful.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@siying has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@koldat has updated the pull request. Re-import the pull request

@koldat
Copy link
Contributor Author

koldat commented Apr 18, 2020

Fixed reviews and squashed / rebased. Please let me know if you want to do further modifications.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@siying has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 6ee66cf.

@koldat
Copy link
Contributor Author

koldat commented Apr 22, 2020

If anyone interested, I have posted LRU concurrent performance analysis here: https://groups.google.com/forum/#!topic/rocksdb/1_uo3Pr6DiE

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

Successfully merging this pull request may close these issues.

3 participants