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

Batching Messages on Initial Project Load #71

Open
LorisSigrist opened this issue May 24, 2024 — with Linear · 6 comments
Open

Batching Messages on Initial Project Load #71

LorisSigrist opened this issue May 24, 2024 — with Linear · 6 comments
Assignees

Comments

Copy link
Member

Context

As discussed with @martin.lysk1

Currently when a large project is loaded the project.query.messages.getAll gets triggered several times with intermediate message states instead of just the final message state.

This causes unnecessary code executions & caching issues in dependent Inlang Apps

Proposal

Batch messages & only trigger the getAll callback once all messages have been loaded.

@jldec
Copy link

jldec commented May 24, 2024

@martin-lysk is this a side effect of the every-500-messages sleep during load?
Would you mind taking a look to see if we should remove that? 🙏

b.t.w. I could not repro this with load-test
Here's a run with 4000 messages and experimental persistence removed from the settings.
The 2nd event was triggered by my edit and save of the messages file.

$ pnpm load-test 4000 0 1 1 1

> @inlang/sdk-load-test@ load-test /Users/jldec/opral/monorepo/inlang/source-code/sdk/load-test
> pnpm clean && MOCK_TRANSLATE_LOCAL=1 DEBUG=$DEBUG,load-test tsx ./main.ts "4000" "0" "1" "1" "1"


> @inlang/sdk-load-test@ clean /Users/jldec/opral/monorepo/inlang/source-code/sdk/load-test
> rm -rf ./locales ./project.inlang/messages.json

  load-test load-test start - watchMode on, ctrl C to exit +0ms
  load-test generating 4000 messages +0ms
  load-test opening repo and loading project +8ms
Using existing cloned repo
  load-test subscribing to project.errors +2s
  load-test subscribing to messages.getAll +0ms
  load-test messages getAll event: 1, length: 4000 +8ms
  load-test subscribing to lintReports.getAll +0ms
  load-test lint reports changed event: 1, length: 144000 +237ms
  load-test load-test done - watching for events +0ms
  load-test messages getAll event: 2, length: 4000 +50s

Copy link

jldec commented May 27, 2024

@martin.lysk, @loris.sigrist please confirm that you have a repro for the issue that this is intended to fix. Thanks

Copy link

As @jldec also checked - this is not the cause of the problem in initial load. We tackle this by batching in sub sequential loads MESDK-111

@martin-lysk martin-lysk closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
@jldec
Copy link

jldec commented May 27, 2024

@martin-lysk does this mean that you can repro the issue by modifying messages after the first load?
I tried to do this by manually editing messages in the file and saving it but that did not produce excess events either.

Copy link
Member Author

We don't have a reliable repro for the original issue, but we can repro the behavior where when making n edits at once you get n callbacks triggered instead of just one with the final state.

Even without the original issue batching would be desirable.

Copy link

jldec commented May 27, 2024

ok - that sounds like an API change similar to what we did for the lintreports `getAll()` api. I'll change the description of MESDK-111 accordingly.

@martin-lysk martin-lysk reopened this May 28, 2024
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

No branches or pull requests

3 participants