Skip to content

Commit 6d4f4cb

Browse files
keremncjenkins
authored andcommitted
util-core: avoid unnecessary unboxing in activation map
The first call to `LocalScheduler::get` registers the activation in a `Map[Activation, Boolean]` by writing a value of `java.lang.Boolean.TRUE`; this requires a boxing call which has negligible performance impact but can pollute profiles with many async dispatches. Differential Revision: https://phabricator.twitter.biz/D1209771
1 parent ef72496 commit 6d4f4cb

File tree

1 file changed

+3
-2
lines changed
  • util-core/concurrent-extra/src/main/scala/com/twitter/concurrent

1 file changed

+3
-2
lines changed

util-core/concurrent-extra/src/main/scala/com/twitter/concurrent/Scheduler.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import com.twitter.util.Awaitable.CanAwait
44
import java.util.ArrayDeque
55
import java.util.concurrent._
66
import java.util.concurrent.atomic.AtomicInteger
7-
import java.util.logging.{Level, Logger}
7+
import java.util.logging.Level
8+
import java.util.logging.Logger
89
import scala.collection.mutable
910

1011
/**
@@ -202,7 +203,7 @@ class LocalScheduler(lifo: Boolean) extends Scheduler {
202203

203204
// use weak refs to prevent Activations from causing a memory leak
204205
// thread-safety provided by synchronizing on `activations`
205-
private[this] val activations = new mutable.WeakHashMap[Activation, Boolean]()
206+
private[this] val activations = new mutable.WeakHashMap[Activation, java.lang.Boolean]()
206207

207208
private[this] val local = new ThreadLocal[Activation]()
208209

0 commit comments

Comments
 (0)