[Buildroot] Buildroot fails on powerpc with busybox login.c

Rob Landley rob at landley.net
Mon Sep 18 18:54:49 UTC 2006


On Monday 18 September 2006 3:12 am, Rich Felker wrote:
> There are WAAAY too many places where BB is using BUFSIZ as a generic
> "we hope it's big enough for whatever we need" buffer. I found several
> uses in the vi applet that were doing memset-0 on the whole buffer
> every time you move the cursor. The _only_ meaning of BUFSIZ is to
> tell you what size buffer you should pass to the (obsolete, replaced
> by setvbuf) setbuf stdio function.

We're also using it as a rough estimate for both PATH_MAX, and the important 
thing is probably PAGE_SIZE.

4k is a bit of a sweet spot in terms of buffer sizes, and has been for maybe 
10 years.  If you're going to any fetch data at all, it's not much slower to 
fetch _this_ much data.  (It has to do with round trip dram fetch latency, 
fully cold cache when you have to open a new bank and then do a burst 
transfer thingy.  It's probably possible to calculate this but would be far 
easier to just benchmark it.  Insert general handwaving here.)

On 64 bit hardware the sweet spot may someday migrate up as high as 64k (in 
fact these days it may be inching closer to 16k), but I don't really care.

Having a 4k buffer lying around is a good thing.  I've pondered renaming 
bb_common_bufsiz1 to something like "applet_buffer", documenting that this is 
general-purpose scratch space which should only be used in an applet and 
_not_ in libbb, and encouraging its use to reduce allocations, large on-stack 
buffers, and declaring yet _more_ unshared per-applet static buffers.

Rob
-- 
Never bet against the cheap plastic solution.



More information about the busybox mailing list