From 430eeee2f62ce0415cbeec14ffd94517e60805ca Mon Sep 17 00:00:00 2001 From: Alex Blewitt Date: Sat, 22 Jun 2019 06:21:51 +0100 Subject: [PATCH] Return the result of the list.recycle() call (#9264) Motivation: Resolve the issue highlighted by SpotJMHBugs that the creation of the RecyclableArrayList may be elided by the JIT since the result isn't consumed or returned. Modifications: Return the result of `list.recycle()` so that the list isn't elided. Result: The JMH benchmark shows a change in performance indicating that the prior results of this may be unsound. --- .../microbench/internal/RecyclableArrayListBenchmark.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microbench/src/main/java/io/netty/microbench/internal/RecyclableArrayListBenchmark.java b/microbench/src/main/java/io/netty/microbench/internal/RecyclableArrayListBenchmark.java index dfb95a6796..32fe2bbeeb 100644 --- a/microbench/src/main/java/io/netty/microbench/internal/RecyclableArrayListBenchmark.java +++ b/microbench/src/main/java/io/netty/microbench/internal/RecyclableArrayListBenchmark.java @@ -36,8 +36,8 @@ public class RecyclableArrayListBenchmark extends AbstractMicrobenchmark { public int size; @Benchmark - public void recycleSameThread() { + public boolean recycleSameThread() { RecyclableArrayList list = RecyclableArrayList.newInstance(size); - list.recycle(); + return list.recycle(); } }