mosche opened a new pull request, #27534: URL: https://github.com/apache/beam/pull/27534
The conversion of rows to the external object is rather inefficient. The code to convert Row fields to the external field types required for the constructor / setters in `FromRowUsingCreator` is branch heavy and rather hard to optimize for Java's JIT compiler. ### Functional observations: Maps and Collections / Lists are currently handled inconsistently: - Maps are eagerly rewritten / copied, making their usage rather expensive. The user object will contain fully operable maps. - Collections / Lists are converted using Guava views (e.g. `Lists.transform`). The user object will contain collections that can mostly just be read from, THOUGH it's possible to remove items from the underlying collection potentially causing issues. ### Changes in this PR: - On first usage, generate a converter function for every field based on schema & type information. No more branching required when applying the function. This way the code is also better JIT optimizable. - [TBD] Depending on types a conversion might not be required at all, in this case the conversion is skipped using an identity converter, e.g. this is the case for a map of primitive types. Though, passing references of maps / collections could potentially cause issues in certain situations (but this is already a given, see above). ### Benchmark results  Historic benchmarks for `GetterBasedSchemaProvider` are available here (master branch only): https://s.apache.org/beam-community-metrics/d/kllfR2vVk/java-jmh-benchmarks?orgId=1 Closes #27533 ------------------------ Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily: - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead. - [ ] Update `CHANGES.md` with noteworthy changes. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/get-started-contributing/#make-the-reviewers-job-easier). To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md) GitHub Actions Tests Status (on master branch) ------------------------------------------------------------------------------------------------ [](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule) [](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule) [](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule) [](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule) See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
