Josh Hurst wrote: > On 10/30/06, Roland Mainz <roland.mainz at nrubsig.org> wrote: > > Attached is a small patch ("ksh93_libcmd_killglobalvars001.diff.txt") > > for ast-ksh.2006-09-12 which significantly reduces the size of the > > global variables in libcmd > Why do you think the global variable size needs to be reduced? Is > there anything especially bad when a program uses global variables?
Using global variables is usually not bad, however in this case there are multiple problems: - A command which uses libcmd will get all global variables of all commands mapped into it's address space. This is not bad for const data but may be devastating for read/write pages. Reducing the global variable size reduces the resource usage of such standalone commands dramatically. - We may want to make libshell threadsafe and global variables would then either require locking or some other kind of protection against other threads. - Solaris has MPSS (multiple page size support) since Solaris 10 and I'd like to use 64k pages on UltraSPARC for the stack since this lowers the MMU overhead by factor eight (and therefore improves performance). By default library mappings, including r/w pages, are mapped as 8k pages (unless a kernel tuneable gets changed) - which means global variables are mapped with 8k pages while the same amount of data stored in the stack is mapped via 64k pages, making it much more efficient than using global variables. ---- Bye, Roland -- __ . . __ (o.\ \/ /.o) roland.mainz at nrubsig.org \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL +49 641 7950090 (;O/ \/ \O;)