docs(runtime): explain import scheduling and dependency selection
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
*/
|
||||
/** Runner-owned feedback, not persisted job state. Probe bounded batches to
|
||||
* distinguish fixed publication cost from the marginal cost of another unit. */
|
||||
/** budget/max由runner给出,用实际已提交units和耗时更新下一批软上限。 */
|
||||
/** runner 提供已验证的正 budget/max,并在尝试后反馈 units/elapsed;本函数不自行读取时钟或发布内容。
|
||||
* 闭包只保留 limit 和 observed,重启 runner 会重新从 1 探测,不用持久化这些性能估计。
|
||||
* 参数/样本未在此验证,调用方需传有限且合理的耗时/单位;它不是容量或源完整性校验器。 */
|
||||
export function createImportBatches(budget:number,max:number){
|
||||
// 初始未观测时保守为1;observed只表示收到反馈,不是源校验或导入已完成。
|
||||
let limit=1,observed=false;
|
||||
@@ -13,7 +15,9 @@ export function createImportBatches(budget:number,max:number){
|
||||
get limit(){return limit;},
|
||||
/** 是否已有至少一次发布成本样本,用于runner的调度决策。 */
|
||||
get observed(){return observed;},
|
||||
/** 超时按比例减小并至少降一档;不足当前limit的尾批不能证明更大批也便宜。 */
|
||||
/** 首次反馈即 observed=true;elapsed > budget 按比例缩小,且尽量至少减 1,最低保留 1。
|
||||
* 未超时且 units ≥ limit 才按约 1.5 倍增长并封顶 max;等于 budget 也算此分支。
|
||||
* 不足当前 limit 的尾批不增长,避免将少量记录的固定发布成本误当成更大批仍便宜。 */
|
||||
record(units:number,elapsed:number){
|
||||
observed=true;
|
||||
if(elapsed>budget){limit=Math.max(1,Math.min(limit-1,Math.floor(units*budget/elapsed)));return;}
|
||||
|
||||
Reference in New Issue
Block a user