Skip to content

Commit

Permalink
Tweak compunit heuristic for EVAL/BEGIN-heavy code
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Aug 1, 2017
1 parent 10203d7 commit 99332f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/core/threadcontext.h
Expand Up @@ -180,6 +180,11 @@ struct MVMThreadContext {
* change to produce some specializations. */
AO_t spesh_log_quota;

/* We try to do better at OSR by creating a fresh log when we enter a new
* compilation unit. However, for things that EVAL or do a ton of BEGIN,
* this does more harm than good. Use this to throttle it back. */
MVMuint32 num_compunit_extra_logs;

/* The current specialization correlation ID, used in logging. */
MVMuint32 spesh_cid;

Expand Down
16 changes: 9 additions & 7 deletions src/spesh/log.c
Expand Up @@ -59,13 +59,15 @@ void commit_entry(MVMThreadContext *tc, MVMSpeshLog *sl) {
* enough data recorded for a tight outer loop in a benchmark. Either grant a
* bonus log or send the log early so we can have a fresh one. */
void MVM_spesh_log_new_compunit(MVMThreadContext *tc) {
if (tc->spesh_log)
if (tc->spesh_log->body.used > tc->spesh_log->body.limit / 4)
send_log(tc, tc->spesh_log);
if (!tc->spesh_log) {
if (MVM_incr(&(tc->spesh_log_quota)) == 0) {
tc->spesh_log = MVM_spesh_log_create(tc, tc->thread_obj);
tc->spesh_log->body.was_compunit_bumped = 1;
if (tc->num_compunit_extra_logs++ < 5) {
if (tc->spesh_log)
if (tc->spesh_log->body.used > tc->spesh_log->body.limit / 4)
send_log(tc, tc->spesh_log);
if (!tc->spesh_log) {
if (MVM_incr(&(tc->spesh_log_quota)) == 0) {
tc->spesh_log = MVM_spesh_log_create(tc, tc->thread_obj);
tc->spesh_log->body.was_compunit_bumped = 1;
}
}
}
}
Expand Down

0 comments on commit 99332f2

Please sign in to comment.