Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Web] Fix NDArrayCache loading report callback #16631

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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