Repository navigation
Generate mappers ahead of time instead of mapping with reflection - #227
Merged
Merged
Conversation
The GeneratedMapperExtension registers a mapper factory which loads mappers generated by the GeneratedMapperWarmer. Classes without generated code, or whose fingerprint changed since the warmup, are mapped with reflection. This is the generator of #219 moved onto the mapper core. Nested objects are mapped with the chain the hydrator built for the nested class, so they are also handled right away when middlewares or a lazy proxy run for that class. If the chain is a generated mapper, its nested entry point is called, which skips the checks the parent mapper already did. The resolver and Direction are not needed anymore.
|
Hello 👋 here is the most recent benchmark result:
This comment gets update everytime a new commit comes in! |
DanielBadura
approved these changes
Oct 16, 2026
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.
This brings the generator from #219 onto the mapper core of #226 and replaces #219. It is based on #226, so the diff only contains the generator.
The
GeneratedMapperExtensionregisters aMapperFactorywhich loads the mappers theGeneratedMapperWarmergenerated ahead of time. Classes without generated code, or whose fingerprint changed since the warmup, are still mapped with reflection. The runtime never loads the generator, an architecture test makes sure of that.The resolver,
Directionanddirect()are gone. A generated mapper asks the hydrator for the chain of a nested class and calls it right away, so nested objects skip the normalizer and the hydrator even when middlewares or a lazy proxy run for the nested class. If the chain is a generated mapper, its nested entry point is called, which skips the checks the parent mapper already did. Other chains are wrapped once in a small adapter, so the generated code has no extra branch per nested object.Compared to #219, hydrating the benchmark event with three nested objects is as fast without middlewares, about 25% faster with the cryptography extension and about 60% faster with a middleware which runs for every class.
The mutation score on the diff is at 81% for now, below the 90% CI wants. #219 failed that check as well, I'll follow up on the generator tests.