Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17558

Use Netty's optimized UTF-8 encoding if available

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 5.1.4
    • Component/s: Core, Reactive
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      CharSequenceEncoder uses CharBuffer.wrap and charset.encode to encode String data to its binary representation. There can be two optimizations made here:

      1. CharSequenceEncoder uses typically UTF-8 encoding and Java's UTF-8 encoder requires significant computing time. It would make sense to detect this case and whether netty is on the class path to use netty's optimized UTF-8 encoding via ByteBufUtil.writeUtf8(…)
      2. Encoding creates a new unpooled ByteBuffer when calling Charset.encode. Netty's ByteBufUtil.encodeString() can encode a String to a pooled buffer that reduces GC pressure.

      See also attached profiling snapshot.

        Attachments

          Activity

            People

            Assignee:
            bclozel Brian Clozel
            Reporter:
            mp911de Mark Paluch
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              3 years, 19 weeks, 4 days ago