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

MESDK-87 Add delegate pattern for MessagesQuery<->LintReportQuery communication #2734

Merged
merged 11 commits into from
May 10, 2024

Conversation

martin-lysk
Copy link
Contributor

@martin-lysk martin-lysk commented May 8, 2024

Copy link

changeset-bot bot commented May 8, 2024

🦋 Changeset detected

Latest commit: 7986415

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 29 packages
Name Type
@inlang/sdk Patch
@inlang/badge Patch
@inlang/cli Patch
@inlang/doc-layout-component Patch
@inlang/editor Patch
@inlang/github-lint-action Patch
vs-code-extension Patch
@inlang/message-bundle-component Patch
@inlang/rpc Patch
@inlang/settings-component Patch
@inlang/telemetry Patch
@inlang/cross-sell-ninja Patch
@inlang/plugin-i18next Patch
@inlang/plugin-json Patch
@inlang/plugin-m-function-matcher Patch
@inlang/plugin-next-intl Patch
@inlang/plugin-t-function-matcher Patch
@inlang/paraglide-unplugin Patch
@inlang/paraglide-js-e2e Patch
@inlang/sdk-load-test Patch
@inlang/server Patch
next-js-testapp Patch
@inlang/sdk-multi-project-test Patch
@inlang/paraglide-rollup Patch
@inlang/paraglide-vite Patch
@inlang/paraglide-webpack Patch
@inlang/paraglide-astro Patch
@inlang/paraglide-sveltekit Patch
@inlang/paraglide-sveltekit-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@martin-lysk martin-lysk requested a review from jldec May 8, 2024 13:01
@martin-lysk martin-lysk changed the title Intreduce delegate pattern for Query<->Lintreport communication Add delegate pattern for MessagesQuery<->LintReportQuery communication May 8, 2024
@martin-lysk martin-lysk marked this pull request as ready for review May 8, 2024 17:29
@jldec jldec changed the title Add delegate pattern for MessagesQuery<->LintReportQuery communication MESDK-87 Add delegate pattern for MessagesQuery<->LintReportQuery communication May 9, 2024

return {
getAll: async () => {
// TODO reintroduce reactivity here - wont be the bottleneck
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't spend more time on this TODO - let's remove it.

await sleep(0) // evaluate on next tick to allow for out-of-order effects
return structuredClone(
[...index.values()].flat().length === 0 ? [] : [...index.values()].flat()
)
},
get: async (args: Parameters<MessageLintReportsQueryApi["get"]>[0]) => {
// TODO reintroduce reactivity here
Copy link
Contributor

Choose a reason for hiding this comment

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

same - no need to re-introduce reactivity.

@@ -62,6 +62,13 @@ export function createMessagesQuery({
// filepath for the lock folder
const messageLockDirPath = projectPath + "/messagelock"

// TODO check if we should use a weak ref instead
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer not to complicate the code with weak refs unless really needed.

Copy link
Contributor

@jldec jldec left a comment

Choose a reason for hiding this comment

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

The surprise is that the process dies with an out of memory crash 💥 during a 10k load-test without translation but with watch turned on, which keeps the process alive (pnpm test 10000 0 1 1 1)

I don't understand why the delegate needs so much more memory when we're no longer creating nested effects.

Once I introduced the sleep-every-500-messages fix from #2738, the process no longer crashes, and total memory usage drops to 380MB which is much better (before it would stay pegged at about 2GB). I was even able to load 20k messages, and then translate them!

I pushed a commit to add the sleep during load.

I also filed opral/inlang-sdk#54 and opral/inlang-sdk#53 for important issues found during the investigation.

@jldec jldec mentioned this pull request May 10, 2024
@jldec jldec merged commit cf62aa9 into main May 10, 2024
3 checks passed
@jldec jldec deleted the martinlysk1/mesdk-50 branch May 10, 2024 17:26
@github-actions github-actions bot locked and limited conversation to collaborators May 10, 2024
@jldec
Copy link
Contributor

jldec commented May 10, 2024

See also opral/inlang-sdk#57

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove nested effects for tracking lint reports
2 participants