You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I've been having some memory issues with an application and I started profiling it using https://github.com/MiniProfiler/rack-mini-profiler#memory-profiling. I found the source of the leaks, but I also noticed that in the allocated strings section the Scout APM gem comes up a lot (at the top of the list). It seems like we could save on a lot of memory allocations by freezing some string literals and/or creating constants for commonly used strings.
also comes up a lot - I guess the file names get computed a lot and the colon is also reallocated frequently.
I'm not sure if it's enough to stick a .freeze after the literals or if you need to pull out a constant to save the memory allocations.
Maybe for a bigger application this would just be noise, but it happens that the "AutoInstrument" string is the top string allocated in the memory profiles that I'm looking at. I think overall Scout's overhead is pretty low but it would always be good to get it lower!
It seems like as of #427 the files that can't run with that pragma are already marked, so it might be possible to put the pragma on all other files. But for now I'm mainly interested in these few files that seem to be triggering a lot of allocations. (Well, I don't really know if it's enough allocations to be noticeable, but a few thousand is certainly more than 1 or 2, at least, so in principle it seems like we could be doing less work.)
The text was updated successfully, but these errors were encountered:
Hi! I've been having some memory issues with an application and I started profiling it using https://github.com/MiniProfiler/rack-mini-profiler#memory-profiling. I found the source of the leaks, but I also noticed that in the allocated strings section the Scout APM gem comes up a lot (at the top of the list). It seems like we could save on a lot of memory allocations by freezing some string literals and/or creating constants for commonly used strings.
scout_apm_ruby/lib/scout_apm/tracked_request.rb
Line 192 in bf9fb4b
scout_apm_ruby/lib/scout_apm/auto_instrument/layer.rb
Line 9 in bf9fb4b
scout_apm_ruby/lib/scout_apm/auto_instrument/layer.rb
Line 6 in bf9fb4b
I'm not sure if it's enough to stick a
.freeze
after the literals or if you need to pull out a constant to save the memory allocations.Maybe for a bigger application this would just be noise, but it happens that the "AutoInstrument" string is the top string allocated in the memory profiles that I'm looking at. I think overall Scout's overhead is pretty low but it would always be good to get it lower!
It seems like as of #427 the files that can't run with that pragma are already marked, so it might be possible to put the pragma on all other files. But for now I'm mainly interested in these few files that seem to be triggering a lot of allocations. (Well, I don't really know if it's enough allocations to be noticeable, but a few thousand is certainly more than 1 or 2, at least, so in principle it seems like we could be doing less work.)
The text was updated successfully, but these errors were encountered: