Repository navigation
perf(java): batch format all libraries using argument file - #7186
Merged
Merged
Conversation
Batch format all generated Java client libraries in a single `google-java-format` invocation using an argument file (@<filename>). This avoids per-library JVM startup overhead when formatting multiple libraries and prevents exceeding OS command-line length limits (ARG_MAX). For googleapis#6218
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the Java library formatting process to batch format multiple libraries in a single google-java-format invocation using an argument file. Feedback was provided regarding a file descriptor leak in internal/librarian/java/format.go, where the temporary file created by os.CreateTemp is not closed before writing to it via os.WriteFile or before the function returns. It is recommended to write directly to the open file descriptor and close it properly to prevent leaks and potential file-locking issues on Windows.
JoeWang1127
reviewed
Aug 4, 2026
yangyzs
marked this pull request as draft
August 5, 2026 02:11
…of 2000 Refactor java.Format to batch format files using temporary argument files (@filename) in chunks of 2,000 to avoid OS ARG_MAX limits and JVM heap exhaustion on CI. Extract createArgFile helper with unit tests.
Contributor
Author
|
In the latest change, we batched Java formatting into chunks of 2,000 files using temporary argument files (@filename).
|
JoeWang1127
reviewed
Aug 5, 2026
…f 2000 Refactor java.Format to pass file paths directly as CLI arguments in chunks of 2,000. This avoids OS ARG_MAX limits (~200 KB vs 2 MB limit) and prevents JVM heap exhaustion on CI without creating temporary argument files.
yangyzs
marked this pull request as ready for review
August 6, 2026 19:33
JoeWang1127
approved these changes
Aug 6, 2026
yangyzs
enabled auto-merge (squash)
August 6, 2026 20:15
JoeWang1127
pushed a commit
that referenced
this pull request
Aug 10, 2026
🤖 I have created a release *beep* *boop* --- ## [0.34.0](v0.33.0...v0.34.0) (2026-08-08) ### Features * **dart:** add a setup skill ([#7193](#7193)) ([d322aa0](d322aa0)) * **dart:** implement bump ([#6989](#6989)) ([5505997](5505997)) * **internal/librarian/php:** derive component name with config override in generate ([#7197](#7197)) ([557e664](557e664)), refs [#7025](#7025) * **internal/librarian/php:** derive lowercase hyphenated php library names from api path ([#7215](#7215)) ([4669112](4669112)) * **internal/librarian/php:** initialize new component before generation ([#7225](#7225)) ([b6c50b4](b6c50b4)) * **internal/librarian/ruby:** support deleting output paths after generation ([#7223](#7223)) ([609ffb7](609ffb7)), refs [#6633](#6633) * **internal/librarian/rust:** support external type conversions ([#7212](#7212)) ([5b72c52](5b72c52)), refs [#7144](#7144) * **internal/proto:** add package to gather proto files ([#7218](#7218)) ([9646f09](9646f09)), refs [#7217](#7217) * **internal/sidekick/rust:** initialize bidi streaming RPCs eagerly ([#7221](#7221)) ([cbfa368](cbfa368)), refs [#6835](#6835) * **internal/sidekick/rust:** support type-erased streaming handles ([#7229](#7229)) ([17f5a3d](17f5a3d)), refs [#6835](#6835) * **internal/sidekick/rust:** use builder pattern for bidi methods ([#7203](#7203)) ([bc90045](bc90045)), refs [#6835](#6835) * **internal/tool/composer:** use entrypoint configuration instead of package names ([#7156](#7156)) ([e33192f](e33192f)) * **sidekick/rust:** bigquery query creation metadata ([#7167](#7167)) ([d70f2a2](d70f2a2)) * **swift:** conversions support map fields ([#7222](#7222)) ([341f1e5](341f1e5)) * **swift:** protobuf conversions support oneofs ([#7205](#7205)) ([40c48df](40c48df)) * **swift:** support skipped_ids in configuration ([#7206](#7206)) ([95d3464](95d3464)) ### Bug Fixes * **internal/librarian/php:** remove version suffix from init namespace ([#7227](#7227)) ([7fb3b46](7fb3b46)) * **internal/librarian/ruby:** pass gem namespace option to generator ([#7210](#7210)) ([817146f](817146f)) * **internal/librarian/ruby:** pass service override option to generator ([#7208](#7208)) ([e9886bf](e9886bf)), refs [#6633](#6633) * **internal/librarian/ruby:** search proto recursively in API path ([#7220](#7220)) ([3d4a4a1](3d4a4a1)), refs [#7219](#7219) [#7217](#7217) * **internal/librarian/rust:** preserve parent messages of used types ([#7170](#7170)) ([e51520c](e51520c)), refs [#7143](#7143) * **internal/serviceconfig:** update config for compute ([#7200](#7200)) ([a08e565](a08e565)) * **internal/sidekick/rust:** use from for repeated enum conversions in convert-prost ([#7211](#7211)) ([ee4fb71](ee4fb71)) ### Performance Improvements * **java:** batch format all libraries using argument file ([#7186](#7186)) ([5a7775a](5a7775a)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
sofisl
pushed a commit
to sofisl/librarian
that referenced
this pull request
Aug 10, 2026
…s#7186) Batch format all generated Java client libraries in a single `google-java-format` invocation using an argument file (@<filename>). This avoids per-library JVM startup overhead when formatting multiple libraries and prevents exceeding OS command-line length limits (ARG_MAX). For googleapis#6218 --------- Signed-off-by: yangyzs <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Batch format all generated Java client libraries in a single
google-java-formatinvocation using an argument file (@).This avoids per-library JVM startup overhead when formatting multiple libraries and prevents exceeding OS command-line length limits (ARG_MAX).
For #6218