netty5/common/src/main/java/io/netty/util
Nick Hill a258cd6f42 Optimize Hpack and AsciiString hashcode and equals (#8902)
Motivation:

While looking at hpack header-processing hotspots I noticed some low
level too-big-to-inline methods which can be shrunk.

Modifications:

Reduce bytecode size and/or runtime operations used for the following
methods:

PlatformDependent0.equals(byte[], ...)
PlatformDependent0.equalsConstantTime(byte[], ...)
PlatformDependent0.hashCodeAscii(byte[],int,int)
PlatformDependent.hashCodeAscii(CharSequence)

Result:

Existing benchmarks show decent improvement

Before

Benchmark                     (size)   Mode  Cnt         Score         Error  Units
HpackUtilBenchmark.newEquals   SMALL  thrpt    5  17200229.374 ± 1701239.198  ops/s
HpackUtilBenchmark.newEquals  MEDIUM  thrpt    5   3386061.629 ±   72264.685  ops/s
HpackUtilBenchmark.newEquals   LARGE  thrpt    5    507579.209 ±   65883.951  ops/s

After

Benchmark                     (size)   Mode  Cnt         Score         Error  Units
HpackUtilBenchmark.newEquals   SMALL  thrpt    5  29221527.058 ± 4805825.836  ops/s
HpackUtilBenchmark.newEquals  MEDIUM  thrpt    5   6556251.645 ±  466115.199  ops/s
HpackUtilBenchmark.newEquals   LARGE  thrpt    5    879828.889 ±  148136.641  ops/s

Before

Benchmark                          (size)  Mode  Cnt     Score     Error  Units
PlatformDepBench.unsafeBytesEqual       4  avgt   10     4.263 ±   0.110  ns/op
PlatformDepBench.unsafeBytesEqual      10  avgt   10     5.206 ±   0.133  ns/op
PlatformDepBench.unsafeBytesEqual      50  avgt   10     8.160 ±   0.320  ns/op
PlatformDepBench.unsafeBytesEqual     100  avgt   10    13.810 ±   0.751  ns/op
PlatformDepBench.unsafeBytesEqual    1000  avgt   10    89.077 ±   7.275  ns/op
PlatformDepBench.unsafeBytesEqual   10000  avgt   10   773.940 ±  24.579  ns/op
PlatformDepBench.unsafeBytesEqual  100000  avgt   10  7546.807 ± 110.395  ns/op

After

Benchmark                          (size)  Mode  Cnt     Score     Error  Units
PlatformDepBench.unsafeBytesEqual       4  avgt   10     3.337 ±   0.087  ns/op
PlatformDepBench.unsafeBytesEqual      10  avgt   10     4.286 ±   0.194  ns/op
PlatformDepBench.unsafeBytesEqual      50  avgt   10     7.817 ±   0.123  ns/op
PlatformDepBench.unsafeBytesEqual     100  avgt   10    11.260 ±   0.412  ns/op
PlatformDepBench.unsafeBytesEqual    1000  avgt   10    84.255 ±   2.596  ns/op
PlatformDepBench.unsafeBytesEqual   10000  avgt   10   591.892 ±   5.136  ns/op
PlatformDepBench.unsafeBytesEqual  100000  avgt   10  6978.859 ± 285.043  ns/op
2019-03-08 06:55:32 +01:00
..
concurrent Tighten up contract of PromiseCombiner and so make it more safe to use (#8886) 2019-02-28 20:39:37 +01:00
internal Optimize Hpack and AsciiString hashcode and equals (#8902) 2019-03-08 06:55:32 +01:00
AbstractConstant.java Improvement: simplified AbstractConstant compareTo. 2016-08-03 09:53:49 +02:00
AbstractReferenceCounted.java Harden ref-counting concurrency semantics (#8583) 2018-11-29 08:32:50 +01:00
AsciiString.java migrate java8: use requireNonNull (#8840) 2019-02-04 10:32:25 +01:00
AsyncMapping.java Allow to do async mappings in the SniHandler 2016-01-18 21:02:13 +01:00
Attribute.java [#4351] Add warnings for Attribute.remove() and Attribute.getAndRemove() 2016-07-29 15:12:36 +02:00
AttributeKey.java Java 8 migration: Use diamond operator (#8749) 2019-01-22 16:07:26 +01:00
AttributeMap.java Better implementation of AttributeMap and also add hasAttr(...). See [#2439] 2014-05-15 06:47:42 +02:00
BooleanSupplier.java migrate java8: use lambda and method reference (#8781) 2019-01-29 14:06:05 +01:00
ByteProcessor.java migrate java8: use lambda and method reference (#8781) 2019-01-29 14:06:05 +01:00
ByteProcessorUtils.java HttpResponseStatus object allocation reduction 2018-01-24 22:01:52 -08:00
CharsetUtil.java migrate java8: use requireNonNull (#8840) 2019-02-04 10:32:25 +01:00
Constant.java Replace UniqueName with Constant and ConstantPool 2014-02-13 15:14:34 -08:00
ConstantPool.java migrate java8: use requireNonNull (#8840) 2019-02-04 10:32:25 +01:00
DefaultAttributeMap.java migrate java8: use requireNonNull (#8840) 2019-02-04 10:32:25 +01:00
DomainMappingBuilder.java Java 8 migration: Use diamond operator (#8749) 2019-01-22 16:07:26 +01:00
DomainNameMapping.java migrate java8: use requireNonNull (#8840) 2019-02-04 10:32:25 +01:00
DomainNameMappingBuilder.java migrate java8: use requireNonNull (#8840) 2019-02-04 10:32:25 +01:00
HashedWheelTimer.java migrate java8: use requireNonNull (#8840) 2019-02-04 10:32:25 +01:00
HashingStrategy.java Fix minor spelling issues in javadocs (#8701) 2019-01-14 07:25:13 +01:00
IllegalReferenceCountException.java ReferenceCountException -> IllegalReferenceCountException 2013-06-13 14:00:15 +09:00
IntSupplier.java Allow to customize NIO (channel) select strategies. 2016-03-30 15:01:25 -07:00
Mapping.java Overall clean-up of the initial SniHandler/DomainNameMapping work 2014-12-04 18:23:07 +09:00
NettyRuntime.java Enable configuring available processors 2017-04-23 10:31:17 +02:00
NetUtil.java migrate java8: use lambda and method reference (#8781) 2019-01-29 14:06:05 +01:00
package-info.java Remove apiviz tags - we are focusing on user guide instead and putting diagrams there 2013-02-14 12:09:16 -08:00
Recycler.java migrate java8: use lambda and method reference (#8781) 2019-01-29 14:06:05 +01:00
ReferenceCounted.java fix the typos 2017-04-20 04:56:09 +02:00
ReferenceCountUtil.java Motivation: Resource Leak Detector (RLD) tries to helpfully indicate where an object was last accessed and report the accesses in the case the object was not cleaned up. It handles lightly used objects well, but drops all but the last few accesses. 2017-10-19 12:21:21 -07:00
ResourceLeak.java Fix false-positives when using ResourceLeakDetector. 2016-12-04 09:01:39 +01:00
ResourceLeakDetector.java Legacy properties removed (#8839) 2019-02-04 13:56:15 +01:00
ResourceLeakDetectorFactory.java migrate java8: use requireNonNull (#8840) 2019-02-04 10:32:25 +01:00
ResourceLeakException.java Ensure backward compatibility 2013-12-05 01:02:38 +09:00
ResourceLeakHint.java Enable a user specify an arbitrary information with ReferenceCounted.touch() 2014-02-13 18:16:25 -08:00
ResourceLeakTracker.java Fix false-positives when using ResourceLeakDetector. 2016-12-04 09:01:39 +01:00
Signal.java Fix a bug where AbstractConstant.compareTo() returns 0 for different constants 2014-07-29 15:01:47 -07:00
SuppressForbidden.java Enable configuring available processors 2017-04-23 10:31:17 +02:00
ThreadDeathWatcher.java migrate java8: use requireNonNull (#8840) 2019-02-04 10:32:25 +01:00
Timeout.java Simpler method naming in Timeout 2012-12-26 13:50:01 +09:00
Timer.java Added optional pending timeouts counter parameter to HashedWheelTimer constructor and ensured that pending timeouts don't exceed provided max pending timeouts. 2016-11-09 10:58:35 +01:00
TimerTask.java Update license headers 2012-06-04 13:31:44 -07:00
UncheckedBooleanSupplier.java migrate java8: use lambda and method reference (#8781) 2019-01-29 14:06:05 +01:00
Version.java Java 8 migration: Use diamond operator (#8749) 2019-01-22 16:07:26 +01:00