Skip to content

Commit

Permalink
Prefetching for sweep
Browse files Browse the repository at this point in the history
  • Loading branch information
stedolan committed Sep 22, 2020
1 parent 2383971 commit b419956
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions runtime/caml/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ CAMLdeprecated_typedef(addr, char *);
#error "How do I align values on this platform?"
#endif

/* Prefetching */

#ifdef CAML_INTERNALS
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
#define caml_prefetch(p) __builtin_prefetch((p), 1, 3)
#else
#define caml_prefetch(p)
#endif
#endif

/* CAMLunused is preserved for compatibility reasons.
Instead of the legacy GCC/Clang-only
CAMLunused foo;
Expand Down
1 change: 1 addition & 0 deletions runtime/freelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,7 @@ static header_t *bf_merge_block (value bp, char *limit)
}
caml_fl_cur_wsz += Whsize_val (cur);
next:
caml_prefetch(Hp_val(cur + 4096));
cur = Next_in_mem (cur);
if (Hp_val (cur) >= (header_t *) limit){
CAMLassert (Hp_val (cur) == (header_t *) limit);
Expand Down
1 change: 1 addition & 0 deletions runtime/major_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ static void sweep_slice (intnat work)
limit = sweep_chunk + Chunk_size(sweep_chunk);
while (work > 0){
if (sweep_hp < limit){
caml_prefetch(sweep_hp + 4096);
hp = sweep_hp;
hd = Hd_hp (hp);
work -= Whsize_hd (hd);
Expand Down

0 comments on commit b419956

Please sign in to comment.