Adapt import commit batches from observed transaction duration
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
/** Runner-owned feedback, not persisted job state. Probe bounded batches to
|
||||
* distinguish fixed publication cost from the marginal cost of another unit. */
|
||||
export function createImportBatches(budget:number,max:number){
|
||||
let limit=1,observed=false;
|
||||
return Object.freeze({
|
||||
get limit(){return limit;},
|
||||
get observed(){return observed;},
|
||||
record(units:number,elapsed:number){
|
||||
observed=true;
|
||||
if(elapsed>budget){limit=Math.max(1,Math.min(limit-1,Math.floor(units*budget/elapsed)));return;}
|
||||
// A short tail/dependency group does not prove that a larger batch is cheap.
|
||||
if(units>=limit)limit=Math.min(max,limit+Math.max(1,Math.floor(limit/2)));
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user