On Saturday 27 October 2007 06:57:14 Matt Mackall wrote:Hi Matt, I avoid typing even a single character of optimization until it's justified. This is partially a reaction against the machoptimization tendencies of many kernel programmers, but it's mainly a concern at the kernel's complexity creep. Meanwhile, of course, I've now spent far too long analyzing this :) Building a 1000 byte string 1 byte at a time involves 6 reallocs (SLAB) or 10 reallocs (SLUB). Frankly, that's good enough without an explicit alloc length field (better in some ways). As to keeping an explicit length vs strlen(): those 1000 calls on my test machine take 1491ns per call with an explicit length vs 1496ns per call with strlen(). That's not worth 4 bytes, let alone a single line of code, O(n^2) or no. As the nail in the coffin, callers only use ->buf, so are insulated from any such optimizations if we decided to do them in future. Hope that helps, Rusty. PS. I don't think we should switch this to a simple char ** tho, as the "struct stringbuf" gives us some type safety and reminds people not to simply kfree it. -
| Linus Torvalds | Linux 2.6.27-rc8 |
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Linus Torvalds | Linux 2.6.20-rc6 |
| Mike Snitzer | Re: Distributed storage. |
git: | |
| Gerrit Renker | [PATCH 03/37] dccp: List management for new feature negotiation |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| David Miller | [GIT]: Networking |
| Herbert Xu | Re: Kernel oops with 2.6.26, padlock and ipsec: probably problem with fpu state ch... |
