Repository-Metriken
- Stars
- (1 Star)
- PR-Merge-Metriken
- (PR-Metriken ausstehend)
Beschreibung
From benchmarks it is clear, that batching can reduce performance a lot and should be applied with care (read for heavy network operations):
load x 896,756 ops/sec ±3.82% (79 runs sampled)
PBatch x 5,118 ops/sec ±2.37% (79 runs sampled)
dataloader x 4,931 ops/sec ±1.65% (83 runs sampled)
But we have cases, when loader can be optimised with SSE computation and it looks like a case for batching. In such cases we can gather multiple keys in a loop and launch addKeys for them. But performance will be eaten by spawning Promise, which we do not use! To reduce spawned Promise count we can:
addAllcan callloaderimmediatelyaddAllcan store group of keys and resolve only one promise, but still call load on multiple groups
In both ways it should respect maxBatchSize option.
First way can be faster, because we do not need to concatenate keys to this._batch, but this leads to underutilization of loader.
Maybe an option to addAll could switch between cases: immediately, deferred and ratio (which means – if there are more keys than maxBatchSize * ratio then do immediately, otherwise deferred).