Uploaded image for project: 'jclouds'
  1. jclouds
  2. JCLOUDS-302

Prevent unnecessary HttpMessage String generation in HTTPUtils

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 1.6.2, 1.7.0
    • 1.6.3, 1.7.0
    • jclouds-core
    • None

    Description

      HttpUtils.checkRequestHasRequiredProperties() has a number of Preconditions checks that generate an error string using concatenation. In particular, the HttpMessage being checked is added to the error string multiple times and this invokes the HttpMessage.toString() function. This generated String is promptly thrown away in the majority of cases where the Preconditions checks are not triggered.

      This wasted work shows up as a hotspot in my microbenchmark profiling in terms of object allocation (8% of total allocations). While fixing it by switching to using the String format version of the Preconditions API does lead to a measurable improvement, the improvement is small. However, this is a low risk change to make and I will therefore push a patch for review.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ntolia Niraj Tolia
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: