Skip to content

Commit 2712633

Browse files
authored
remove stale objprofile (#54991)
As mentioned in #54968, `OBJPROFILE` exposes a functionality which is quite similar to what the heap snapshot does, but has a considerably worse visualization tool (i.e. raw printf's compared to the snapshot viewer from Chrome). Closes #54968.
1 parent 7579659 commit 2712633

File tree

4 files changed

+0
-136
lines changed

4 files changed

+0
-136
lines changed

src/gc-debug.c

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -576,90 +576,6 @@ void jl_gc_debug_print_status(void)
576576
}
577577
#endif
578578

579-
#ifdef OBJPROFILE
580-
static htable_t obj_counts[3];
581-
static htable_t obj_sizes[3];
582-
void objprofile_count(void *ty, int old, int sz)
583-
{
584-
if (gc_verifying) return;
585-
if ((intptr_t)ty <= 0x10) {
586-
ty = (void*)jl_buff_tag;
587-
}
588-
else if (ty != (void*)jl_buff_tag && ty != jl_malloc_tag &&
589-
jl_is_datatype(ty) && jl_is_datatype_singleton((jl_datatype_t*)ty)) {
590-
ty = jl_singleton_tag;
591-
}
592-
void **bp = ptrhash_bp(&obj_counts[old], ty);
593-
if (*bp == HT_NOTFOUND)
594-
*bp = (void*)2;
595-
else
596-
(*((intptr_t*)bp))++;
597-
bp = ptrhash_bp(&obj_sizes[old], ty);
598-
if (*bp == HT_NOTFOUND)
599-
*bp = (void*)(intptr_t)(1 + sz);
600-
else
601-
*((intptr_t*)bp) += sz;
602-
}
603-
604-
void objprofile_reset(void)
605-
{
606-
for (int g = 0; g < 3; g++) {
607-
htable_reset(&obj_counts[g], 0);
608-
htable_reset(&obj_sizes[g], 0);
609-
}
610-
}
611-
612-
static void objprofile_print(htable_t nums, htable_t sizes)
613-
{
614-
for(int i=0; i < nums.size; i+=2) {
615-
if (nums.table[i+1] != HT_NOTFOUND) {
616-
void *ty = nums.table[i];
617-
int num = (intptr_t)nums.table[i + 1] - 1;
618-
size_t sz = (uintptr_t)ptrhash_get(&sizes, ty) - 1;
619-
static const int ptr_hex_width = 2 * sizeof(void*);
620-
if (sz > 2e9) {
621-
jl_safe_printf(" %6d : %*.1f GB of (%*p) ",
622-
num, 6, ((double)sz) / 1024 / 1024 / 1024,
623-
ptr_hex_width, ty);
624-
}
625-
else if (sz > 2e6) {
626-
jl_safe_printf(" %6d : %*.1f MB of (%*p) ",
627-
num, 6, ((double)sz) / 1024 / 1024,
628-
ptr_hex_width, ty);
629-
}
630-
else if (sz > 2e3) {
631-
jl_safe_printf(" %6d : %*.1f kB of (%*p) ",
632-
num, 6, ((double)sz) / 1024,
633-
ptr_hex_width, ty);
634-
}
635-
else {
636-
jl_safe_printf(" %6d : %*d B of (%*p) ",
637-
num, 6, (int)sz, ptr_hex_width, ty);
638-
}
639-
if (ty == (void*)jl_buff_tag)
640-
jl_safe_printf("#<buffer>");
641-
else if (ty == jl_malloc_tag)
642-
jl_safe_printf("#<malloc>");
643-
else if (ty == jl_singleton_tag)
644-
jl_safe_printf("#<singletons>");
645-
else
646-
jl_static_show(JL_STDERR, (jl_value_t*)ty);
647-
jl_safe_printf("\n");
648-
}
649-
}
650-
}
651-
652-
void objprofile_printall(void)
653-
{
654-
jl_safe_printf("Transient mark :\n");
655-
objprofile_print(obj_counts[0], obj_sizes[0]);
656-
jl_safe_printf("Perm mark :\n");
657-
objprofile_print(obj_counts[1], obj_sizes[1]);
658-
jl_safe_printf("Remset :\n");
659-
objprofile_print(obj_counts[2], obj_sizes[2]);
660-
}
661-
#endif
662-
663579
#if defined(GC_TIME) || defined(GC_FINAL_STATS)
664580
STATIC_INLINE double jl_ns2ms(int64_t t)
665581
{
@@ -993,13 +909,6 @@ void jl_gc_debug_init(void)
993909
arraylist_new(&lostval_parents_done, 0);
994910
#endif
995911

996-
#ifdef OBJPROFILE
997-
for (int g = 0; g < 3; g++) {
998-
htable_new(&obj_counts[g], 0);
999-
htable_new(&obj_sizes[g], 0);
1000-
}
1001-
#endif
1002-
1003912
#ifdef GC_FINAL_STATS
1004913
process_t0 = jl_hrtime();
1005914
#endif

src/gc.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,6 @@ STATIC_INLINE void gc_setmark_big(jl_ptls_t ptls, jl_taggedvalue_t *o,
845845
gc_queue_big_marked(ptls, hdr, 1);
846846
}
847847
}
848-
objprofile_count(jl_typeof(jl_valueof(o)),
849-
mark_mode == GC_OLD_MARKED, hdr->sz);
850848
}
851849

852850
// This function should be called exactly once during marking for each pool
@@ -868,8 +866,6 @@ STATIC_INLINE void gc_setmark_pool_(jl_ptls_t ptls, jl_taggedvalue_t *o,
868866
page->has_young = 1;
869867
}
870868
}
871-
objprofile_count(jl_typeof(jl_valueof(o)),
872-
mark_mode == GC_OLD_MARKED, page->osize);
873869
page->has_marked = 1;
874870
#endif
875871
}
@@ -2689,8 +2685,6 @@ FORCE_INLINE void gc_mark_outrefs(jl_ptls_t ptls, jl_gc_markqueue_t *mq, void *_
26892685
size_t dtsz = l * sizeof(void *) + sizeof(jl_svec_t);
26902686
if (update_meta)
26912687
gc_setmark(ptls, o, bits, dtsz);
2692-
else if (foreign_alloc)
2693-
objprofile_count(jl_simplevector_type, bits == GC_OLD_MARKED, dtsz);
26942688
jl_value_t *objary_parent = new_obj;
26952689
jl_value_t **objary_begin = data;
26962690
jl_value_t **objary_end = data + l;
@@ -2701,17 +2695,13 @@ FORCE_INLINE void gc_mark_outrefs(jl_ptls_t ptls, jl_gc_markqueue_t *mq, void *_
27012695
else if (vtag == jl_module_tag << 4) {
27022696
if (update_meta)
27032697
gc_setmark(ptls, o, bits, sizeof(jl_module_t));
2704-
else if (foreign_alloc)
2705-
objprofile_count(jl_module_type, bits == GC_OLD_MARKED, sizeof(jl_module_t));
27062698
jl_module_t *mb_parent = (jl_module_t *)new_obj;
27072699
uintptr_t nptr = ((mb_parent->usings.len + 1) << 2) | (bits & GC_OLD);
27082700
gc_mark_module_binding(ptls, mb_parent, nptr, bits);
27092701
}
27102702
else if (vtag == jl_task_tag << 4) {
27112703
if (update_meta)
27122704
gc_setmark(ptls, o, bits, sizeof(jl_task_t));
2713-
else if (foreign_alloc)
2714-
objprofile_count(jl_task_type, bits == GC_OLD_MARKED, sizeof(jl_task_t));
27152705
jl_task_t *ta = (jl_task_t *)new_obj;
27162706
gc_scrub_record_task(ta);
27172707
if (gc_cblist_task_scanner) {
@@ -2780,16 +2770,12 @@ FORCE_INLINE void gc_mark_outrefs(jl_ptls_t ptls, jl_gc_markqueue_t *mq, void *_
27802770
size_t dtsz = jl_string_len(new_obj) + sizeof(size_t) + 1;
27812771
if (update_meta)
27822772
gc_setmark(ptls, o, bits, dtsz);
2783-
else if (foreign_alloc)
2784-
objprofile_count(jl_string_type, bits == GC_OLD_MARKED, dtsz);
27852773
}
27862774
else {
27872775
jl_datatype_t *vt = ijl_small_typeof[vtag / sizeof(*ijl_small_typeof)];
27882776
size_t dtsz = jl_datatype_size(vt);
27892777
if (update_meta)
27902778
gc_setmark(ptls, o, bits, dtsz);
2791-
else if (foreign_alloc)
2792-
objprofile_count(vt, bits == GC_OLD_MARKED, dtsz);
27932779
}
27942780
return;
27952781
}
@@ -2808,17 +2794,12 @@ FORCE_INLINE void gc_mark_outrefs(jl_ptls_t ptls, jl_gc_markqueue_t *mq, void *_
28082794
else
28092795
gc_setmark_big(ptls, o, bits);
28102796
}
2811-
else if (foreign_alloc) {
2812-
objprofile_count(vt, bits == GC_OLD_MARKED, sizeof(jl_genericmemory_t));
2813-
}
28142797
int how = jl_genericmemory_how(m);
28152798
if (how == 0 || how == 2) {
28162799
gc_heap_snapshot_record_hidden_edge(new_obj, m->ptr, jl_genericmemory_nbytes(m), how == 0 ? 2 : 0);
28172800
}
28182801
else if (how == 1) {
28192802
if (update_meta || foreign_alloc) {
2820-
objprofile_count(jl_malloc_tag, bits == GC_OLD_MARKED,
2821-
jl_genericmemory_nbytes(m));
28222803
size_t nb = jl_genericmemory_nbytes(m);
28232804
gc_heap_snapshot_record_hidden_edge(new_obj, m->ptr, nb, 0);
28242805
if (bits == GC_OLD_MARKED) {
@@ -2885,8 +2866,6 @@ FORCE_INLINE void gc_mark_outrefs(jl_ptls_t ptls, jl_gc_markqueue_t *mq, void *_
28852866
size_t dtsz = jl_datatype_size(vt);
28862867
if (update_meta)
28872868
gc_setmark(ptls, o, bits, dtsz);
2888-
else if (foreign_alloc)
2889-
objprofile_count(vt, bits == GC_OLD_MARKED, dtsz);
28902869
if (vt == jl_weakref_type)
28912870
return;
28922871
const jl_datatype_layout_t *layout = vt->layout;
@@ -3222,7 +3201,6 @@ static void gc_premark(jl_ptls_t ptls2)
32223201
void **items = remset->items;
32233202
for (size_t i = 0; i < len; i++) {
32243203
jl_value_t *item = (jl_value_t *)items[i];
3225-
objprofile_count(jl_typeof(item), 2, 0);
32263204
jl_astaggedvalue(item)->bits.gc = GC_OLD_MARKED;
32273205
}
32283206
}
@@ -3617,8 +3595,6 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
36173595
gc_verify(ptls);
36183596
gc_stats_all_pool();
36193597
gc_stats_big_obj();
3620-
objprofile_printall();
3621-
objprofile_reset();
36223598
gc_num.total_allocd += gc_num.allocd;
36233599
if (!prev_sweep_full)
36243600
promoted_bytes += perm_scanned_bytes - last_perm_scanned_bytes;

src/gc.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -744,24 +744,6 @@ static inline void gc_scrub(void)
744744
}
745745
#endif
746746

747-
#ifdef OBJPROFILE
748-
void objprofile_count(void *ty, int old, int sz) JL_NOTSAFEPOINT;
749-
void objprofile_printall(void);
750-
void objprofile_reset(void);
751-
#else
752-
static inline void objprofile_count(void *ty, int old, int sz) JL_NOTSAFEPOINT
753-
{
754-
}
755-
756-
static inline void objprofile_printall(void)
757-
{
758-
}
759-
760-
static inline void objprofile_reset(void)
761-
{
762-
}
763-
#endif
764-
765747
#ifdef MEMPROFILE
766748
void gc_stats_all_pool(void);
767749
void gc_stats_big_obj(void);

src/options.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@
7474
// GC_TIME prints time taken by each phase of GC
7575
// #define GC_TIME
7676

77-
// OBJPROFILE counts objects by type
78-
// #define OBJPROFILE
79-
8077
// pool allocator configuration options
8178

8279
// GC_SMALL_PAGE allocates objects in 4k pages

0 commit comments

Comments
 (0)