Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-1357

Use shared DefaultConversionService in ProxyProjectionFactory and ResultProcessor

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 2.0.8 (Kay SR8)
    • Component/s: Core
    • Labels:
      None

      Description

      Just an observation, might be worth reviewing. When looking at the startup of Petclinic, there are 17 calls to addDefaultConverters(). There are no calls to convert anything at startup - although obviously that can change if supplying some properties that need it (but even then not all 17 initialized converters are used). Here is a log of invocations of addDefaultConverters() and other methods on the conversion service ( removeConvertible )

      3756abf2:DCS: DefaultConversionService.addDefaultConverters() called
      3b22cdd0:DCS: DefaultConversionService.addDefaultConverters() called
      34f7cfd9:DCS: DefaultConversionService.addDefaultConverters() called
      7582ff54:DCS: DefaultConversionService.addDefaultConverters() called
      6c2c1385:DCS: DefaultConversionService.addDefaultConverters() called
      6c2c1385:DCS: removeConvertible(C sourceType,C targetType) called
      4b23c30a:DCS: DefaultConversionService.addDefaultConverters() called
      38089a5a:DCS: DefaultConversionService.addDefaultConverters() called
      38089a5a:DCS: removeConvertible(C sourceType,C targetType) called
      32c4e8b2:DCS: DefaultConversionService.addDefaultConverters() called
      77102b91:DCS: DefaultConversionService.addDefaultConverters() called
      7749bf93:DCS: DefaultConversionService.addDefaultConverters() called
      13330ac6:DCS: DefaultConversionService.addDefaultConverters() called
      13330ac6:DCS: removeConvertible(C sourceType,C targetType) called
      39a2bb97:DCS: DefaultConversionService.addDefaultConverters() called
      21fd5faa:DCS: DefaultConversionService.addDefaultConverters() called
      2766ca9d:DCS: DefaultConversionService.addDefaultConverters() called
      2766ca9d:DCS: removeConvertible(C sourceType,C targetType) called
      2e6a5539:DCS: DefaultConversionService.addDefaultConverters() called
      4d9ac0b4:DCS: DefaultConversionService.addDefaultConverters() called
      1852a3ff:DCS: DefaultConversionService.addDefaultConverters() called 
       

      For a bit more context I'll attach a text log of who is making those calls. A crude attempt to make everything lazy (i.e. only add the default ones when doing something that needs them, like a conversion or removing a converter) resulted in very small CPU gains, but I haven't measured memory impact from creating all these objects we don't use (may never use).

      My measurements also included small changes to some of the addConverter calls such that when registering converters with obvious types, pass those types rather than relying on the runtime reification of generics to dig that information out.

      As Juergen eluded to in another issue, an alternative to lazy is increase/promote the sharing of these. So initialize fewer overall. As I say, speed numbers don't suggest a big win but haven't measured memory. Related to this is the DefaultFormattingConversionService in boot.

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mp911de Mark Paluch
                Reporter:
                aclement Andy Clement
                Last updater:
                Mark Paluch
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: