Skip to content

Commit

Permalink
Merge branch 'main' into wip-ofriedma-snap-optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuval-Ariel authored Aug 2, 2023
2 parents 108c1f2 + 6e05428 commit 1c0bbb1
Show file tree
Hide file tree
Showing 70 changed files with 1,234 additions and 251 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/build_and_publish_jar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@ jobs:
patch=$(( $(grep '_PATCH\s\+[0-9]\+' "$VERSION_FILE" | sed 's/[^0-9]\+//') + 1 )) && echo $patch
echo "verSion=$major.$minor.$patch" >> $GITHUB_OUTPUT
Mac_i86_Bld:
Mac_i86:
needs: pre_build
uses: ./.github/workflows/ci_macos.yml
with:
verSion: ${{ needs.pre_build.outputs.out1 }}

Mac_ARM_Bld:
Mac_ARM:
needs: pre_build
uses: ./.github/workflows/ci_macos_ARM.yml
with:
verSion: ${{ needs.pre_build.outputs.out1 }}

Ubu_ARM_Bld:
Ubuntu_ARM:
needs: pre_build
uses: ./.github/workflows/bld_java_ubu_arm.yml
uses: ./.github/workflows/ci_ubuntu_arm.yml
with:
verSion: ${{ needs.pre_build.outputs.out1 }}

Windows_Bld:
Windows:
needs: pre_build
uses: ./.github/workflows/ci_windows.yml
with:
Expand All @@ -60,9 +60,9 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_BUCKET: ${{ secrets.AWS_BUCKET }}

Build_and_upload:
needs: [pre_build, Mac_i86_Bld, Windows_Bld, Ubu_ARM_Bld]
needs: [pre_build, Mac_i86, Windows, Ubuntu_ARM]
runs-on: ubu4mvn
env:
VERSION_FILE: speedb/version.h
Expand All @@ -86,10 +86,12 @@ jobs:
export JAVA_HOME="$(jrunscript -e 'java.lang.System.out.println(java.lang.System.getProperty("java.home"));')"
export LIB_JAVA_VERSION=11.0.17
export the_version=${{ steps.find_version.outputs.verSion }}
PORTABLE=1 DEBUG_LEVEL=0 make -j $(nproc) rocksdbjavastatic
export SPDB_LIB_DIR=~/spdb_lib && mkdir -p $SPDB_LIB_DIR
docker run --rm -v $(readlink -f ${SPDB_LIB_DIR}):/out -i speedb-centos-builder ${{ github.ref_name }}
cd java
mkdir src/main/resources
cp target/libspeedbjni-linux64.so src/main/resources
cp $SPDB_LIB_DIR/libspeedbjni-linux64.so src/main/resources
mv $SPDB_LIB_DIR/libspeedbjni-linux64.so{,_$(date '+%d_%m_%Y__%H_%M_%S')}
echo "aws s3 --profile nd7 cp --recursive s3://spdb-builder/jar_test/v$VERSION/ java/src/main/resources/"
sleep 180
aws s3 --profile nd7 cp --recursive s3://spdb-builder/jar_test/v$VERSION/ src/main/resources/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ jobs:

- name: 'build'
run: |
export JAVA_HOME=$(jrunscript -e 'java.lang.System.out.println(java.lang.System.getProperty("java.home"));')
PORTABLE=1 DEBUG_LEVEL=0 make -j $(nproc) rocksdbjavastatic
export SPDB_LIB_DIR=~/spdb_lib && mkdir -p $SPDB_LIB_DIR
docker run --rm -v $(readlink -f ${SPDB_LIB_DIR}):/out -i speedb-centos-builder ${{ github.ref_name }}
- name: 'upload artifacts' #This step executed only when this workflow is called by another and a version is provided
if: inputs.verSion != ' '
run: aws s3 cp java/target/libspeedbjni-linux-aarch64.so s3://spdb-builder/jar_test/v${{ inputs.verSion }}/libspeedbjni-linux-aarch64.so
run: |
aws s3 cp ~/spdb_lib/libspeedbjni-linux-aarch64.so s3://spdb-builder/jar_test/v${{ inputs.verSion }}/libspeedbjni-linux-aarch64.so
mv ~/spdb_lib/libspeedbjni-linux-aarch64.so{,_$(date '+%d_%m_%Y__%H_%M_%S')}
2 changes: 1 addition & 1 deletion .github/workflows/ci_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
AWS_REGION: us-east-1
SOURCE_MODE: FILE
SOURCE_PATH: runner_bld\java\Release\speedbjni-shared.dll
DEST_FILE: jar_test/v${{ inputs.verSion }}/speedbjni-shared.dll
DEST_FILE: jar_test/v${{ inputs.verSion }}/libspeedbjni-win64.dll
16 changes: 8 additions & 8 deletions .github/workflows/sanity_check.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: Check buck targets and code format
on: [push, workflow_call, workflow_dispatch]
on: [push, workflow_call, workflow_dispatch, pull_request_target]
permissions:
contents: read

jobs:
check:
name: Check TARGETS file and code format
#runs-on: ubuntu:20.04
runs-on: [self-hosted, ubuntu, asrunner]
container:
image: ubuntu:focal
runs-on: ubuntu-20.04
#runs-on: [self-hosted, ubuntu, asrunner]
#container:
# image: ubuntu:focal
steps:

- name: pre
run: apt update && apt install -y sudo git make clang build-essential clang-format wget
run: sudo apt update && sudo apt install -y git make clang build-essential clang-format wget

- name: Checkout feature branch
uses: actions/checkout@v2
Expand All @@ -36,10 +36,10 @@ jobs:
architecture: 'x64'

- name: Install Dependencies
run: python -m pip install --upgrade pip
run: sudo python -m pip install --upgrade pip

- name: Install argparse
run: pip install argparse
run: sudo pip install argparse

- name: Download clang-format-diff.py
run: |
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ set(SOURCES
table/block_based/partitioned_index_iterator.cc
table/block_based/partitioned_index_reader.cc
table/block_based/reader_common.cc
table/block_based/table_pinning_policy.cc
table/block_based/uncompression_dict_reader.cc
table/block_fetcher.cc
table/cuckoo/cuckoo_table_builder.cc
Expand Down
8 changes: 8 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@

### New Features
* Snapshot optimization - The most important information inside a snapshot is its Sequence number, which allows the compaction to know if the key-value should be deleted or not. The sequence number is being changed when modification happens in the db. This feature allows the db to take a snapshot without acquiring db mutex when the last snapshot has the same sequence number as a new one. In transactional db with mostly read operations, it should improve performance when used with multithreaded environment and as well other scenarios of taking large amount of snapshots with mostly read operations.
* Add a TablePinningPolicy to the BlockBasedTableOptions. This class controls when blocks should be pinned in memory for a block based table. The default behavior uses the MetadataCacheOptions to control pinning and behaves identical to the previous releases.

### Enhancements
* db_bench: add estimate-table-readers-mem benchmark which prints these stats.

### Bug Fixes
* unit tests: fix GlobalWriteControllerTest.GlobalAndWBMSetupDelay by waiting for the memtable memory release.
* spdb memtable: use_seek_parallel_threshold option parameter mishandled (#570)
* build: Plug memtable global switch memtable stuck fix. (#606)
* build: Windows compilation fix (#568).
* Logger: fix Block cache stats trace by spacing it from the last trace (#578).
* WriteController: move the class to public interface which should have been done under #346.
* unit tests: fix DBCompactionTest.DisableMultiManualCompaction by blocking all bg compaction threads which increased by default to 8 in #194.

## Fig v2.5.0 (06/14/2023)
Based on RocksDB 8.1.1
Expand Down Expand Up @@ -51,6 +58,7 @@ Also switch to waiting a sec on the CV each time. This is required since a bg er
* spdb memtable use after free bug (#501)
* db_bench: Create a WBM once for all db-s regardless of their use in different groups (#550)
* Tompstone unit test faiure (#560)
* build: Remove unused variables in unit tests (#581)

### Miscellaneous
* disable failing unit tests and paired bloom filter stress testing
Expand Down
2 changes: 2 additions & 0 deletions TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ cpp_library_wrapper(name="rocksdb_lib", srcs=[
"table/block_based/partitioned_index_iterator.cc",
"table/block_based/partitioned_index_reader.cc",
"table/block_based/reader_common.cc",
"table/block_based/table_pinning_policy.cc",
"table/block_based/uncompression_dict_reader.cc",
"table/block_fetcher.cc",
"table/compaction_merging_iterator.cc",
Expand Down Expand Up @@ -550,6 +551,7 @@ cpp_library_wrapper(name="rocksdb_whole_archive_lib", srcs=[
"table/block_based/partitioned_index_iterator.cc",
"table/block_based/partitioned_index_reader.cc",
"table/block_based/reader_common.cc",
"table/block_based/table_pinning_policy.cc",
"table/block_based/uncompression_dict_reader.cc",
"table/block_fetcher.cc",
"table/compaction_merging_iterator.cc",
Expand Down
2 changes: 1 addition & 1 deletion db/column_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
#include "db/range_del_aggregator.h"
#include "db/table_properties_collector.h"
#include "db/version_set.h"
#include "db/write_controller.h"
#include "file/sst_file_manager_impl.h"
#include "logging/logging.h"
#include "monitoring/thread_status_util.h"
#include "options/options_helper.h"
#include "port/port.h"
#include "rocksdb/convenience.h"
#include "rocksdb/table.h"
#include "rocksdb/write_controller.h"
#include "table/merging_iterator.h"
#include "util/autovector.h"
#include "util/cast_util.h"
Expand Down
2 changes: 1 addition & 1 deletion db/column_family.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
#include "db/table_cache.h"
#include "db/table_properties_collector.h"
#include "db/write_batch_internal.h"
#include "db/write_controller.h"
#include "options/cf_options.h"
#include "rocksdb/compaction_job_stats.h"
#include "rocksdb/db.h"
#include "rocksdb/env.h"
#include "rocksdb/options.h"
#include "rocksdb/write_controller.h"
#include "trace_replay/block_cache_tracer.h"
#include "util/hash_containers.h"
#include "util/thread_local.h"
Expand Down
2 changes: 1 addition & 1 deletion db/compaction/compaction_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "db/range_del_aggregator.h"
#include "db/seqno_to_time_mapping.h"
#include "db/version_edit.h"
#include "db/write_controller.h"
#include "db/write_thread.h"
#include "logging/event_logger.h"
#include "options/cf_options.h"
Expand All @@ -41,6 +40,7 @@
#include "rocksdb/env.h"
#include "rocksdb/memtablerep.h"
#include "rocksdb/transaction_log.h"
#include "rocksdb/write_controller.h"
#include "table/scoped_arena_iterator.h"
#include "util/autovector.h"
#include "util/stop_watch.h"
Expand Down
17 changes: 12 additions & 5 deletions db/db_compaction_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8618,9 +8618,13 @@ TEST_F(DBCompactionTest, DisableMultiManualCompaction) {
MoveFilesToLevel(1);

// Block compaction queue
test::SleepingBackgroundTask sleeping_task_low;
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask, &sleeping_task_low,
Env::Priority::LOW);
std::vector<test::SleepingBackgroundTask> sleeping_task_low(
std::max(1, env_->GetBackgroundThreads(Env::Priority::LOW)));

for (auto& sleeping_task : sleeping_task_low) {
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask, &sleeping_task,
Env::Priority::LOW);
}

port::Thread compact_thread1([&]() {
CompactRangeOptions cro;
Expand Down Expand Up @@ -8651,8 +8655,11 @@ TEST_F(DBCompactionTest, DisableMultiManualCompaction) {
compact_thread1.join();
compact_thread2.join();

sleeping_task_low.WakeUp();
sleeping_task_low.WaitUntilDone();
for (auto& sleeping_task : sleeping_task_low) {
sleeping_task.WakeUp();
sleeping_task.WaitUntilDone();
}

ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
}

Expand Down
2 changes: 1 addition & 1 deletion db/db_impl/db_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include "db/trim_history_scheduler.h"
#include "db/version_edit.h"
#include "db/wal_manager.h"
#include "db/write_controller.h"
#include "db/write_thread.h"
#include "logging/event_logger.h"
#include "monitoring/instrumented_mutex.h"
Expand All @@ -59,6 +58,7 @@
#include "rocksdb/transaction_log.h"
#include "rocksdb/utilities/replayer.h"
#include "rocksdb/write_buffer_manager.h"
#include "rocksdb/write_controller.h"
#include "table/merging_iterator.h"
#include "table/scoped_arena_iterator.h"
#include "util/autovector.h"
Expand Down
2 changes: 0 additions & 2 deletions db/db_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3484,10 +3484,8 @@ static bool CompareIterators(int step, DB* model, DB* db,
options.snapshot = db_snap;
Iterator* dbiter = db->NewIterator(options);
bool ok = true;
int count = 0;
for (miter->SeekToFirst(), dbiter->SeekToFirst();
ok && miter->Valid() && dbiter->Valid(); miter->Next(), dbiter->Next()) {
count++;
if (miter->key().compare(dbiter->key()) != 0) {
fprintf(stderr, "step %d: Key mismatch: '%s' vs. '%s'\n", step,
EscapeString(miter->key()).c_str(),
Expand Down
2 changes: 1 addition & 1 deletion db/external_sst_file_ingestion_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ Status ExternalSstFileIngestionJob::GetIngestedFileInfo(
*cfd_->ioptions(), sv->mutable_cf_options.prefix_extractor,
env_options_, cfd_->internal_comparator(),
/*skip_filters*/ false, /*immortal*/ false,
/*force_direct_prefetch*/ false, /*level*/ -1,
/*force_direct_prefetch*/ false, /*level*/ -1, /*bottommost*/ false,
/*block_cache_tracer*/ nullptr,
/*max_file_size_for_l0_meta_pin*/ 0, versions_->DbSessionId(),
/*cur_file_num*/ new_file_number),
Expand Down
2 changes: 1 addition & 1 deletion db/flush_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "db/seqno_to_time_mapping.h"
#include "db/snapshot_impl.h"
#include "db/version_edit.h"
#include "db/write_controller.h"
#include "db/write_thread.h"
#include "logging/event_logger.h"
#include "monitoring/instrumented_mutex.h"
Expand All @@ -39,6 +38,7 @@
#include "rocksdb/listener.h"
#include "rocksdb/memtablerep.h"
#include "rocksdb/transaction_log.h"
#include "rocksdb/write_controller.h"
#include "table/scoped_arena_iterator.h"
#include "util/autovector.h"
#include "util/stop_watch.h"
Expand Down
2 changes: 1 addition & 1 deletion db/global_write_controller_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.

#include "db/db_test_util.h"
#include "db/write_controller.h"
#include "rocksdb/write_buffer_manager.h"
#include "rocksdb/write_controller.h"

namespace ROCKSDB_NAMESPACE {

Expand Down
2 changes: 1 addition & 1 deletion db/import_column_family_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ Status ImportColumnFamilyJob::GetIngestedFileInfo(
*cfd_->ioptions(), sv->mutable_cf_options.prefix_extractor,
env_options_, cfd_->internal_comparator(),
/*skip_filters*/ false, /*immortal*/ false,
/*force_direct_prefetch*/ false, /*level*/ -1,
/*force_direct_prefetch*/ false, /*level*/ -1, /*bottommost*/ false,
/*block_cache_tracer*/ nullptr,
/*max_file_size_for_l0_meta_pin*/ 0, versions_->DbSessionId(),
/*cur_file_num*/ new_file_number),
Expand Down
2 changes: 1 addition & 1 deletion db/memtable_list_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

#include "db/merge_context.h"
#include "db/version_set.h"
#include "db/write_controller.h"
#include "rocksdb/db.h"
#include "rocksdb/status.h"
#include "rocksdb/write_buffer_manager.h"
#include "rocksdb/write_controller.h"
#include "test_util/testharness.h"
#include "test_util/testutil.h"
#include "util/string_util.h"
Expand Down
5 changes: 3 additions & 2 deletions db/table_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,13 @@ Status TableCache::GetTableReader(
file->Hint(FSRandomAccessFile::kRandom);
}
StopWatch sw(ioptions_.clock, ioptions_.stats, TABLE_OPEN_IO_MICROS);
bool is_bottom = (level == ioptions_.num_levels - 1);
std::unique_ptr<RandomAccessFileReader> file_reader(
new RandomAccessFileReader(
std::move(file), fname, ioptions_.clock, io_tracer_,
record_read_stats ? ioptions_.stats : nullptr, SST_READ_MICROS,
file_read_hist, ioptions_.rate_limiter.get(), ioptions_.listeners,
file_temperature, level == ioptions_.num_levels - 1));
file_temperature, is_bottom));
UniqueId64x2 expected_unique_id;
if (ioptions_.verify_sst_unique_id_in_manifest) {
expected_unique_id = file_meta.unique_id;
Expand All @@ -140,7 +141,7 @@ Status TableCache::GetTableReader(
ro,
TableReaderOptions(ioptions_, prefix_extractor, file_options,
internal_comparator, skip_filters, immortal_tables_,
false /* force_direct_prefetch */, level,
false /* force_direct_prefetch */, level, is_bottom,
block_cache_tracer_, max_file_size_for_l0_meta_pin,
db_session_id_, file_meta.fd.GetNumber(),
expected_unique_id, file_meta.fd.largest_seqno),
Expand Down
2 changes: 1 addition & 1 deletion db/version_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
#include "db/table_cache.h"
#include "db/version_builder.h"
#include "db/version_edit.h"
#include "db/write_controller.h"
#include "env/file_system_tracer.h"
#include "rocksdb/write_controller.h"
#if USE_COROUTINES
#include "folly/experimental/coro/BlockingWait.h"
#include "folly/experimental/coro/Collect.h"
Expand Down
2 changes: 1 addition & 1 deletion db/write_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).

#include "db/write_controller.h"
#include "rocksdb/write_controller.h"

#include <algorithm>
#include <atomic>
Expand Down
2 changes: 1 addition & 1 deletion db/write_controller_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
//
#include "db/write_controller.h"
#include "rocksdb/write_controller.h"

#include <array>
#include <ratio>
Expand Down
1 change: 1 addition & 0 deletions db_stress_tool/db_stress_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ DECLARE_bool(compression_use_zstd_dict_trainer);
DECLARE_string(checksum_type);
DECLARE_string(env_uri);
DECLARE_string(fs_uri);
DECLARE_string(pinning_policy);
DECLARE_uint64(ops_per_thread);
DECLARE_uint64(log2_keys_per_lock);
DECLARE_uint64(max_manifest_file_size);
Expand Down
2 changes: 2 additions & 0 deletions db_stress_tool/db_stress_gflags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,8 @@ DEFINE_string(fs_uri, "",
" with --env_uri."
" Creates a default environment with the specified filesystem.");

DEFINE_string(pinning_policy, "", "URI for registry TablePinningPolicy");

DEFINE_uint64(ops_per_thread, 1200000, "Number of operations per thread.");
static const bool FLAGS_ops_per_thread_dummy __attribute__((__unused__)) =
RegisterFlagValidator(&FLAGS_ops_per_thread, &ValidateUint32Range);
Expand Down
Loading

0 comments on commit 1c0bbb1

Please sign in to comment.