Skip to content

Commit

Permalink
Querying number of removed entries and bins
Browse files Browse the repository at this point in the history
This is for the Rust part of the binding to visualize the number of
entries and bins removed in specific work packets.
  • Loading branch information
wks committed Oct 18, 2024
1 parent d04fe24 commit 0013d31
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions include/ruby/st.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ void rb_hash_bulk_insert_into_st_table(long, const VALUE *, VALUE);
#if USE_MMTK
size_t rb_mmtk_st_get_num_entries(const st_table *tab);
void rb_mmtk_st_get_size_info(const st_table *tab, size_t *entries_start, size_t *entries_bound, size_t *bins_num);
void rb_mmtk_st_update_entries_range(st_table *tab, size_t begin, size_t end, bool weak_keys, bool weak_records, bool forward);
void rb_mmtk_st_update_bins_range(st_table *tab, size_t begin, size_t end);
size_t rb_mmtk_st_update_entries_range(st_table *tab, size_t begin, size_t end, bool weak_keys, bool weak_records, bool forward);
size_t rb_mmtk_st_update_bins_range(st_table *tab, size_t begin, size_t end);
void rb_mmtk_st_update_dedup_table(st_table *tab);
#endif

Expand Down
14 changes: 7 additions & 7 deletions internal/mmtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ typedef struct MMTk_RubyUpcalls {
size_t *entries_start,
size_t *entries_bound,
size_t *bins_num);
void (*st_update_entries_range)(struct st_table *table,
size_t begin,
size_t end,
bool weak_keys,
bool weak_records,
bool forward);
void (*st_update_bins_range)(struct st_table *table, size_t begin, size_t end);
size_t (*st_update_entries_range)(struct st_table *table,
size_t begin,
size_t end,
bool weak_keys,
bool weak_records,
bool forward);
size_t (*st_update_bins_range)(struct st_table *table, size_t begin, size_t end);
} MMTk_RubyUpcalls;

typedef struct MMTk_RawVecOfObjRef {
Expand Down
11 changes: 9 additions & 2 deletions st.c
Original file line number Diff line number Diff line change
Expand Up @@ -2380,7 +2380,7 @@ rb_mmtk_st_maybe_update_key_record(st_data_t *slot, bool weak, bool forward)
return delete_entry;
}

void
size_t
rb_mmtk_st_update_entries_range(st_table *tab, size_t begin, size_t end, bool weak_keys, bool weak_records, bool forward)
{
// Either the keys or the values must be weak, otherwise it is a strong table.
Expand Down Expand Up @@ -2417,15 +2417,19 @@ rb_mmtk_st_update_entries_range(st_table *tab, size_t begin, size_t end, bool we
}

rbimpl_atomic_size_sub(&tab->num_entries, deleted_entries);

return deleted_entries;
}

void
size_t
rb_mmtk_st_update_bins_range(st_table *tab, size_t begin, size_t end)
{
RUBY_ASSERT(end <= get_bins_num(tab));

unsigned int const size_ind = get_size_ind(tab);

size_t deleted_bins = 0;

// Delete bins that point to deleted entries.
for (st_index_t ind = begin; ind < end; ind++) {
st_index_t bin = get_bin(tab->bins, size_ind, ind);
Expand All @@ -2435,8 +2439,11 @@ rb_mmtk_st_update_bins_range(st_table *tab, size_t begin, size_t end)
st_table_entry *entry = &tab->entries[bin - ENTRY_BASE];
if (DELETED_ENTRY_P(entry)) {
MARK_BIN_DELETED(tab, ind);
deleted_bins++;
}
}

return deleted_bins;
}

// Update a deduplication table.
Expand Down

0 comments on commit 0013d31

Please sign in to comment.