bombela / backward-cpp

A beautiful stack trace pretty printer for C++
MIT License
3.66k stars 466 forks source link

Load stack trace into user-provided storage #318

Open drew-gross opened 8 months ago

drew-gross commented 8 months ago

Current, backward loads a stack trace into a std::vector that is resized inside load_here.

I'm working on optimizing some of our code involving stack traces and I'd like to be able to eliminate this allocation, by providing pre-allocated memory of my own (most likely stack memory, but also potentially heap memory allocated from a pool). What do you think it would take to refactor the code to allow this? Any suggestions for how to go about it, or any potential pitfalls?

bombela commented 8 months ago

Damn this is tough. This vector is pretty well rooted in there. I don't have any smart idea at the moment. I will try to think of something.

On Thu, Oct 19, 2023, 19:21 Drew @.***> wrote:

Current, backward loads a stack trace into a std::vector https://github.com/bombela/backward-cpp/blob/65a769ffe77cf9d759d801bc792ac56af8e911a3/backward.hpp#L800 that is resized inside load_here https://github.com/bombela/backward-cpp/blob/65a769ffe77cf9d759d801bc792ac56af8e911a3/backward.hpp#L878-L880 .

I'm working on optimizing some of our code involving stack traces and I'd like to be able to eliminate this allocation, by providing pre-allocated memory of my own (most likely stack memory, but also potentially heap memory allocated from a pool). What do you think it would take to refactor the code to allow this? Any suggestions for how to go about it, or any potential pitfalls?

— Reply to this email directly, view it on GitHub https://github.com/bombela/backward-cpp/issues/318, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABUZDCRNBHTC6BME63ZSD3YAHNZVAVCNFSM6AAAAAA6IFAD3CVHI2DSMVQWIX3LMV43ASLTON2WKOZRHE2TGMZXGQYTCNY . You are receiving this because you are subscribed to this thread.Message ID: @.***>