Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a long-standing issue that I finally had to tackle because due to our increasingly complex pipelines it had become impossible to execute our code without throwing a huge amount of memory at it.
The problem was that when parsing a XProc step declaration, every single import would result in parsing that file plus all imports of that file, leading to the same files possibly being parsed multiple times. And when you, like us, work with libraries that collect a lot of steps that in turn depend on other libraries, you are soon dealing with tens of thousands of files being parsed. This results in a huge memory consumption before the execution of the pipeline has even started.
Actually I'm a bit surprised that no one else has noticed the issue before. Nevertheless I think my fix will be interesting for others too.
In the end the solution that I came up with is pretty simple: I cache the PipelineLibrary objects. But in order to be able to do this I had to move some things around. I hope you like it.