Skip to content

Commit 95f4a7c

Browse files
authored
Remove core metrics (#6990)
* remove core metrics * remove metrics from package.swift
1 parent 8de6482 commit 95f4a7c

29 files changed

+1
-2211
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
### Internals
3030
* Update History Command tool to work with realms with fileformat v23 ([PR #6970](https://github.com/realm/realm-core/pull/6970))
3131
* 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))
32+
* Removed the core metrics which were unused. ([PR 6990](https://github.com/realm/realm-core/pull/6990))
3233

3334
----------------------------------------------
3435

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ if(NOT EMSCRIPTEN)
254254
endif()
255255
option(REALM_ENABLE_MEMDEBUG "Add additional memory checks" OFF)
256256
option(REALM_VALGRIND "Tell the test suite we are running with valgrind" OFF)
257-
option(REALM_METRICS "Enable various metric tracking" ON)
258257
option(REALM_SYNC_MULTIPLEXING "Enables/disables sync session multiplexing by default" ON)
259258
set(REALM_MAX_BPNODE_SIZE "1000" CACHE STRING "Max B+ tree node size.")
260259
option(REALM_ENABLE_GEOSPATIAL "Enable geospatial types and queries." ON)

Package.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ let package = Package(
403403
"realm/CMakeLists.txt",
404404
"realm/exec",
405405
"realm/geospatial.cpp",
406-
"realm/metrics",
407406
"realm/object-store/CMakeLists.txt",
408407
"realm/object-store/c_api",
409408
"realm/object-store/impl/epoll",
@@ -451,7 +450,6 @@ let package = Package(
451450
"external",
452451
"realm/CMakeLists.txt",
453452
"realm/exec",
454-
"realm/metrics",
455453
"realm/object-store",
456454
"realm/parser",
457455
"realm/sync/CMakeLists.txt",

src/realm/CMakeLists.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,6 @@ set(REALM_INSTALL_HEADERS
249249
util/to_string.hpp
250250
util/type_traits.hpp
251251
util/uri.hpp
252-
253-
metrics/metrics.hpp
254-
metrics/metric_timer.hpp
255-
metrics/query_info.hpp
256-
metrics/transaction_info.hpp
257252
) # REALM_INSTALL_HEADERS
258253

259254
set(REALM_NOINST_HEADERS
@@ -279,12 +274,6 @@ set(REALM_NOINST_HEADERS
279274
util/value_reset_guard.hpp
280275
) # REALM_NOINST_HEADERS
281276

282-
list(APPEND REALM_SOURCES
283-
metrics/metrics.cpp
284-
metrics/metric_timer.cpp
285-
metrics/query_info.cpp
286-
metrics/transaction_info.cpp)
287-
288277
if(NOT MSVC)
289278
list(APPEND REALM_SOURCES util/interprocess_mutex.cpp)
290279
endif()

src/realm/db.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757

5858

5959
using namespace realm;
60-
using namespace realm::metrics;
6160
using namespace realm::util;
6261
using Durability = DBOptions::Durability;
6362

@@ -1443,11 +1442,6 @@ void DB::open(const std::string& path, bool no_create_file, const DBOptions& opt
14431442
close();
14441443
throw;
14451444
}
1446-
#if REALM_METRICS
1447-
if (options.enable_metrics) {
1448-
m_metrics = std::make_shared<Metrics>(options.metrics_buffer_size);
1449-
}
1450-
#endif // REALM_METRICS
14511445
m_alloc.set_read_only(true);
14521446
}
14531447

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

15351529
m_file_format_version = target_file_format_version;
15361530

1537-
#if REALM_METRICS
1538-
if (options.enable_metrics) {
1539-
m_metrics = std::make_shared<Metrics>(options.metrics_buffer_size);
1540-
}
1541-
#endif // REALM_METRICS
15421531
m_info = info;
15431532
m_alloc.set_read_only(true);
15441533
}
@@ -2483,9 +2472,6 @@ void DB::low_level_commit(uint_fast64_t new_version, Transaction& transaction, b
24832472
auto live_versions = top_refs.size();
24842473
// Do the actual commit
24852474
REALM_ASSERT(oldest_version <= new_version);
2486-
#if REALM_METRICS
2487-
transaction.update_num_objects();
2488-
#endif // REALM_METRICS
24892475

24902476
GroupWriter out(transaction, Durability(info->durability), m_marker_observer.get()); // Throws
24912477
out.set_versions(new_version, top_refs, any_new_unreachables);

src/realm/db.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <realm/handover_defs.hpp>
2525
#include <realm/impl/changeset_input_stream.hpp>
2626
#include <realm/impl/transact_log.hpp>
27-
#include <realm/metrics/metrics.hpp>
2827
#include <realm/replication.hpp>
2928
#include <realm/util/checked_mutex.hpp>
3029
#include <realm/util/features.h>
@@ -391,10 +390,6 @@ class DB : public std::enable_shared_from_this<DB> {
391390
/// On the importing side, the top-level accessor being created during
392391
/// import takes ownership of all other accessors (if any) being created as
393392
/// part of the import.
394-
std::shared_ptr<metrics::Metrics> get_metrics()
395-
{
396-
return m_metrics;
397-
}
398393

399394
// Try to grab an exclusive lock of the given realm path's lock file. If the lock
400395
// can be acquired, the callback will be executed with the lock and then return true.
@@ -507,7 +502,6 @@ class DB : public std::enable_shared_from_this<DB> {
507502
util::InterprocessCondVar m_new_commit_available;
508503
util::InterprocessCondVar m_pick_next_writer;
509504
std::function<void(int, int)> m_upgrade_callback;
510-
std::shared_ptr<metrics::Metrics> m_metrics;
511505
std::unique_ptr<AsyncCommitHelper> m_commit_helper;
512506
std::shared_ptr<util::Logger> m_logger;
513507
bool m_is_sync_agent = false;

src/realm/db_options.hpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,6 @@ struct DBOptions {
8080
/// This string should include a trailing slash '/'.
8181
std::string temp_dir = sys_tmp_dir;
8282

83-
/// Controls the feature of collecting various metrics to the DB.
84-
/// A prerequisite is compiling with REALM_METRICS=ON.
85-
bool enable_metrics = false;
86-
87-
/// The maximum number of entries stored by the metrics (if enabled). If this number
88-
/// is exceeded without being consumed, only the most recent entries will be stored.
89-
size_t metrics_buffer_size = 10000;
90-
9183
/// is_immutable should be set to true if run from a read-only file system.
9284
/// this will prevent the DB from making any writes, also disabling the creation
9385
/// of write transactions.

src/realm/group.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ Group::Group(const std::string& file_path, const char* encryption_key)
7676
, m_top(m_alloc)
7777
, m_tables(m_alloc)
7878
, m_table_names(m_alloc)
79-
, m_total_rows(0)
8079
{
8180
init_array_parents();
8281

@@ -99,7 +98,6 @@ Group::Group(BinaryData buffer, bool take_ownership)
9998
, m_top(m_alloc)
10099
, m_tables(m_alloc)
101100
, m_table_names(m_alloc)
102-
, m_total_rows(0)
103101
{
104102
REALM_ASSERT(buffer.data());
105103

@@ -118,7 +116,6 @@ Group::Group(SlabAlloc* alloc) noexcept
118116
m_top(m_alloc)
119117
, m_tables(m_alloc)
120118
, m_table_names(m_alloc)
121-
, m_total_rows(0)
122119
{
123120
init_array_parents();
124121
}
@@ -560,9 +557,6 @@ void Group::attach(ref_type top_ref, bool writable, bool create_group_when_missi
560557
while (m_table_accessors.size() < sz) {
561558
m_table_accessors.emplace_back();
562559
}
563-
#if REALM_METRICS
564-
update_num_objects();
565-
#endif // REALM_METRICS
566560
}
567561

568562

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

581-
void Group::update_num_objects()
582-
{
583-
#if REALM_METRICS
584-
if (m_metrics) {
585-
// This is quite invasive and completely defeats the lazy loading mechanism
586-
// where table accessors are only instantiated on demand, because they are all created here.
587-
588-
m_total_rows = 0;
589-
auto keys = get_table_keys();
590-
for (auto key : keys) {
591-
ConstTableRef t = get_table(key);
592-
m_total_rows += t->size();
593-
}
594-
}
595-
#endif // REALM_METRICS
596-
}
597-
598575
void Group::attach_shared(ref_type new_top_ref, size_t new_file_size, bool writable, VersionID version)
599576
{
600577
REALM_ASSERT_3(new_top_ref, <, new_file_size);

src/realm/group.hpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include <realm/exceptions.hpp>
3232
#include <realm/impl/cont_transact_hist.hpp>
3333
#include <realm/impl/output_stream.hpp>
34-
#include <realm/metrics/metrics.hpp>
3534
#include <realm/table.hpp>
3635
#include <realm/util/features.h>
3736
#include <realm/util/input_stream.hpp>
@@ -615,9 +614,7 @@ class Group : public ArrayParent {
615614

616615
util::UniqueFunction<void(const CascadeNotification&)> m_notify_handler;
617616
util::UniqueFunction<void()> m_schema_change_handler;
618-
std::shared_ptr<metrics::Metrics> m_metrics;
619617
std::vector<ToDeleteRef> m_objects_to_delete;
620-
size_t m_total_rows;
621618

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

693-
std::shared_ptr<metrics::Metrics> get_metrics() const noexcept;
694-
void set_metrics(std::shared_ptr<metrics::Metrics> other) noexcept;
695-
void update_num_objects();
696690
/// Memory mappings must have been updated to reflect any growth in filesize before
697691
/// calling advance_transact()
698692
void advance_transact(ref_type new_top_ref, util::InputStream*, bool writable);
@@ -837,8 +831,6 @@ class Group : public ArrayParent {
837831
friend class GroupCommitter;
838832
friend class DB;
839833
friend class _impl::GroupFriend;
840-
friend class metrics::QueryInfo;
841-
friend class metrics::Metrics;
842834
friend class Transaction;
843835
friend class TableKeyIterator;
844836
friend class CascadeState;
@@ -1175,16 +1167,6 @@ inline void Group::reset_free_space_tracking()
11751167
m_alloc.reset_free_space_tracking(); // Throws
11761168
}
11771169

1178-
inline std::shared_ptr<metrics::Metrics> Group::get_metrics() const noexcept
1179-
{
1180-
return m_metrics;
1181-
}
1182-
1183-
inline void Group::set_metrics(std::shared_ptr<metrics::Metrics> shared) noexcept
1184-
{
1185-
m_metrics = shared;
1186-
}
1187-
11881170
// The purpose of this class is to give internal access to some, but
11891171
// not all of the non-public parts of the Group class.
11901172
class _impl::GroupFriend {

src/realm/group_writer.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@
2828
#include <realm/disable_sync_to_disk.hpp>
2929
#include <realm/impl/destroy_guard.hpp>
3030
#include <realm/impl/simulated_failure.hpp>
31-
#include <realm/metrics/metric_timer.hpp>
3231
#include <realm/util/miscellaneous.hpp>
3332
#include <realm/util/safe_int_ops.hpp>
3433

3534
using namespace realm;
3635
using namespace realm::util;
37-
using namespace realm::metrics;
3836

3937
namespace realm {
4038
class InMemoryWriter : public _impl::ArrayWriterBase {
@@ -647,10 +645,6 @@ void GroupWriter::prepare_evacuation()
647645

648646
ref_type GroupWriter::write_group()
649647
{
650-
#if REALM_METRICS
651-
std::unique_ptr<MetricTimer> fsync_timer = Metrics::report_write_time(m_group);
652-
#endif // REALM_METRICS
653-
654648
ALLOC_DBG_COUT("Commit nr " << m_current_version << " ( from " << m_oldest_reachable_version << " )"
655649
<< std::endl);
656650

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

1412-
#if REALM_METRICS
1413-
std::unique_ptr<MetricTimer> fsync_timer = Metrics::report_fsync_time(m_group);
1414-
#endif // REALM_METRICS
1415-
14161406
// Make sure that that all data relating to the new snapshot is written to
14171407
// stable storage before flipping the slot selector
14181408
window->encryption_write_barrier(&file_header, sizeof file_header);

0 commit comments

Comments
 (0)