GithubHelp home page GithubHelp logo

Comments (10)

jrudolph avatar jrudolph commented on July 26, 2024

In this particular case it seems to be a "sibling" method that is actually doing the allocations:

Counter: 9428816 (97.81%)
  [ 0] [Ljava/lang/Object;
  [ 1] akka.http.scaladsl.model.Uri$.create
  [ 2] akka.http.impl.model.parser.UriParser.parseHttpRequestTarget
  [ 3] akka.http.scaladsl.model.Uri$.parseHttpRequestTarget
  [ 4] akka.http.impl.engine.parsing.HttpRequestParser$$anon$1.parseRequestTarget
  [ 5] akka.http.impl.engine.parsing.HttpRequestParser$$anon$1.parseMessage
  [ 6] akka.http.impl.engine.parsing.HttpMessageParser$class.startNewMessage
  [ 7] akka.http.impl.engine.parsing.HttpRequestParser$$anon$1.startNewMessage
  [ 8] akka.http.impl.engine.parsing.HttpMessageParser$$anonfun$startNewMessage$1.apply

Using VisualVM I found out that it's not create but another call chain starting from UriParser.parseHttpRequestTarget which is actually doing the allocations.

from async-profiler.

apangin avatar apangin commented on July 26, 2024

This might be a bug of AsyncGetCallTrace. Does -XX:+DebugNonSafepoints make it better?
Do you have a small reproducer that you can share?

from async-profiler.

retronym avatar retronym commented on July 26, 2024

I've also run into seemingly impossible stack traces when CPU profiling the Scala compiler with flight recorder or async-profiler. For a while, I thought I was going crazy! It's comforting to know that the flaw might be elsewhere.

I've just trawled some open bugs on AsyncGetCallTrace. JDK-8022893 is a good one with a reproduction and has analysis of the root cause in the comments. It is plausibly the same problem as reported here.

from async-profiler.

jrudolph avatar jrudolph commented on July 26, 2024

@apangin in my case with -XX:+DebugNonSafepoints it is missing intermediate frames:

  [ 0] [Ljava/lang/Object;
  [ 1] akka.http.impl.engine.parsing.HttpRequestParser$$anon$1.parseRequestTarget
  [ 2] akka.http.impl.engine.parsing.HttpRequestParser$$anon$1.parseMessage
  [ 3] akka.http.impl.engine.parsing.HttpMessageParser$class.startNewMessage
  [ 4] akka.http.impl.engine.parsing.HttpRequestParser$$anon$1.startNewMessage
  [ 5] akka.http.impl.engine.parsing.HttpMessageParser$$anonfun$startNewMessage$1.apply
  [ 6] akka.http.impl.engine.parsing.HttpMessageParser$$anonfun$startNewMessage$1.apply
  [ 7] akka.http.impl.engine.parsing.HttpMessageParser$$anonfun$continue$2.apply
  [ 8] akka.http.impl.engine.parsing.HttpMessageParser$$anonfun$continue$2.apply
  [ 9] akka.http.impl.engine.parsing.HttpMessageParser$class.run$1

while it should have three more frames on top of HttpRequestParser$$anon$1.parseRequestTarget.

I don't have a small reproducer right now, I guess I could build a bigger one sharing a ~30MB jar file and instructions.

from async-profiler.

apangin avatar apangin commented on July 26, 2024

OK, looks like I can reproduce the problem. Will investigate this.

from async-profiler.

apangin avatar apangin commented on July 26, 2024

After some investigation I can confirm that it is AsyncGetCallTraces that works wrong.
If I replace AGCT with the standard JVM TI GetStackTrace call, everything looks good. Fortunately, it is safe to do so for allocation profiler (but not for CPU profiler).

I think the right fix would be to check if current thread has _last_Java_sp set, and, if yes, call JVM TI GetStackTrace(), otherwise call AsyncGetCallTrace.

from async-profiler.

jrudolph avatar jrudolph commented on July 26, 2024

Might make sense to compare results with the output generated by grav: https://epickrram.blogspot.de/2017/09/heap-allocation-flamegraphs.html

from async-profiler.

apangin avatar apangin commented on July 26, 2024

Re-implemented Java stack traces with JVM TI for allocation profiling. This is going to be accurate now.

from async-profiler.

apangin avatar apangin commented on July 26, 2024

Unfortunately, calling JVM TI from VM context may sometimes trigger assertion in VM code (#64), so reverted back to AsyncGetCallTrace for now. Better inaccurate than unsafe.
Will fix that properly in #66.

from async-profiler.

apangin avatar apangin commented on July 26, 2024

Re-implemented allocation stack walking once again. Now the stacks should be accurate without a risk of internal JVM deadlocks or assertion failures.

from async-profiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.