MyFaces Core
  1. MyFaces Core
  2. MYFACES-2889

[PERF] Remove String.intern() calls in FlashELResolver and ImplicitObjectResolver

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.2-SNAPSHOT
    • Fix Version/s: 1.2.11, 2.0.8, 2.1.2
    • Component/s: JSR-314
    • Labels:
      None
    • Environment:
      JBoss AS 6 M4, Parleys.com JSF2 app

      Description

      I've been doing some profiling and I see pretty much activity in FlashELResolver.castAndIntern() and ImplicitObjectResolver.castAndIntern().
      When I replace the "return s.intern()" lines by "return s", both methods have (of course) much better performance.

      But I'm pretty sure someone put them there with a reason, like memory footprint.
      However, I don't see any difference in memory footprint.

      Any ideas? Do we want to keep the intern() calls?

        Issue Links

          Activity

          Hide
          Mark Struberg added a comment -

          Hi!

          The problem with that is that you need to check all '==' comparisons because "xyz".intern() == "xyz".intern() but "xyz" != "xyz"

          intern is very usefully if something is compared really often.

          Show
          Mark Struberg added a comment - Hi! The problem with that is that you need to check all '==' comparisons because "xyz".intern() == "xyz".intern() but "xyz" != "xyz" intern is very usefully if something is compared really often.
          Hide
          Jan-Kees van Andel added a comment -

          True, but in these two cases, the (interned) Strings are only used for Map lookups. And AFAIK, interning has no effect on the performance of the hashcode method...

          Show
          Jan-Kees van Andel added a comment - True, but in these two cases, the (interned) Strings are only used for Map lookups. And AFAIK, interning has no effect on the performance of the hashcode method...
          Hide
          Mike Kienenberger added a comment -

          I am not commenting on whether intern should be used in this situation, as I don't know.

          However, for maps, if there are several items in the map which have the same hashcode, then those individual items will be compared using equality operations.

          No idea how often that would happen in this particular case.

          Show
          Mike Kienenberger added a comment - I am not commenting on whether intern should be used in this situation, as I don't know. However, for maps, if there are several items in the map which have the same hashcode, then those individual items will be compared using equality operations. No idea how often that would happen in this particular case.

            People

            • Assignee:
              Leonardo Uribe
              Reporter:
              Jan-Kees van Andel
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development