Skip to content

Commit

Permalink
Remove core metrics (#6990)
Browse files Browse the repository at this point in the history
* remove core metrics

* remove metrics from package.swift
  • Loading branch information
ironage authored Sep 20, 2023
1 parent 8de6482 commit 95f4a7c
Show file tree
Hide file tree
Showing 29 changed files with 1 addition and 2,211 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
### Internals
* Update History Command tool to work with realms with fileformat v23 ([PR #6970](https://github.com/realm/realm-core/pull/6970))
* Don't edit the ObjectStore target to enable the libuv scheduler in tests, just register the factory instead. ([PR #6699](https://github.com/realm/realm-core/pull/6699))
* Removed the core metrics which were unused. ([PR 6990](https://github.com/realm/realm-core/pull/6990))

----------------------------------------------

Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ if(NOT EMSCRIPTEN)
endif()
option(REALM_ENABLE_MEMDEBUG "Add additional memory checks" OFF)
option(REALM_VALGRIND "Tell the test suite we are running with valgrind" OFF)
option(REALM_METRICS "Enable various metric tracking" ON)
option(REALM_SYNC_MULTIPLEXING "Enables/disables sync session multiplexing by default" ON)
set(REALM_MAX_BPNODE_SIZE "1000" CACHE STRING "Max B+ tree node size.")
option(REALM_ENABLE_GEOSPATIAL "Enable geospatial types and queries." ON)
Expand Down
2 changes: 0 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ let package = Package(
"realm/CMakeLists.txt",
"realm/exec",
"realm/geospatial.cpp",
"realm/metrics",
"realm/object-store/CMakeLists.txt",
"realm/object-store/c_api",
"realm/object-store/impl/epoll",
Expand Down Expand Up @@ -451,7 +450,6 @@ let package = Package(
"external",
"realm/CMakeLists.txt",
"realm/exec",
"realm/metrics",
"realm/object-store",
"realm/parser",
"realm/sync/CMakeLists.txt",
Expand Down
11 changes: 0 additions & 11 deletions src/realm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,6 @@ set(REALM_INSTALL_HEADERS
util/to_string.hpp
util/type_traits.hpp
util/uri.hpp

metrics/metrics.hpp
metrics/metric_timer.hpp
metrics/query_info.hpp
metrics/transaction_info.hpp
) # REALM_INSTALL_HEADERS

set(REALM_NOINST_HEADERS
Expand All @@ -279,12 +274,6 @@ set(REALM_NOINST_HEADERS
util/value_reset_guard.hpp
) # REALM_NOINST_HEADERS

list(APPEND REALM_SOURCES
metrics/metrics.cpp
metrics/metric_timer.cpp
metrics/query_info.cpp
metrics/transaction_info.cpp)

if(NOT MSVC)
list(APPEND REALM_SOURCES util/interprocess_mutex.cpp)
endif()
Expand Down
14 changes: 0 additions & 14 deletions src/realm/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@


using namespace realm;
using namespace realm::metrics;
using namespace realm::util;
using Durability = DBOptions::Durability;

Expand Down Expand Up @@ -1443,11 +1442,6 @@ void DB::open(const std::string& path, bool no_create_file, const DBOptions& opt
close();
throw;
}
#if REALM_METRICS
if (options.enable_metrics) {
m_metrics = std::make_shared<Metrics>(options.metrics_buffer_size);
}
#endif // REALM_METRICS
m_alloc.set_read_only(true);
}

Expand Down Expand Up @@ -1534,11 +1528,6 @@ void DB::open(Replication& repl, const DBOptions options)

m_file_format_version = target_file_format_version;

#if REALM_METRICS
if (options.enable_metrics) {
m_metrics = std::make_shared<Metrics>(options.metrics_buffer_size);
}
#endif // REALM_METRICS
m_info = info;
m_alloc.set_read_only(true);
}
Expand Down Expand Up @@ -2483,9 +2472,6 @@ void DB::low_level_commit(uint_fast64_t new_version, Transaction& transaction, b
auto live_versions = top_refs.size();
// Do the actual commit
REALM_ASSERT(oldest_version <= new_version);
#if REALM_METRICS
transaction.update_num_objects();
#endif // REALM_METRICS

GroupWriter out(transaction, Durability(info->durability), m_marker_observer.get()); // Throws
out.set_versions(new_version, top_refs, any_new_unreachables);
Expand Down
6 changes: 0 additions & 6 deletions src/realm/db.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <realm/handover_defs.hpp>
#include <realm/impl/changeset_input_stream.hpp>
#include <realm/impl/transact_log.hpp>
#include <realm/metrics/metrics.hpp>
#include <realm/replication.hpp>
#include <realm/util/checked_mutex.hpp>
#include <realm/util/features.h>
Expand Down Expand Up @@ -391,10 +390,6 @@ class DB : public std::enable_shared_from_this<DB> {
/// On the importing side, the top-level accessor being created during
/// import takes ownership of all other accessors (if any) being created as
/// part of the import.
std::shared_ptr<metrics::Metrics> get_metrics()
{
return m_metrics;
}

// Try to grab an exclusive lock of the given realm path's lock file. If the lock
// can be acquired, the callback will be executed with the lock and then return true.
Expand Down Expand Up @@ -507,7 +502,6 @@ class DB : public std::enable_shared_from_this<DB> {
util::InterprocessCondVar m_new_commit_available;
util::InterprocessCondVar m_pick_next_writer;
std::function<void(int, int)> m_upgrade_callback;
std::shared_ptr<metrics::Metrics> m_metrics;
std::unique_ptr<AsyncCommitHelper> m_commit_helper;
std::shared_ptr<util::Logger> m_logger;
bool m_is_sync_agent = false;
Expand Down
8 changes: 0 additions & 8 deletions src/realm/db_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ struct DBOptions {
/// This string should include a trailing slash '/'.
std::string temp_dir = sys_tmp_dir;

/// Controls the feature of collecting various metrics to the DB.
/// A prerequisite is compiling with REALM_METRICS=ON.
bool enable_metrics = false;

/// The maximum number of entries stored by the metrics (if enabled). If this number
/// is exceeded without being consumed, only the most recent entries will be stored.
size_t metrics_buffer_size = 10000;

/// is_immutable should be set to true if run from a read-only file system.
/// this will prevent the DB from making any writes, also disabling the creation
/// of write transactions.
Expand Down
23 changes: 0 additions & 23 deletions src/realm/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ Group::Group(const std::string& file_path, const char* encryption_key)
, m_top(m_alloc)
, m_tables(m_alloc)
, m_table_names(m_alloc)
, m_total_rows(0)
{
init_array_parents();

Expand All @@ -99,7 +98,6 @@ Group::Group(BinaryData buffer, bool take_ownership)
, m_top(m_alloc)
, m_tables(m_alloc)
, m_table_names(m_alloc)
, m_total_rows(0)
{
REALM_ASSERT(buffer.data());

Expand All @@ -118,7 +116,6 @@ Group::Group(SlabAlloc* alloc) noexcept
m_top(m_alloc)
, m_tables(m_alloc)
, m_table_names(m_alloc)
, m_total_rows(0)
{
init_array_parents();
}
Expand Down Expand Up @@ -560,9 +557,6 @@ void Group::attach(ref_type top_ref, bool writable, bool create_group_when_missi
while (m_table_accessors.size() < sz) {
m_table_accessors.emplace_back();
}
#if REALM_METRICS
update_num_objects();
#endif // REALM_METRICS
}


Expand All @@ -578,23 +572,6 @@ void Group::detach() noexcept
m_attached = false;
}

void Group::update_num_objects()
{
#if REALM_METRICS
if (m_metrics) {
// This is quite invasive and completely defeats the lazy loading mechanism
// where table accessors are only instantiated on demand, because they are all created here.

m_total_rows = 0;
auto keys = get_table_keys();
for (auto key : keys) {
ConstTableRef t = get_table(key);
m_total_rows += t->size();
}
}
#endif // REALM_METRICS
}

void Group::attach_shared(ref_type new_top_ref, size_t new_file_size, bool writable, VersionID version)
{
REALM_ASSERT_3(new_top_ref, <, new_file_size);
Expand Down
18 changes: 0 additions & 18 deletions src/realm/group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <realm/exceptions.hpp>
#include <realm/impl/cont_transact_hist.hpp>
#include <realm/impl/output_stream.hpp>
#include <realm/metrics/metrics.hpp>
#include <realm/table.hpp>
#include <realm/util/features.h>
#include <realm/util/input_stream.hpp>
Expand Down Expand Up @@ -615,9 +614,7 @@ class Group : public ArrayParent {

util::UniqueFunction<void(const CascadeNotification&)> m_notify_handler;
util::UniqueFunction<void()> m_schema_change_handler;
std::shared_ptr<metrics::Metrics> m_metrics;
std::vector<ToDeleteRef> m_objects_to_delete;
size_t m_total_rows;

Group(SlabAlloc* alloc) noexcept;
void init_array_parents() noexcept;
Expand Down Expand Up @@ -690,9 +687,6 @@ class Group : public ArrayParent {
void write(util::File& file, const char* encryption_key, uint_fast64_t version_number, TableWriter& writer) const;
void write(std::ostream&, bool pad, uint_fast64_t version_numer, TableWriter& writer) const;

std::shared_ptr<metrics::Metrics> get_metrics() const noexcept;
void set_metrics(std::shared_ptr<metrics::Metrics> other) noexcept;
void update_num_objects();
/// Memory mappings must have been updated to reflect any growth in filesize before
/// calling advance_transact()
void advance_transact(ref_type new_top_ref, util::InputStream*, bool writable);
Expand Down Expand Up @@ -837,8 +831,6 @@ class Group : public ArrayParent {
friend class GroupCommitter;
friend class DB;
friend class _impl::GroupFriend;
friend class metrics::QueryInfo;
friend class metrics::Metrics;
friend class Transaction;
friend class TableKeyIterator;
friend class CascadeState;
Expand Down Expand Up @@ -1175,16 +1167,6 @@ inline void Group::reset_free_space_tracking()
m_alloc.reset_free_space_tracking(); // Throws
}

inline std::shared_ptr<metrics::Metrics> Group::get_metrics() const noexcept
{
return m_metrics;
}

inline void Group::set_metrics(std::shared_ptr<metrics::Metrics> shared) noexcept
{
m_metrics = shared;
}

// The purpose of this class is to give internal access to some, but
// not all of the non-public parts of the Group class.
class _impl::GroupFriend {
Expand Down
10 changes: 0 additions & 10 deletions src/realm/group_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@
#include <realm/disable_sync_to_disk.hpp>
#include <realm/impl/destroy_guard.hpp>
#include <realm/impl/simulated_failure.hpp>
#include <realm/metrics/metric_timer.hpp>
#include <realm/util/miscellaneous.hpp>
#include <realm/util/safe_int_ops.hpp>

using namespace realm;
using namespace realm::util;
using namespace realm::metrics;

namespace realm {
class InMemoryWriter : public _impl::ArrayWriterBase {
Expand Down Expand Up @@ -647,10 +645,6 @@ void GroupWriter::prepare_evacuation()

ref_type GroupWriter::write_group()
{
#if REALM_METRICS
std::unique_ptr<MetricTimer> fsync_timer = Metrics::report_write_time(m_group);
#endif // REALM_METRICS

ALLOC_DBG_COUT("Commit nr " << m_current_version << " ( from " << m_oldest_reachable_version << " )"
<< std::endl);

Expand Down Expand Up @@ -1409,10 +1403,6 @@ void GroupCommitter::commit(ref_type new_top_ref)
bool disable_sync = get_disable_sync_to_disk() || m_durability == Durability::Unsafe;
file_header.m_top_ref[slot_selector] = new_top_ref;

#if REALM_METRICS
std::unique_ptr<MetricTimer> fsync_timer = Metrics::report_fsync_time(m_group);
#endif // REALM_METRICS

// Make sure that that all data relating to the new snapshot is written to
// stable storage before flipping the slot selector
window->encryption_write_barrier(&file_header, sizeof file_header);
Expand Down
Loading

0 comments on commit 95f4a7c

Please sign in to comment.