Slow workspace initialization and manifest loading from a GUI app

Hi, I imported spm as a library to build a tool using the manager and noticed that it takes about 6s to initialize a workspace and about 17s to load package manifest from the GUI app I figured out, that workspace loading is longer when initializing ManifestLoader. Does anyone has tips on improving the performance? (I probably may build an underlying CLI for my GUI app to interact with the SPM library, but I'd like to find out a way to interact with spm code directly, instead of dealing with multiprocess communication of my tools)

1 Like

I tried to launch the CLI from the GUI app, but it's as slow as using spmlib code directly. Actually, I'm trying to list packages in the specified folder and it's subfolders. I create a Workspace for reach Package.swift I find and I reduced workspace initialization time by initializing UserToolchain befrore I iterate through folders and I reuse the same toolchain for each workspace, but manifest loading is still too long, the main bottleneck seems to be PackageLoading/ManifestLoader.swift:244 (self.parseAndCacheManifest(...))

Seems like launching the same code from an XPC service works much faster. Iā€™m partially happy with the solution for now, but the issue in general is pretty weird nonetheless :new_moon_with_face:

Well, XPC has it's own limitations. I used to return result as a sequence of published (via Combine) events, so that I could return found packages as soon as I find them, but XPC forces me to use an array of results (also I can't use shared models, because the inteface of the service should be an objc protocol) so the problem is still relevant and I'm not happy with the XPC solution :clown_face: