How to analyze stack trace info of a thread?
Asked Answered
B

1

0

I'm trying to monitor performance of my app;

When cpu usage overloads, I dump the stack trace of the suspicious thread and main thread as string by two libs: https://github.com/bestswifter/BSBacktraceLogger https://github.com/plausiblelabs/plcrashreporter

Following are the stack trace of one thread that I record, but it cannot help me analyze and locate where the performance issue is.

Am I doing wrong or how can I analyze the stack trace of a thread?

Burgwell answered 2/11, 2017 at 9:4 Comment(5)
Have you tried Instruments ?developer.apple.com/library/content/documentation/… . Apple's guide is very much informative and probably can fix your problem too.Skateboard
@YashBedi, yes; But instrument cannot help live app; So I monitor CPU/GPU/Memory and dump stack trace programmaticallyBurgwell
Both those stacks are for the main thread. And at the point of capture it is waiting to handle the next item in the runloop.Manse
@YashBedi Yes; Any suggestion on next step? I already can monitor which thread is eating cpu/gpu/memory, but next step I need to find out why it's using so much, my thought is by capturing backtrace of the suspicious thread, then analyze it, but seems my above backtrace in screenshots cannot help me locate issueBurgwell
yeah you're not getting the info for that suspicious thread..Skateboard
S
0

Ohkay ! I somewhat got your problem. What is your app about,? I mean is it a Game or something.? With this very info, I'll give you few workarounds,

  • I would suggest you to thoroughly study the code and de-initialize all the resources which are not being used.
  • Check for how many static properties and global variables/properties you’re using and ask yourself are they even required ?
  • Also I would again suggest you to monitor your app with Instruments look very precisely when the memory bar is going high and when low [e.g. by opening what ViewController it eats up a lot, by closing what ViewController the memory bar goes down, is your app dependent on GPS coz in big applications like uber they do not update locations on didUpdateLocations rather they use other methods, like singletons / Timer / heartbeats etc,]
  • Plus if you wanna avoid all this manual work, go for NewRelic

A small tutorial for that : link

Post again for more, Would be happy to help. =)


Here are some links : by using and combining them with firebase you'll be able to see events and logs as well, here's 1st -> watchdog

here's the 2nd 1 -> Prints the filename, function name, line number and textual..etc..

Now combine any of that with firebase and it'll send the logs to you directly.

Skateboard answered 6/11, 2017 at 5:52 Comment(5)
Thx so much man; My app is a news app, DAU about 1million; But again, I need to clarify that our developers already use instrument when debugging; But now what we want to monitor is live app's performance on users' phone, which cannot use instrument.....So I'm trying to get backtrace of all threads programmaticallyBurgwell
your welcome, buddy.! Try newRelic in that case it'll solve the problem.Skateboard
In fact for now, I can already monitor app's performance programmatically; But I need to locate the performance issue and solve it, do you know about any other good iOS libs that can get the stack trace?Burgwell
cocoawithlove.com/blog/2016/02/28/stack-traces-in-swift.html if the this will not work, read the updated answerSkateboard
Thx so much man, will checking your suggestions and keep you updated.Burgwell

© 2022 - 2024 — McMap. All rights reserved.