Skip to content

Commit

Permalink
[Web] Fix NDArrayCache loading report callback (#16631)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickzx committed Feb 23, 2024
1 parent 72ce701 commit a6ab8cb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions web/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,7 @@ export class Instance implements Disposable {
totalBytes += list[i].nbytes;
}
let fetchedBytes = 0;
let fetchedShards = 0;
let timeElapsed = 0;

const cacheOnly = await artifactCache.hasAllKeys(list.map(key => new URL(key.dataPath, ndarrayCacheUrl).href))
Expand Down Expand Up @@ -1550,9 +1551,7 @@ export class Instance implements Disposable {
}

const processShard = async (i: number) => {
reportCallback(i);
const shard = list[i];
fetchedBytes += shard.nbytes;
const dataUrl = new URL(shard.dataPath, ndarrayCacheUrl).href;
let buffer;
try {
Expand Down Expand Up @@ -1591,6 +1590,8 @@ export class Instance implements Disposable {
}
}
timeElapsed = Math.ceil((perf.now() - tstart) / 1000);
fetchedBytes += shard.nbytes;
reportCallback(fetchedShards++);
}
await Promise.all(list.map((_, index) => processShard(index)));
reportCallback(list.length);
Expand Down

0 comments on commit a6ab8cb

Please sign in to comment.