]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
location hint wip-ifed-loc-hint
authorIgor Fedotov <ifedotov@suse.com>
Thu, 25 Jul 2019 10:06:50 +0000 (13:06 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Wed, 14 Aug 2019 13:12:18 +0000 (16:12 +0300)
db/builder.cc
db/compaction_job.cc
db/db_impl_open.cc
db/db_impl_write.cc
db/version_set.cc
include/rocksdb/env.h

index 8e944983d2a2945881dd835c826675867e6ecb14..561b1faab7c48f0b29bf2cb67180da4c9a60ded4 100644 (file)
@@ -118,6 +118,10 @@ Status BuildTable(
         return s;
       }
       file->SetIOPriority(io_priority);
+      file->SetWriteLocationHint(
+          level < 0 ?
+              Env::LOCATION_UNSORTED :
+              Env::WriteLocationHint(Env::LOCATION_L0 + level));
       file->SetWriteLifeTimeHint(write_hint);
 
       file_writer.reset(new WritableFileWriter(std::move(file), env_options,
index 8bafabd5d731e08cea541494413f44d05c5540a9..493a4f314be9103e4fdce4006f12b716f2ae7c75 100644 (file)
@@ -1359,6 +1359,10 @@ Status CompactionJob::OpenCompactionOutputFile(
 
   sub_compact->outputs.push_back(out);
   writable_file->SetIOPriority(Env::IO_LOW);
+  writable_file->SetWriteLocationHint(
+      Env::WriteLocationHint(
+        Env::LOCATION_L0 + sub_compact->compaction->output_level()));
+
   writable_file->SetWriteLifeTimeHint(write_hint_);
   writable_file->SetPreallocationBlockSize(static_cast<size_t>(
       sub_compact->compaction->OutputFilePreallocationSize()));
index 2ab3478938ce0e441aea90c9a693d8d3b001558c..dc0233406f020592bfb81d7aced0330fcdcdbf68 100644 (file)
@@ -230,6 +230,7 @@ Status DBImpl::NewDB() {
     }
     file->SetPreallocationBlockSize(
         immutable_db_options_.manifest_preallocation_size);
+    file->SetWriteLocationHint(Env::LOCATION_UNSORTED);
     unique_ptr<WritableFileWriter> file_writer(
         new WritableFileWriter(std::move(file), env_options));
     log::Writer log(std::move(file_writer), 0, false);
@@ -950,7 +951,7 @@ Status DBImpl::WriteLevel0TableForRecovery(int job_id, ColumnFamilyData* cfd,
           cfd->ioptions()->compression_opts, paranoid_file_checks,
           cfd->internal_stats(), TableFileCreationReason::kRecovery,
           &event_logger_, job_id, Env::IO_HIGH, nullptr /* table_properties */,
-          -1 /* level */, current_time, write_hint);
+          0 /* level */, current_time, write_hint);
       LogFlush(immutable_db_options_.info_log);
       ROCKS_LOG_DEBUG(immutable_db_options_.info_log,
                       "[%s] [WriteLevel0TableForRecovery]"
@@ -1079,6 +1080,7 @@ Status DBImpl::Open(const DBOptions& db_options, const std::string& dbname,
         &lfile, opt_env_options);
     if (s.ok()) {
       lfile->SetWriteLifeTimeHint(write_hint);
+      lfile->SetWriteLocationHint(Env::LOCATION_WAL);
       lfile->SetPreallocationBlockSize(
           impl->GetWalPreallocateBlockSize(max_write_buffer_size));
       {
index fce910c708cc85afb8633fcfcd7e0ed5beb34ac2..b5340b27b7d5bba8e402334815272a53bc99b3e3 100644 (file)
@@ -1346,6 +1346,7 @@ Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context,
         // use preallocate_block_size instead
         // of calling GetWalPreallocateBlockSize()
         lfile->SetPreallocationBlockSize(preallocate_block_size);
+        lfile->SetWriteLocationHint(Env::LOCATION_WAL);
         lfile->SetWriteLifeTimeHint(write_hint);
         unique_ptr<WritableFileWriter> file_writer(
             new WritableFileWriter(std::move(lfile), opt_env_opt));
index b14bea8972f4d2e3c0d77381564aafd1327a00a6..71f81215424bcd72a22c50d0062eaf04204f85b9 100644 (file)
@@ -2861,6 +2861,7 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
           env_, DescriptorFileName(dbname_, pending_manifest_file_number_),
           &descriptor_file, opt_env_opts);
       if (s.ok()) {
+        descriptor_file->SetWriteLocationHint(Env::LOCATION_UNSORTED);
         descriptor_file->SetPreallocationBlockSize(
             db_options_->manifest_preallocation_size);
 
index 79ff3f38b7b3be3798cd7d39a418f0f76f4ec1e6..a7da1577242da7e625a71ded2fd994db08005aec 100644 (file)
@@ -164,6 +164,12 @@ class Env {
     WLTH_EXTREME,     // Data written has an extremely long life time
   };
 
+  enum WriteLocationHint {
+    LOCATION_WAL = 1,
+    LOCATION_UNSORTED = 2,
+    LOCATION_L0 = 3,
+  };\r
+
   // Create an object that writes to a new file with the specified
   // name.  Deletes any existing file with the same name and creates a
   // new file.  On success, stores a pointer to the new file in
@@ -685,6 +691,10 @@ class WritableFile {
 
   virtual Env::IOPriority GetIOPriority() { return io_priority_; }
 
+  virtual void SetWriteLocationHint(Env::WriteLocationHint) {
+    // do nothing
+  }\r
+
   virtual void SetWriteLifeTimeHint(Env::WriteLifeTimeHint hint) {
     write_hint_ = hint;
   }