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

feat: Implement worker threads for upload processing #1591

Merged
merged 7 commits into from
Sep 1, 2024

Conversation

aalemayhu
Copy link
Contributor

@aalemayhu aalemayhu commented Aug 31, 2024

Unfortunately the node worker threads cannot share buffers reliably with the main thread. I learned this the hard way 😅
So I have move all of the read writes of the APKG payload to be be based on file system access which is thread safe since we only read after writes.

While reviewing the code path, I discovered that we actually do a lot of wasteful reads and writes. Essentially for every APKG generation we make 2x calls due to the renaming to provide the uploader with friendly name. I have not measured how long this takes but instead of double work we do this one time and rely on the create_deck having the right name.

Revert of revert #1589
Reference: 2anki/create_deck#93

@@ -61,7 +61,12 @@ class DownloadController {
return;
}

const page = DownloadPage({ id, files });
console.log('files', files);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove debug log

@aalemayhu aalemayhu marked this pull request as ready for review September 1, 2024 18:18
Do not copy apkg when not used. Due to the thread changes we do not to
keep the buffer in memory.
const page = DownloadPage({
id,
files: files.filter((file) => file.endsWith('.apkg')),
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not want to index images and other files

Copy link

sonarcloud bot commented Sep 1, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@aalemayhu aalemayhu merged commit 4e12767 into main Sep 1, 2024
3 of 4 checks passed
@aalemayhu aalemayhu deleted the revert-1590-revert-1589-fix/handle-blocking branch September 1, 2024 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant