分析线程转储 - sun.misc.Unsafe.park 上的许多阻塞线程 [重复]

Posted

技术标签:

【中文标题】分析线程转储 - sun.misc.Unsafe.park 上的许多阻塞线程 [重复]【英文标题】:Analysing thread dump - lot of blocked threads on sun.misc.Unsafe.park [duplicate] 【发布时间】:2017-11-11 19:54:54 【问题描述】:

正在使用 akka 框架应用程序修复 Java 游戏中的性能问题。基本上消费和处理来自队列的消息。并在处理每条消息时大量使用外部服务 API。 我在某些情况下遇到 CPU 负载问题,试图找到根本原因。这是 CPU ~100% 时主机之一的线程转储。

我看到很多带有 sun.misc.Unsafe.park 的阻塞线程,并且没有看到任何应用程序代码信息。这些被阻塞的是否在等待 IO?你能给出一些提示吗? 谢谢

    1032 BLOCKED
threads

    Thread 34542 - threadId:Thread 34542 - state:BLOCKED
    stackTrace:
    - sun.misc.Unsafe.park(boolean, long) @bci=0 (Compiled frame; information may be imprecise)
    - java.util.concurrent.locks.LockSupport.parkNanos(java.lang.Object, long) @bci=20, line=226 (Compiled frame)
    - java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(long) @bci=68, line=2082 (Compiled frame)
    - java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take() @bci=122, line=1090 (Compiled frame)
    - java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take() @bci=1, line=807 (Compiled frame)
    - java.util.concurrent.ThreadPoolExecutor.getTask() @bci=156, line=1068 (Compiled frame)
    - java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=26, line=1130 (Compiled frame)
    - java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5, line=615 (Interpreted frame)
    - java.lang.Thread.run() @bci=11, line=745 (Interpreted frame)

362 BLOCKED
threads

    Thread 77117 - threadId:Thread 77117 - state:BLOCKED
    stackTrace:
    - sun.misc.Unsafe.park(boolean, long) @bci=0 (Compiled frame; information may be imprecise)
    - java.util.concurrent.locks.LockSupport.park(java.lang.Object) @bci=14, line=186 (Compiled frame)
    - java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await() @bci=42, line=2043 (Compiled frame)
    - java.util.concurrent.LinkedBlockingQueue.take() @bci=29, line=442 (Compiled frame)
    - java.util.concurrent.ThreadPoolExecutor.getTask() @bci=156, line=1068 (Compiled frame)
    - java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=26, line=1130 (Compiled frame)
    - java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5, line=615 (Interpreted frame)
    - java.lang.Thread.run() @bci=11, line=745 (Interpreted frame)

269 BLOCKED
threads

    Thread 37702 - threadId:Thread 37702 - state:BLOCKED
    stackTrace:
    - sun.misc.Unsafe.park(boolean, long) @bci=0 (Compiled frame; information may be imprecise)
    - scala.concurrent.forkjoin.ForkJoinPool.scan(scala.concurrent.forkjoin.ForkJoinPool$WorkQueue) @bci=525, line=2075 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinPool.runWorker(scala.concurrent.forkjoin.ForkJoinPool$WorkQueue) @bci=8, line=1979 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinWorkerThread.run() @bci=14, line=107 (Interpreted frame)

66 BLOCKED
threads

    Thread 33338 - threadId:Thread 33338 - state:BLOCKED
    stackTrace:
    - java.io.ExpiringCache.get(java.lang.String) @bci=0, line=74 (Compiled frame)
    - java.io.UnixFileSystem.canonicalize(java.lang.String) @bci=17, line=152 (Compiled frame)
    - java.io.File.getCanonicalPath() @bci=27, line=618 (Compiled frame)
    - com.azr.rocketman.render.helper.EmailconfigTemplateMethodModel.<init>(java.lang.String) @bci=27, line=50 (Compiled frame)
    - sun.reflect.GeneratedConstructorAccessor84.newInstance(java.lang.Object[]) @bci=28 (Compiled frame)
    - sun.reflect.DelegatingConstructorAccessorImpl.newInstance(java.lang.Object[]) @bci=5, line=45 (Compiled frame)
    - java.lang.reflect.Constructor.newInstance(java.lang.Object[]) @bci=79, line=526 (Compiled frame)
    - freemarker.ext.beans.BeansWrapper.newInstance(java.lang.Class, java.util.List) @bci=144, line=994 (Compiled frame)
    - freemarker.core.NewBI$ConstructorFunction.exec(java.util.List) @bci=32, line=116 (Compiled frame)
    - freemarker.core.MethodCall._eval(freemarker.core.Environment) @bci=52, line=98 (Compiled frame)
      …
    - freemarker.core.Environment.visit(freemarker.core.TemplateElement) @bci=7, line=265 (Compiled frame)
    - freemarker.core.Environment.process() @bci=31, line=243 (Compiled frame)
    - com.azr.push.renderer.processor.FreeMarkerRenderer.render(java.lang.String, freemarker.template.Configuration, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=165, line=101 (Compiled frame)
    - com.azr.push.renderer.processor.FreeMarkerRenderer.renderFromPath(java.lang.String, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=7, line=60 (Compiled frame)
    - com.azr.push.renderer.processor.FreeMarkerRenderer.renderFromPath(java.lang.String, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=4, line=30 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.renderhtmlBody(com.azr.push.pipeline.rendersend.context.RenderAndSendEmailContext, com.azr.push.renderer.data.TemplateData) @bci=23, line=146 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.process(com.azr.push.pipeline.rendersend.context.RenderAndSendEmailContext) @bci=61, line=109 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=5, line=63 (Compiled frame)
    - com.azr.push.pipeline.rendersend.RenderPipeline.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=31, line=21 (Compiled frame)
    - com.azr.push.pipeline.rendersend.RenderAndSendPipeline.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=2, line=20 (Compiled frame)
    - com.azr.push.assembler.AbstractDataAssembler.assemble(com.azr.push.pojo.wrapper.UserPayload) @bci=27, line=72 (Compiled frame)
    - com.azr.push.assembler.AssemblerActor.onReceive(java.lang.Object) @bci=39, line=30 (Compiled frame)
    - akka.actor.UntypedActor$$anonfun$receive$1.applyOrElse(java.lang.Object, scala.Function1) @bci=7, line=167 (Compiled frame)
    - akka.actor.ActorCell.receiveMessage(java.lang.Object) @bci=25, line=498 (Compiled frame)
    - akka.actor.ActorCell.invoke(akka.dispatch.Envelope) @bci=39, line=456 (Compiled frame)
    - akka.dispatch.Mailbox.processMailbox(int, long) @bci=24, line=237 (Compiled frame)
    - akka.dispatch.Mailbox.run() @bci=20, line=219 (Compiled frame)
    - akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec() @bci=4, line=385 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinTask.doExec() @bci=10, line=260 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(scala.concurrent.forkjoin.ForkJoinTask) @bci=10, line=1339 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinPool.runWorker(scala.concurrent.forkjoin.ForkJoinPool$WorkQueue) @bci=11, line=1979 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinWorkerThread.run() @bci=14, line=107 (Interpreted frame)

    64 BLOCKED
    threads

    Thread 33194 - threadId:Thread 33194 - state:BLOCKED
    stackTrace:
    - sun.misc.Unsafe.park(boolean, long) @bci=0 (Compiled frame; information may be imprecise)
    - java.util.concurrent.locks.LockSupport.parkNanos(java.lang.Object, long) @bci=20, line=226 (Compiled frame)
    - java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(long) @bci=68, line=2082 (Compiled frame)
    - java.util.concurrent.LinkedBlockingQueue.poll(long, java.util.concurrent.TimeUnit) @bci=62, line=467 (Compiled frame)
    - java.util.concurrent.ThreadPoolExecutor.getTask() @bci=141, line=1068 (Compiled frame)
    - java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=26, line=1130 (Compiled frame)
    - java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5, line=615 (Interpreted frame)
    - java.lang.Thread.run() @bci=11, line=745 (Interpreted frame)

    63 BLOCKED
    threads

    Thread 63135 - threadId:Thread 63135 - state:BLOCKED
    stackTrace:
    - sun.nio.ch.EPollArrayWrapper.epollWait(long, int, long, int) @bci=0 (Compiled frame; information may be imprecise)
    - sun.nio.ch.EPollArrayWrapper.poll(long) @bci=18, line=269 (Compiled frame)
    - sun.nio.ch.EPollSelectorImpl.doSelect(long) @bci=28, line=79 (Compiled frame)
    - sun.nio.ch.SelectorImpl.lockAndDoSelect(long) @bci=37, line=87 (Compiled frame)
    - sun.nio.ch.SelectorImpl.select(long) @bci=30, line=98 (Compiled frame)
    - org.jboss.netty.channel.socket.nio.SelectorUtil.select(java.nio.channels.Selector) @bci=4, line=68 (Compiled frame)
    - org.jboss.netty.channel.socket.nio.AbstractNioselector.select(java.nio.channels.Selector) @bci=1, line=409 (Compiled frame)
    - org.jboss.netty.channel.socket.nio.AbstractNioSelector.run() @bci=49, line=206 (Compiled frame)
    - org.jboss.netty.channel.socket.nio.AbstractNioWorker.run() @bci=1, line=90 (Interpreted frame)
    - org.jboss.netty.channel.socket.nio.NioWorker.run() @bci=1, line=178 (Interpreted frame)
    - org.jboss.netty.util.ThreadRenamingRunnable.run() @bci=55, line=108 (Interpreted frame)
    - org.jboss.netty.util.internal.DeadLockProofWorker$1.run() @bci=14, line=42 (Interpreted frame)
    - java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=95, line=1145 (Interpreted frame)
    - java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5, line=615 (Interpreted frame)
    - java.lang.Thread.run() @bci=11, line=745 (Interpreted frame)

    34 blocked threads

    Thread 33336 - threadId:Thread 33336 - state:BLOCKED
    stackTrace:
     …
    - com.azr.push.renderer.processor.FreeMarkerRenderer.render(java.lang.String, freemarker.template.Configuration, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=165, line=101 (Compiled frame)
    - com.azr.push.renderer.processor.FreeMarkerRenderer.renderFromPath(java.lang.String, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=7, line=60 (Compiled frame)
    - com.azr.push.renderer.processor.FreeMarkerRenderer.renderFromPath(java.lang.String, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=4, line=30 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.renderHtmlBody(com.azr.push.pipeline.rendersend.context.RenderAndSendEmailContext, com.azr.push.renderer.data.TemplateData) @bci=23, line=146 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.process(com.azr.push.pipeline.rendersend.context.RenderAndSendEmailContext) @bci=61, line=109 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=5, line=63 (Compiled frame)
    - com.azr.push.pipeline.rendersend.RenderPipeline.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=31, line=21 (Compiled frame)
    - com.azr.push.pipeline.rendersend.RenderAndSendPipeline.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=2, line=20 (Compiled frame)
    - com.azr.push.assembler.AbstractDataAssembler.assemble(com.azr.push.pojo.wrapper.UserPayload) @bci=27, line=72 (Compiled frame)
    - com.azr.push.assembler.AssemblerActor.onReceive(java.lang.Object) @bci=39, line=30 (Compiled frame)
    - akka.actor.UntypedActor$$anonfun$receive$1.applyOrElse(java.lang.Object, scala.Function1) @bci=7, line=167 (Compiled frame)
    - akka.actor.ActorCell.receiveMessage(java.lang.Object) @bci=25, line=498 (Compiled frame)
    - akka.actor.ActorCell.invoke(akka.dispatch.Envelope) @bci=39, line=456 (Compiled frame)
    - akka.dispatch.Mailbox.processMailbox(int, long) @bci=24, line=237 (Compiled frame)
    - akka.dispatch.Mailbox.run() @bci=20, line=219 (Compiled frame)
    - akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec() @bci=4, line=385 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinTask.doExec() @bci=10, line=260 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(scala.concurrent.forkjoin.ForkJoinTask) @bci=10, line=1339 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinPool.runWorker(scala.concurrent.forkjoin.ForkJoinPool$WorkQueue) @bci=11, line=1979 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinWorkerThread.run() @bci=14, line=107 (Interpreted frame)


    26 blocked threads
    Thread 33327 - threadId:Thread 33327 - state:BLOCKED
    stackTrace:
    - freemarker.core._RegexBuiltins.getPattern(java.lang.String, int) @bci=16, line=122 (Compiled frame)    
      …
    - freemarker.core.Environment.process() @bci=31, line=243 (Compiled frame)
    - com.azr.push.renderer.processor.FreeMarkerRenderer.render(java.lang.String, freemarker.template.Configuration, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=165, line=101 (Compiled frame)
    - com.azr.push.renderer.processor.FreeMarkerRenderer.renderFromPath(java.lang.String, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=7, line=60 (Compiled frame)
    - com.azr.push.renderer.processor.FreeMarkerRenderer.renderFromPath(java.lang.String, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=4, line=30 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.renderHtmlBody(com.azr.push.pipeline.rendersend.context.RenderAndSendEmailContext, com.azr.push.renderer.data.TemplateData) @bci=23, line=146 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.process(com.azr.push.pipeline.rendersend.context.RenderAndSendEmailContext) @bci=61, line=109 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=5, line=63 (Compiled frame)
    - com.azr.push.pipeline.rendersend.RenderPipeline.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=31, line=21 (Compiled frame)
    - com.azr.push.pipeline.rendersend.RenderAndSendPipeline.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=2, line=20 (Compiled frame)
    - com.azr.push.assembler.AbstractDataAssembler.assemble(com.azr.push.pojo.wrapper.UserPayload) @bci=27, line=72 (Compiled frame)
    - com.azr.push.assembler.AssemblerActor.onReceive(java.lang.Object) @bci=39, line=30 (Compiled frame)
    - akka.actor.UntypedActor$$anonfun$receive$1.applyOrElse(java.lang.Object, scala.Function1) @bci=7, line=167 (Compiled frame)
    - akka.actor.ActorCell.receiveMessage(java.lang.Object) @bci=25, line=498 (Compiled frame)
    - akka.actor.ActorCell.invoke(akka.dispatch.Envelope) @bci=39, line=456 (Compiled frame)
    - akka.dispatch.Mailbox.processMailbox(int, long) @bci=24, line=237 (Compiled frame)
    - akka.dispatch.Mailbox.run() @bci=20, line=219 (Compiled frame)
    - akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec() @bci=4, line=385 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinTask.doExec() @bci=10, line=260 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(scala.concurrent.forkjoin.ForkJoinTask) @bci=10, line=1339 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinPool.runWorker(scala.concurrent.forkjoin.ForkJoinPool$WorkQueue) @bci=11, line=1979 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinWorkerThread.run() @bci=14, line=107 (Interpreted frame)

    26 blocked thread

    Thread 33333 - threadId:Thread 33333 - state:BLOCKED
    stackTrace:
    - freemarker.core._RegexBuiltins.getPattern(java.lang.String, int) @bci=16, line=122 (Compiled frame)
      ..
    - com.azr.push.renderer.processor.FreeMarkerRenderer.render(java.lang.String, freemarker.template.Configuration, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=165, line=101 (Compiled frame)
    - com.azr.push.renderer.processor.FreeMarkerRenderer.renderFromPath(java.lang.String, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=7, line=60 (Compiled frame)
    - com.azr.push.renderer.processor.FreeMarkerRenderer.renderFromPath(java.lang.String, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=4, line=30 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.renderHtmlBody(com.azr.push.pipeline.rendersend.context.RenderAndSendEmailContext, com.azr.push.renderer.data.TemplateData) @bci=23, line=146 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.process(com.azr.push.pipeline.rendersend.context.RenderAndSendEmailContext) @bci=61, line=109 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=5, line=63 (Compiled frame)
    - com.azr.push.pipeline.rendersend.RenderPipeline.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=31, line=21 (Compiled frame)
    - com.azr.push.pipeline.rendersend.RenderAndSendPipeline.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=2, line=20 (Compiled frame)
    - com.azr.push.assembler.AbstractDataAssembler.assemble(com.azr.push.pojo.wrapper.UserPayload) @bci=27, line=72 (Compiled frame)
    - com.azr.push.assembler.AssemblerActor.onReceive(java.lang.Object) @bci=39, line=30 (Compiled frame)
    - akka.actor.UntypedActor$$anonfun$receive$1.applyOrElse(java.lang.Object, scala.Function1) @bci=7, line=167 (Compiled frame)
    - akka.actor.ActorCell.receiveMessage(java.lang.Object) @bci=25, line=498 (Compiled frame)
    - akka.actor.ActorCell.invoke(akka.dispatch.Envelope) @bci=39, line=456 (Compiled frame)
    - akka.dispatch.Mailbox.processMailbox(int, long) @bci=24, line=237 (Compiled frame)
    - akka.dispatch.Mailbox.run() @bci=20, line=219 (Compiled frame)
    - akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec() @bci=4, line=385 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinTask.doExec() @bci=10, line=260 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(scala.concurrent.forkjoin.ForkJoinTask) @bci=10, line=1339 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinPool.runWorker(scala.concurrent.forkjoin.ForkJoinPool$WorkQueue) @bci=11, line=1979 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinWorkerThread.run() @bci=14, line=107 (Interpreted frame)

    25 blocked threads

    Thread 33323 - threadId:Thread 33323 - state:BLOCKED
    stackTrace:
    - freemarker.core._RegexBuiltins.getPattern(java.lang.String, int) @bci=16, line=122 (Compiled frame)
      …
    - freemarker.core.Environment.visit(freemarker.core.TemplateElement) @bci=7, line=265 (Compiled frame)
    - freemarker.core.Environment.process() @bci=31, line=243 (Compiled frame)
    - com.azr.push.renderer.processor.FreeMarkerRenderer.render(java.lang.String, freemarker.template.Configuration, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=165, line=101 (Compiled frame)
    - com.azr.push.renderer.processor.FreeMarkerRenderer.renderFromPath(java.lang.String, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=7, line=60 (Compiled frame)
    - com.azr.push.renderer.processor.FreeMarkerRenderer.renderFromPath(java.lang.String, com.azr.push.renderer.data.TemplateData, com.azr.push.error.MessageError) @bci=4, line=30 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.renderHtmlBody(com.azr.push.pipeline.rendersend.context.RenderAndSendEmailContext, com.azr.push.renderer.data.TemplateData) @bci=23, line=146 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.process(com.azr.push.pipeline.rendersend.context.RenderAndSendEmailContext) @bci=61, line=109 (Compiled frame)
    - com.azr.push.pipeline.rendersend.component.email.RenderEmailComponent.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=5, line=63 (Compiled frame)
    - com.azr.push.pipeline.rendersend.RenderPipeline.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=31, line=21 (Compiled frame)
    - com.azr.push.pipeline.rendersend.RenderAndSendPipeline.process(com.azr.push.pipeline.rendersend.context.RenderAndSendContext) @bci=2, line=20 (Compiled frame)
    - com.azr.push.assembler.AbstractDataAssembler.assemble(com.azr.push.pojo.wrapper.UserPayload) @bci=27, line=72 (Compiled frame)
    - com.azr.push.assembler.AssemblerActor.onReceive(java.lang.Object) @bci=39, line=30 (Compiled frame)
    - akka.actor.UntypedActor$$anonfun$receive$1.applyOrElse(java.lang.Object, scala.Function1) @bci=7, line=167 (Compiled frame)
    - akka.actor.ActorCell.receiveMessage(java.lang.Object) @bci=25, line=498 (Compiled frame)
    - akka.actor.ActorCell.invoke(akka.dispatch.Envelope) @bci=39, line=456 (Compiled frame)
    - akka.dispatch.Mailbox.processMailbox(int, long) @bci=24, line=237 (Compiled frame)
    - akka.dispatch.Mailbox.run() @bci=20, line=219 (Compiled frame)
    - akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec() @bci=4, line=385 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinTask.doExec() @bci=10, line=260 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(scala.concurrent.forkjoin.ForkJoinTask) @bci=10, line=1339 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinPool.runWorker(scala.concurrent.forkjoin.ForkJoinPool$WorkQueue) @bci=11, line=1979 (Compiled frame)
    - scala.concurrent.forkjoin.ForkJoinWorkerThread.run() @bci=14, line=107 (Interpreted frame)

【问题讨论】:

你只有 1 个线程我可以肯定地说等待 IO:epoll 的线程。其他等待队列中的新元素出现,一些 FJP 线程等待新工作出现。 _RegexBuiltins.getPattern 很可能在 synchronized 中被阻止。除非系统中有太多(>500 个,具体取决于)线程,否则应该不是问题。 看起来可疑的线程是:`Thread 33338` - ExpiringCache.get(),以及所有的freemarker.core._RegexBuiltins.getPattern(。我建议您将 2 个线程转储相隔 30 秒,以消除它没有完全阻塞。 设置可能需要做很多工作,但您可以尝试设置 Kamon 并使用它的跟踪来准确了解代码的哪些部分导致了锁定:通常在洞察力方面更有帮助那种 JMX 风格的东西 【参考方案1】:

sun.misc.Unsafe.park(...)Thread.wait基本一样,只是使用了os代码,所以不会暴露给我们。

您可以在堆栈跟踪中看到,被停放的线程来自与阻塞队列相关的线程池。来自池的“停放”的线程只是在等待分配任务。此外,它们确实消耗 0% 的 CPU,所以我怀疑这是您的问题。

您可能会遇到死锁或并发问题,因此您的队列会永远阻塞自己...

此外,其中唯一提到 I/O 的线程是 ID 为 63135 的线程。

【讨论】:

以上是关于分析线程转储 - sun.misc.Unsafe.park 上的许多阻塞线程 [重复]的主要内容,如果未能解决你的问题,请参考以下文章

线程处于 WAITING 状态:java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method)

sun.misc.Unsafed的API说明

如何获取 sun.misc.Unsafe 的实例?

sun.misc.Unsafe 记录在哪里? [关闭]

找不到方法 sun.misc.Unsafe.defineClass

sun.misc.Unsafe中一些常用方法记录