Skip to content

Conversation

@benaitcheson
Copy link
Contributor

@benaitcheson benaitcheson commented Feb 21, 2025

Problem

After setting Singed.output_directory = "flamegraphs/" inside development.rb the gem initialisation defaults it back to "tmp/speedscope"

Solution

Added memoization using the ||= operator to cache the computed path after its first calculation. This ensures that:

  • The path is only computed once during Rails initialization
  • The original fallback behavior is preserved if a custom path is set before initialization

Impact

  • Reduces unnecessary path computations
  • Maintains compatibility with existing custom path configurations
  • No breaking changes to the public API

Testing

  • Verified that the output directory is correctly set on initialization
  • Confirmed that custom paths set before initialization are not overwritten

Resulting stacktrace from server after change with bundle open
image

Before hand:
image

development.rb setup
image

@benaitcheson
Copy link
Contributor Author

@technicalpickles Would I be able to get a review on this one please. Thanks.

@technicalpickles technicalpickles merged commit 732818e into rubyatscale:main Apr 28, 2025
@technicalpickles
Copy link
Collaborator

Released in https://github.com/rubyatscale/singed/releases/tag/v0.2.3 , thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants