js-lingui icon indicating copy to clipboard operation
js-lingui copied to clipboard

Make `lingui compile` support concurrent mode?

Open yunsii opened this issue 6 months ago • 4 comments

Problem Description

It will generate too many po files with dependency tree crawling in a big project. So it took quite some time to compile.

Proposed Solution

Make lingui compile support concurrent mode.

Alternatives Considered

Maybe not.

Additional Context

https://deepwiki.com/search/how-many-concurrent-limit-with_5a79ea40-5634-4a22-9c71-64fed3398c60

yunsii avatar May 16 '25 14:05 yunsii

Hello! How much is "quite some time" ? I need to understand the baseline

timofei-iatsenko avatar May 19 '25 06:05 timofei-iatsenko

Now we have more than 4000 po files, it spend more than 1000 seconds in local machine.

Image

yunsii avatar May 19 '25 07:05 yunsii

@yunsii there is a pretty simple code processing this one, it should be quite simple change to make it concurent instead of sequential, could you try doing this locally and compare the results?

I'm afraid that just making this concurrent (single core, utilizing event-loop) wouldn't be enough, what you actually want to make it parallel (running on multiple machine cores), this might be a slighlty bigger change.

The problem is that i don't have such a big project to play with, making it parallel using multiple cores may not make it faster because of overhead of spawning multiple workers, reading / compiling lingui configuration and so on. So ideally would be nice to have something big and than play with it.

(just thinking outloud, may be just generate some set of dummy catalogs for perf test...)

timofei-iatsenko avatar May 19 '25 07:05 timofei-iatsenko

Okey, we will do a test in our spare time.

yunsii avatar May 19 '25 07:05 yunsii

@yunsii i added a full concurrency for extract / compile, could you compare how that helped (if helped at all)

timofei-iatsenko avatar Jul 30 '25 13:07 timofei-iatsenko

@timofei-iatsenko Could you release a pre-release version for testing?

yunsii avatar Jul 31 '25 01:07 yunsii

I plan to release a new version this week. In addition, there are some minor fixes waiting. It may be a regular release, just to avoid overcomplicating things with a pre-release.

andrii-bodnar avatar Jul 31 '25 07:07 andrii-bodnar

Just chiming in here, for my own use case (~43 pofiles, ~6700 keys) lingui compile takes around 1000s on both 5.4.0 and 5.3.3. It seems to use a full CPU core the whole time in both cases, so I think it may need a full threading implementation to see a significant speedup.

karmeleon avatar Aug 04 '25 20:08 karmeleon

That was my assumption as well. The extraction is CPU bound load, so there no much speedup would be in concurrent vs sequntial mode.

timofei-iatsenko avatar Aug 05 '25 06:08 timofei-iatsenko

Full multithreading support was merged to the main branch https://github.com/lingui/js-lingui/pull/2320

My test project reports a significant performance improvements.

timofei-iatsenko avatar Sep 12 '25 09:09 timofei-iatsenko

That branch cut our compile times by 90%, incredible! Thank you :)

karmeleon avatar Sep 12 '25 19:09 karmeleon