Date: Tue, 22 Jan 2013 12:01:06 -0500 From: John Baldwin <jhb@freebsd.org> To: freebsd-hackers@freebsd.org Cc: Mikolaj Golub <trociny@freebsd.org>, Stanislav Sedov <stas@freebsd.org>, Robert Watson <rwatson@freebsd.org> Subject: Re: libprocstat(3): retrieve process command line args and environment Message-ID: <201301221201.06290.jhb@freebsd.org> In-Reply-To: <20130119151253.GB88025@gmail.com> References: <20130119151253.GB88025@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday, January 19, 2013 10:12:54 am Mikolaj Golub wrote: > Hi, > > Some time ago Stanislav Sedov suggested to me extending libprocstat(3) > with functions to retrieve process command line arguments and > environment variables. > > In the first approach I tried, the newly added functions > procstat_getargv/getenvv allocated a buffer of necessary size, stored > the values and returned to the caller: > > http://people.freebsd.org/~trociny/libprocstat.1.patch > > The problem with this approach was that when I updated procstat(1) to > use this interface, I observed noticeable performance degradation > (about 30% on systems with MALLOC_PRODUCTION off), due to memory > allocation overhead: the original procstat(1) reuses the buffer for > all its retrievals. > > So my second approach was to add internal buffers to struct procstat, > which are used by procstat_getargv/getenvv to store values and reused > on the subsequent call: > > http://people.freebsd.org/~trociny/libprocstat.2.patch > > The drawback of this approach is that a user has to take care and > remember that a subsequent call rewrites argument vector obtained from > the previous call. On the other hand this is ok for typical use cases > while does not add allocation overhead, so I like this approach more. > > I would like to commit this second patch, if there are no objections > or suggestions how to improve the things. How is this different from kvm_getargv()? It seems to be a direct copy. -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201301221201.06290.jhb>