Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #2066 (reopened enhancement)

Opened 13 years ago

Last modified 13 years ago

Log.d: Prevent allocation through concatination

Reported by: Marenz Assigned to: community
Priority: major Milestone: 1.0
Component: Tango Version: 0.99.9 Kai
Keywords: Cc:

Description

This line http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Log.d#L1099 allocates memory for each Lookup/injection call.

I wrote a small patch to only allocate memory when it actually is adding something to the map.

Attachments

Log.patch (0.9 kB) - added by Marenz on 07/15/11 10:33:42.

Change History

07/15/11 10:33:42 changed by Marenz

  • attachment Log.patch added.

07/18/11 13:23:56 changed by mwarning

This patch makes the code,

  • harder to read,
  • introduces a slightly higher stack use and
  • makes it quite a bit faster

Ihmho, library code is allowed to be a bit harder to read.

08/03/11 20:14:24 changed by dhasenan

  • status changed from new to closed.
  • resolution set to fixed.

(In [5675]) Fix #2066: allocate less when searching for a Logger.

Thanks to Marenz for the patch.

(follow-up: ↓ 4 ) 08/04/11 00:32:19 changed by kris

  • status changed from closed to reopened.
  • resolution deleted.

shouldn't be doing lookups often at all .. they should be done once and the Logger references stored at module-scope.

I feel this is a misunderstanding over usage, rather than something that needs to be made faster. If you're concerned about speed, it's a whole lot faster to not invoke this at all (other than for initialization purposes).

(in reply to: ↑ 3 ) 08/04/11 10:58:47 changed by Marenz

Replying to kris:

shouldn't be doing lookups often at all .. they should be done once and the Logger references stored at module-scope. I feel this is a misunderstanding over usage, rather than something that needs to be made faster. If you're concerned about speed, it's a whole lot faster to not invoke this at all (other than for initialization purposes).

yea, eventually mwarning and me got to the same conclusion.. it was a rather specific and hacky testcase. I was aware that it wasn't meant to be used like that, but at the moment it was easier to do it like that than to add a logger variable and use that.. it was fast hack to output stuff to a certain logger and that's how I found it.. so yea, let's close this.. though we need to revert the commit, right?