Skip to content

Commit

Permalink
[mono] Remove mono-perfcounters.c and most of mono-counters.c (dotnet…
Browse files Browse the repository at this point in the history
…#66986)

They were disabled already so were behaving as no-ops.
The recommended replacement is using EventCounters.
  • Loading branch information
akoeplinger authored Mar 29, 2022
1 parent ee57513 commit a7c5546
Show file tree
Hide file tree
Showing 41 changed files with 14 additions and 3,995 deletions.
1 change: 0 additions & 1 deletion src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ if(ENABLE_MINIMAL)
endif()

set(DISABLE_COM 1)
set(DISABLE_PERFCOUNTERS 1)

# Dependencies between options
if(ENABLE_INTERP_LIB)
Expand Down
12 changes: 0 additions & 12 deletions src/mono/cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,6 @@
/* Disable Soft Debugger Agent. */
#cmakedefine DISABLE_DEBUGGER_AGENT 1

/* Disable Performance Counters. */
#cmakedefine DISABLE_PERFCOUNTERS 1

/* Disable shared perfcounters. */
#cmakedefine DISABLE_SHARED_PERFCOUNTERS 1

/* Disable support code for the LLDB plugin. */
#cmakedefine DISABLE_LLDB 1

Expand Down Expand Up @@ -312,9 +306,6 @@
/* Disable Threads */
#cmakedefine DISABLE_THREADS 1

/* Disable perf counters */
#cmakedefine DISABLE_PERF_COUNTERS

/* Disable MONO_LOG_DEST */
#cmakedefine DISABLE_LOG_DEST

Expand Down Expand Up @@ -515,9 +506,6 @@
/* Enable support for using sigaltstack for SIGSEGV and stack overflow handling, this doesn't work on some platforms */
#cmakedefine ENABLE_SIGALTSTACK 1

/* Define to 1 if you have the `shm_open' function. */
#cmakedefine HAVE_SHM_OPEN 1

/* Define to 1 if you have the `poll' function. */
#cmakedefine HAVE_POLL 1

Expand Down
2 changes: 1 addition & 1 deletion src/mono/cmake/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ac_check_funcs (
getrusage dladdr sysconf getrlimit prctl nl_langinfo
sched_getaffinity sched_setaffinity getpwuid_r chmod lstat getdtablesize ftruncate msync
getpeername utime utimes openlog closelog atexit popen strerror_r inet_pton inet_aton
shm_open poll getfsstat mremap posix_fadvise vsnprintf sendfile statfs statvfs setpgid system
poll getfsstat mremap posix_fadvise vsnprintf sendfile statfs statvfs setpgid system
fork execv execve waitpid localtime_r mkdtemp getrandom execvp strlcpy stpcpy strtok_r rewinddir
vasprintf strndup getpwuid_r getprotobyname getprotobyname_r getaddrinfo mach_absolute_time
gethrtime read_real_time gethostbyname gethostbyname2 getnameinfo getifaddrs
Expand Down
2 changes: 0 additions & 2 deletions src/mono/cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ option (DISABLE_JIT "Disable the JIT, only full-aot mode or interpreter will be
option (DISABLE_INTERPRETER "Disable the interpreter.")
option (DISABLE_SIMD "Disable SIMD intrinsics related optimizations.")
option (DISABLE_DEBUGGER_AGENT "Disable Soft Debugger Agent.")
option (DISABLE_PERFCOUNTERS "Disable Performance Counters.")
option (DISABLE_SHARED_PERFCOUNTERS "Disable shared perfcounters.")
option (DISABLE_LLDB "Disable support code for the LLDB plugin.")
option (DISABLE_ASSERT_MESSAGES "Disable assertion messages.")
option (DISABLE_SGEN_MAJOR_MARKSWEEP_CONC "Disable concurrent gc support in SGEN.")
Expand Down
5 changes: 2 additions & 3 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
<_MonoMinimal Condition="'$(Configuration)' == 'Release' and '$(MonoEnableAssertMessages)' != 'true'">$(_MonoMinimal),assert_messages</_MonoMinimal>
</PropertyGroup>
<ItemGroup Condition="'$(TargetsBrowser)' == 'true'">
<_MonoCMakeArgs Include="-DENABLE_MINIMAL=jit,sgen_major_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,sgen_debug_helpers,sgen_binary_protocol,logging,shared_perfcounters,interpreter,threads,qcalls$(_MonoMinimal)"/>
<_MonoCMakeArgs Include="-DENABLE_MINIMAL=jit,sgen_major_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,sgen_debug_helpers,sgen_binary_protocol,logging,interpreter,threads,qcalls$(_MonoMinimal)"/>
<_MonoCMakeArgs Include="-DENABLE_INTERP_LIB=1"/>
<_MonoCMakeArgs Include="-DDISABLE_ICALL_TABLES=1"/>
<_MonoCMakeArgs Include="-DENABLE_ICALL_EXPORT=1"/>
Expand Down Expand Up @@ -371,11 +371,10 @@
</ItemGroup>
<!-- iOS/tvOS simulator specific options -->
<ItemGroup Condition="('$(TargetsiOS)' == 'true' and '$(TargetsiOSSimulator)' == 'true') or ('$(TargetstvOS)' == 'true' and '$(TargetstvOSSimulator)' == 'true')">
<_MonoCMakeArgs Include="-DENABLE_MINIMAL=shared_perfcounters"/>
</ItemGroup>
<!-- iOS/tvOS device specific options -->
<ItemGroup Condition="('$(TargetsiOS)' == 'true' and '$(TargetsiOSSimulator)' != 'true') or ('$(TargetstvOS)' == 'true' and '$(TargetstvOSSimulator)' != 'true')">
<_MonoCMakeArgs Include="-DENABLE_MINIMAL=jit,logging,shared_perfcounters" />
<_MonoCMakeArgs Include="-DENABLE_MINIMAL=jit,logging" />
<_MonoCMakeArgs Include="-DENABLE_VISIBILITY_HIDDEN=1"/>
<_MonoCMakeArgs Include="-DENABLE_LAZY_GC_THREAD_CREATION=1"/>
<_MonoCMakeArgs Include="-DENABLE_ICALL_EXPORT=1"/>
Expand Down
3 changes: 0 additions & 3 deletions src/mono/mono/metadata/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ set(metadata_common_sources
mono-hash.h
mono-conc-hash.c
mono-conc-hash.h
mono-perfcounters.c
mono-perfcounters.h
mono-perfcounters-def.h
mono-ptr-array.h
monitor.h
object.c
Expand Down
32 changes: 0 additions & 32 deletions src/mono/mono/metadata/boehm-gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ mono_gc_init_icalls (void)
void
mono_gc_collect (int generation)
{
#ifndef DISABLE_PERFCOUNTERS
mono_atomic_inc_i32 (&mono_perfcounters->gc_induced);
#endif
GC_gcollect ();
}

Expand Down Expand Up @@ -446,10 +443,6 @@ on_gc_notification (GC_EventType event)
case GC_EVENT_START:
e = MONO_GC_EVENT_START;
MONO_GC_BEGIN (1);
#ifndef DISABLE_PERFCOUNTERS
if (mono_perfcounters)
mono_atomic_inc_i32 (&mono_perfcounters->gc_collections0);
#endif
mono_atomic_inc_i32 (&mono_gc_stats.major_gc_count);
gc_start_time = mono_100ns_ticks ();
break;
Expand All @@ -464,17 +457,6 @@ on_gc_notification (GC_EventType event)
sleep(0);
#endif

#ifndef DISABLE_PERFCOUNTERS
if (mono_perfcounters) {
guint64 heap_size = GC_get_heap_size ();
guint64 used_size = heap_size - GC_get_free_bytes ();
/* FIXME: change these to mono_atomic_store_i64 () */
UnlockedWrite64 (&mono_perfcounters->gc_total_bytes, used_size);
UnlockedWrite64 (&mono_perfcounters->gc_committed_bytes, heap_size);
UnlockedWrite64 (&mono_perfcounters->gc_reserved_bytes, heap_size);
UnlockedWrite64 (&mono_perfcounters->gc_gen0size, heap_size);
}
#endif
UnlockedAdd64 (&mono_gc_stats.major_gc_time, mono_100ns_ticks () - gc_start_time);
mono_trace_message (MONO_TRACE_GC, "gc took %" G_GINT64_FORMAT " usecs", (mono_100ns_ticks () - gc_start_time) / 10);
break;
Expand Down Expand Up @@ -512,14 +494,6 @@ static void
on_gc_heap_resize (GC_word new_size)
{
guint64 heap_size = GC_get_heap_size ();
#ifndef DISABLE_PERFCOUNTERS
if (mono_perfcounters) {
/* FIXME: change these to mono_atomic_store_i64 () */
UnlockedWrite64 (&mono_perfcounters->gc_committed_bytes, heap_size);
UnlockedWrite64 (&mono_perfcounters->gc_reserved_bytes, heap_size);
UnlockedWrite64 (&mono_perfcounters->gc_gen0size, heap_size);
}
#endif

MONO_PROFILER_RAISE (gc_resize, (new_size));
}
Expand Down Expand Up @@ -1450,9 +1424,6 @@ alloc_handle (HandleData *handles, MonoObject *obj, gboolean track)
handles->entries [slot] = obj;
}

#ifndef DISABLE_PERFCOUNTERS
mono_atomic_inc_i32 (&mono_perfcounters->gc_num_handles);
#endif
unlock_handles (handles);
res = MONO_GC_HANDLE (slot, handles->type);
MONO_PROFILER_RAISE (gc_handle_created, (res, (MonoGCHandleType)handles->type, obj));
Expand Down Expand Up @@ -1615,9 +1586,6 @@ mono_gchandle_free_internal (MonoGCHandle gch)
} else {
/* print a warning? */
}
#ifndef DISABLE_PERFCOUNTERS
mono_atomic_dec_i32 (&mono_perfcounters->gc_num_handles);
#endif
/*g_print ("freed entry %d of type %d\n", slot, handles->type);*/
unlock_handles (handles);
MONO_PROFILER_RAISE (gc_handle_deleted, (gchandle, (MonoGCHandleType)handles->type));
Expand Down
79 changes: 0 additions & 79 deletions src/mono/mono/metadata/class-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -666,85 +666,6 @@ typedef struct {
gboolean enabled;
} MonoStats;

/*
* new structure to hold performace counters values that are exported
* to managed code.
* Note: never remove fields from this structure and only add them to the end.
* Size of fields and type should not be changed as well.
*/
typedef struct {
/* JIT category */
gint32 jit_methods;
gint32 jit_bytes;
gint32 jit_time;
gint32 jit_failures;
/* Exceptions category */
gint32 exceptions_thrown;
gint32 exceptions_filters;
gint32 exceptions_finallys;
gint32 exceptions_depth;
gint32 aspnet_requests_queued;
gint32 aspnet_requests;
/* Memory category */
gint32 gc_collections0;
gint32 gc_collections1;
gint32 gc_collections2;
gint32 gc_promotions0;
gint32 gc_promotions1;
gint32 gc_promotion_finalizers;
gint64 gc_gen0size;
gint64 gc_gen1size;
gint64 gc_gen2size;
gint32 gc_lossize;
gint32 gc_fin_survivors;
gint32 gc_num_handles;
gint32 gc_allocated;
gint32 gc_induced;
gint32 gc_time;
gint64 gc_total_bytes;
gint64 gc_committed_bytes;
gint64 gc_reserved_bytes;
gint32 gc_num_pinned;
gint32 gc_sync_blocks;
/* Loader category */
gint32 loader_classes;
gint32 loader_total_classes;
gint32 loader_appdomains;
gint32 loader_total_appdomains;
gint32 loader_assemblies;
gint32 loader_total_assemblies;
gint32 loader_failures;
gint32 loader_bytes;
gint32 loader_appdomains_uloaded;
/* Threads and Locks category */
gint32 thread_contentions;
gint32 thread_queue_len;
gint32 thread_queue_max;
gint32 thread_num_logical;
gint32 thread_num_physical;
gint32 thread_cur_recognized;
gint32 thread_num_recognized;
/* Interop category */
gint32 interop_num_ccw;
gint32 interop_num_stubs;
gint32 interop_num_marshals;
/* Security category */
gint32 security_num_checks;
gint32 security_num_link_checks;
gint32 security_time;
gint32 security_depth;
gint32 unused;
/* Threadpool */
gint32 threadpool_threads;
gint64 threadpool_workitems;
gint64 threadpool_ioworkitems;
gint32 threadpool_iothreads;
} MonoPerfCounters;

extern MonoPerfCounters *mono_perfcounters;

MONO_API void mono_perfcounters_init (void);

/*
* The definition of the first field in SafeHandle,
* Keep in sync with SafeHandle.cs, this is only used
Expand Down
1 change: 0 additions & 1 deletion src/mono/mono/metadata/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/metadata-update.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-string.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/mono-logger-internals.h>
Expand Down
1 change: 0 additions & 1 deletion src/mono/mono/metadata/cominterop.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "mono/metadata/threads-types.h"
#include "mono/metadata/string-icalls.h"
#include "mono/metadata/attrdefs.h"
#include "mono/utils/mono-counters.h"
#include "mono/utils/strenc.h"
#include "mono/utils/atomic.h"
#include "mono/utils/mono-error.h"
Expand Down
7 changes: 0 additions & 7 deletions src/mono/mono/metadata/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ create_root_domain (void)

MONO_PROFILER_RAISE (domain_loading, (domain));

#ifndef DISABLE_PERFCOUNTERS
mono_atomic_inc_i32 (&mono_perfcounters->loader_appdomains);
mono_atomic_inc_i32 (&mono_perfcounters->loader_total_appdomains);
#endif

MONO_PROFILER_RAISE (domain_loaded, (domain));

Expand Down Expand Up @@ -169,9 +165,6 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *

mono_w32event_init ();

#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters_init ();
#endif
mono_counters_init ();

mono_counters_register ("Max HashTable Chain Length", MONO_COUNTER_INT|MONO_COUNTER_METADATA, &mono_g_hash_table_max_chain_length);
Expand Down
1 change: 0 additions & 1 deletion src/mono/mono/metadata/icall-decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "handle.h"
#include "marshal.h"
#include "monitor.h"
#include "mono-perfcounters.h"
#include <mono/metadata/object-forward.h>
#include "object-internals.h"
#include <mono/metadata/reflection.h>
Expand Down
1 change: 0 additions & 1 deletion src/mono/mono/metadata/icall.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/cil-coff.h>
#include <mono/metadata/mono-perfcounters.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/mono-ptr-array.h>
#include <mono/metadata/verify-internals.h>
Expand Down
16 changes: 0 additions & 16 deletions src/mono/mono/metadata/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -2290,10 +2290,6 @@ mono_image_close_finish (MonoImage *image)

mono_metadata_update_image_close_all (image);

#ifndef DISABLE_PERFCOUNTERS
/* FIXME: use an explicit subtraction method as soon as it's available */
mono_atomic_fetch_add_i32 (&mono_perfcounters->loader_bytes, -1 * mono_mempool_get_allocated (image->mempool));
#endif

if (!image_is_dynamic (image)) {
if (debug_assembly_unload)
Expand Down Expand Up @@ -2827,9 +2823,6 @@ mono_image_alloc (MonoImage *image, guint size)
{
gpointer res;

#ifndef DISABLE_PERFCOUNTERS
mono_atomic_fetch_add_i32 (&mono_perfcounters->loader_bytes, size);
#endif
mono_image_lock (image);
res = mono_mempool_alloc (image->mempool, size);
mono_image_unlock (image);
Expand All @@ -2842,9 +2835,6 @@ mono_image_alloc0 (MonoImage *image, guint size)
{
gpointer res;

#ifndef DISABLE_PERFCOUNTERS
mono_atomic_fetch_add_i32 (&mono_perfcounters->loader_bytes, size);
#endif
mono_image_lock (image);
res = mono_mempool_alloc0 (image->mempool, size);
mono_image_unlock (image);
Expand All @@ -2857,9 +2847,6 @@ mono_image_strdup (MonoImage *image, const char *s)
{
char *res;

#ifndef DISABLE_PERFCOUNTERS
mono_atomic_fetch_add_i32 (&mono_perfcounters->loader_bytes, (gint32)strlen (s));
#endif
mono_image_lock (image);
res = mono_mempool_strdup (image->mempool, s);
mono_image_unlock (image);
Expand All @@ -2874,9 +2861,6 @@ mono_image_strdup_vprintf (MonoImage *image, const char *format, va_list args)
mono_image_lock (image);
buf = mono_mempool_strdup_vprintf (image->mempool, format, args);
mono_image_unlock (image);
#ifndef DISABLE_PERFCOUNTERS
mono_atomic_fetch_add_i32 (&mono_perfcounters->loader_bytes, (gint32)strlen (buf));
#endif
return buf;
}

Expand Down
1 change: 0 additions & 1 deletion src/mono/mono/metadata/jit-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-membar.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/hazard-pointer.h>
#include <mono/utils/mono-tls.h>
#include <mono/utils/mono-mmap.h>
Expand Down
1 change: 0 additions & 1 deletion src/mono/mono/metadata/marshal-ilgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "mono/metadata/handle.h"
#include "mono/metadata/custom-attrs-internals.h"
#include "mono/metadata/icall-internals.h"
#include "mono/utils/mono-counters.h"
#include "mono/utils/mono-tls.h"
#include "mono/utils/mono-memory-model.h"
#include "mono/utils/atomic.h"
Expand Down
Loading

0 comments on commit a7c5546

Please sign in to comment.