Skip to content

Commit

Permalink
Static Pinning: Report static pinning options to the log (#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
udi-speedb authored Oct 12, 2023
1 parent 5e4e147 commit 858bb1a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Fix RepeatableThread to work properly with on thread start callback feature (htt

### Enhancements
* Unit Testing: Expose the disallow_trivial_move flag in the MoveFilesToLevel testing utility (#677).
* Static Pinning: Report pinning policy name and parameters to the log (#691).
* LOG Reporting: add reporting capabilities to the WriteController and the WriteBufferManager by saving the Loggers of the dbs which are using them internally and issuing WARN msgs to these Loggers whenever the state of the WC and WBM changes in regards to delaying (#556).

### Bug Fixes
Expand Down
2 changes: 2 additions & 0 deletions include/rocksdb/table_pinning_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class TablePinningPolicy : public Customizable {
// Returns the amount of data currently pinned.
virtual size_t GetPinnedUsage() const = 0;

virtual std::string GetPrintableOptions() const { return ""; }

// Returns the info (e.g. statistics) associated with this policy.
virtual std::string ToString() const = 0;
};
Expand Down
26 changes: 26 additions & 0 deletions plugin/speedb/pinning_policy/scoped_pinning_policy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@

#include "plugin/speedb/pinning_policy/scoped_pinning_policy.h"

#include <inttypes.h>

#include <cstdio>
#include <unordered_map>

#include "port/port.h"
#include "rocksdb/utilities/options_type.h"

namespace ROCKSDB_NAMESPACE {
Expand Down Expand Up @@ -68,6 +72,28 @@ bool ScopedPinningPolicy::CheckPin(const TablePinningOptions& tpo,
return true;
}

std::string ScopedPinningPolicy::GetPrintableOptions() const {
std::string ret;
const int kBufferSize = 200;
char buffer[kBufferSize];

snprintf(buffer, kBufferSize,
" pinning_policy.capacity: %" ROCKSDB_PRIszt "\n",
options_.capacity);
ret.append(buffer);

snprintf(buffer, kBufferSize,
" pinning_policy.last_level_with_data_percent: %" PRIu32 "\n",
options_.bottom_percent);
ret.append(buffer);

snprintf(buffer, kBufferSize, " pinning_policy.mid_percent: %" PRIu32 "\n",
options_.mid_percent);
ret.append(buffer);

return ret;
}

} // namespace ROCKSDB_NAMESPACE

#endif // ROCKSDB_LITE
2 changes: 2 additions & 0 deletions plugin/speedb/pinning_policy/scoped_pinning_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class ScopedPinningPolicy : public RecordingPinningPolicy {
const char* NickName() const override { return kNickName(); }
std::string GetId() const override;

std::string GetPrintableOptions() const override;

protected:
bool CheckPin(const TablePinningOptions& tpo, uint8_t type, size_t size,
size_t limit) const override;
Expand Down
14 changes: 14 additions & 0 deletions table/block_based/block_based_table_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,20 @@ std::string BlockBasedTableFactory::GetPrintableOptions() const {
ret.append(buffer);
ret.append(table_options_.persistent_cache->GetPrintableOptions());
}
if (table_options_.pinning_policy) {
const char* pinning_policy_name = table_options_.pinning_policy->Name();
if (pinning_policy_name != nullptr) {
snprintf(buffer, kBufferSize, " pinning_policy_name: %s\n",
pinning_policy_name);
ret.append(buffer);
}
auto pinning_printable_options =
table_options_.pinning_policy->GetPrintableOptions();
if (pinning_printable_options.empty() == false) {
ret.append(" pinning_policy_options:\n");
ret.append(pinning_printable_options);
}
}
snprintf(buffer, kBufferSize, " block_size: %" PRIu64 "\n",
table_options_.block_size);
ret.append(buffer);
Expand Down

0 comments on commit 858bb1a

Please sign in to comment.