diff --git a/src/engine.c b/src/engine.c index 163c4710f559b80bbfbbc1e063df03a0415c3828..84157e0545729ca4426284861a8a1be9fd109dd2 100644 --- a/src/engine.c +++ b/src/engine.c @@ -932,10 +932,13 @@ void engine_maketasks ( struct engine *e ) { /* Rank the tasks. */ scheduler_ranktasks( sched ); - + /* Weight the tasks. */ scheduler_reweight( sched ); + /* Set the tasks age. */ + e->tasks_age = 0; + } @@ -1158,6 +1161,11 @@ void engine_prepare ( struct engine *e ) { /* Did this not go through? */ if ( rebuild ) engine_rebuild( e ); + + /* Re-rank the tasks every now and then. */ + if ( e->tasks_age % engine_tasksreweight == 1 ) + scheduler_reweight( &e->sched ); + e->tasks_age += 1; /* Start the scheduler. */ // ticks tic2 = getticks(); diff --git a/src/engine.h b/src/engine.h index a9f6e6d254c47d3f027df738dceeb7054cf4bca8..98e0daab1c902e3ed301ad0dc402fc46e77c3f87 100644 --- a/src/engine.h +++ b/src/engine.h @@ -34,6 +34,7 @@ #define engine_queue_scale 1.2 #define engine_maxtaskspercell 32 #define engine_maxproxies 64 +#define engine_tasksreweight 10 /* The rank of the engine as a global variable (for messages). */ @@ -94,6 +95,9 @@ struct engine { /* Force the engine to rebuild? */ int forcerebuild, forcerepart; + /* How many steps have we done with the same set of tasks? */ + int tasks_age; + };