Closed tonistiigi closed 6 days ago
Some things that I looked at but did not fix:
Image
happens for every base image.HasPrefix
was enough but there are still cases like https://github.com/moby/buildkit/blob/v0.14.1/frontend/dockerfile/parser/parser.go#L514-L517 that look far for optimal for the use case.
This adds many updates to reduce memory allocations in Dockerfile frontend when dealing with huge inputs, improving performance and reducing GC pressure for other component.
Most of the issues are in dockerfile parser code and have been there forever (pre-buildkit). There was issue with excessive env reads in variable expansion as well. I also switched the
llb.Env()
datatype although performance impact of that was not very significant and it should be considered more as a cleanup of unneeded conversions. CSV parsers have also been switched as we used them for parsing small single-line values while stdlib parser is optimized for big documents.Profile of allocations with giant Dockerfile from https://github.com/moby/buildkit/issues/4948 (5x)
Before:
After:
There are many unrelated updates in here so definitely review per-commit. I can also start to split it to more reasonable smaller PRs. I did it all together as only then the profiler result is reasonable.