-
Notifications
You must be signed in to change notification settings - Fork 185
Introduce codec mapping caches #410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce codec mapping caches #410
Conversation
Thanks a lot for submitting a pull request. Introducing caching comes with quite some complexity. The on-demand cache registration of codecs resonates with my cautionary sense that the state of the codec registry changes over time (as the application keeps running) which can lead to some point to driver behavior that cannot be properly reproduced because of so many moving parts. I'd like much more to explore a path where we pre-populate the caches to keep a stable state on a per-connection level. With doing so, potential bugs can be caught early on as each connection enters a stable state after establishing the connection. I think to make that work, we would need to extend our codecs with some sort of interface that exposes which data types, classes and formats are supported ( |
…decoding performances. * Switched the codec list to a thread safe variant to avoid the synchronized blocks. Even though `CopyOnWriteArrayList` is not super performant it should work fine in this context where the list should not be frequently updated. * Switched `mockito-core` to `mockito-junit-jupiter` for Junit 5 support
63d7b30
to
2d79aa7
Compare
Sorry for the late reply. I will have a look at pre-filling the caches. This does imply that we don't support a codec that can encode sub-classes of the associated type. |
@mp911de I followed your recommendations and tried to implement a pre-filled cache. Note that I decided to do that in another commit instead of a fixup. Hope this is okay. |
Thanks a lot. I'm not sure about the codec finder API yet, but having each codec exposing details which data types it is able to process makes a lot of sense. Are you able to come up with some benchmarks to see whether this optimization makes sense? We have some integrative benchmarks in the |
I'll add benchmarks that compare the encode and decode using both the cache and default implementations of the codec finder. |
3cc431c
to
8ce39e3
Compare
I added some benchmarks as follow in the last commit:
I ran the same benchmark on the main branch to compare the results and they kind of match with the cache disabled codec registry benchmarks:
|
e502034
to
f885190
Compare
Wow, that's amazing, 2x up to 10x improvement in throughput. Out of curiosity, have you tried to backport the commits to the |
I originally tested this on the |
* Refactored the codec registry to use a CodecFinder (default to SPI definition in the classpath) * Provided 2 implementations of the codec finder, one without cache and another with cache * Added a build cache method that will attempt to fill the cache when the codecs are updated. This cannot covers all the cases like the nested arrays, therefore for those type the cache will be filled dynamically on per-request basis * Added microbenchmarks for codec encode and decode using the cache based implementation or not * Disabled unixDomainSocketTest IT when running on Mac or Windows
f885190
to
521217b
Compare
Thanks a lot. I'll come back to this next week. |
…rmances. * Switched the codec list to a thread safe variant to avoid the synchronized blocks. Even though `CopyOnWriteArrayList` is not super performant it should work fine in this context where the list should not be frequently updated. * Switched `mockito-core` to `mockito-junit-jupiter` for Junit 5 support * Refactored the codec registry to use a CodecFinder (default to SPI definition in the classpath) * Provided 2 implementations of the codec finder, one without cache and another with cache * Added a build cache method that will attempt to fill the cache when the codecs are updated. This cannot covers all the cases like the nested arrays, therefore for those type the cache will be filled dynamically on per-request basis * Added microbenchmarks for codec encode and decode using the cache based implementation or not * Disabled unixDomainSocketTest IT when running on Windows [#410][resolves #409]
Thank you for your contribution. That's merged and polished now. |
Thank you for accepting it. I like your version better ;) |
Thanks for having a look at the polishing commits, I'll incorporate your feedback. |
Fixes #409
Introduce codec mapping caches to improve encoding and decoding performances.
CopyOnWriteArrayList
is not super performant it should work fine in this context where the list should not be frequently updated.mockito-core
tomockito-junit-jupiter
for Junit 5 supportMake sure that:
Issue description
See gh-409
New Public APIs
Additional context