On Fri, 30 Apr 2010 04:45:43 +0200, Tomas Carnecky <[email protected]> wrote:
> Is there any other reason you chose to allocated the array only once > when the object is created? For almost all of the objects, the privates are allocated along with the underlying object itself, saving an allocation call and keeping memory accesses more local. The one exception is the screen object where privates are added on the fly during server initialization, requiring a realloc call. Without a separate allocation, it would be tricky to reallocate the private storage. This is precisely how privates worked when first implemented, so we aren't inventing a new requirement, just enforcing it again after a short hiatus. > Another difference, albeit a minor one, was that I kept my > 'DevPrivateRec' structures allocated inside privates.c instead of > scattered around the source files. Having them defined in the individual source file makes the privates code simpler; it doesn't need to allocate anything as they are registered. Plus, it means that getting the offset requires only a single memory fetch instead of two. > That allowed me to easily dump statistics about which privates are > used in which objects etc. I thought that would be a useful feature > for debugging purposes, or to simply see how much memory is being used > where. The privates code has a list of every key used everywhere once the server starts, and I've got some statistics dumping code written for precisely this purpose. -- [email protected]
pgp7xB6x1OHte.pgp
Description: PGP signature
_______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
