Closed guigs closed 4 years ago
Logging is a hotspot and some log messages can be quite big and each call to gsub allocates a new string.
gsub
I added a call to #dup at the beginning so we don't mutate the original message. But after that all substitutions mutates this copy.
#dup
I haven't run any benchmarks and have not tested this.
Thanks @guigs! rake benchmark:memory shows a decrease of 5 allocations per log call as expected.
rake benchmark:memory
Logging is a hotspot and some log messages can be quite big and each call to
gsub
allocates a new string.I added a call to
#dup
at the beginning so we don't mutate the original message. But after that all substitutions mutates this copy.Disclaimer
I haven't run any benchmarks and have not tested this.