Re: [PATCH 1/1] platform: optimize sysctl_set() to use stack allocated buffer



On Wed, 2016-02-24 at 20:55 -0500, Colin Walters wrote:
On Tue, Feb 23, 2016, at 05:54 PM, Thomas Haller wrote:

The value written to sysctl is usually a short string. It makes
sense
to optimize for this case and avoid allocating a temporary string
on the heap.
Hey, so a while ago I was pushing for NetworkManager to use
libgsystem,
which then got backed out in favor of just copying the local alloc
macros.

Yes, because we only used gsystem-local-alloc.h, so we copied the file
as is.
Note that this kind of "reuse-by-copying-into-own-tree" has less
downsides then usual copy&paste or re-implementation. We still treat
the copied file as external. So is more like including libgsystem as
git-submodule -- e.g. our copied version is unmodified.

Since then, I've introduced "libglnx", its successor:

https://git.gnome.org/browse/libglnx

It'd likely be a good match for NetworkManager too, as this time it's
*only*
a git submodule.  It also has backported local alloc macros.

Now, the reason I'm mentioning this in reply to this message is that
part of
libglnx is shamelessly cloning some of the good parts of libsystemd-
shared,
and specifically in this case:

https://git.gnome.org/browse/libglnx/tree/glnx-alloca.h?id=8a7943fef6
061a4e9ca368e0042a8a3924affb99#n28

which avoids the hand-rolled string offset handling.

Nice... also to be able to include the ~library~ as git-submodule.

We also have a "shared" directory [2] what contains files that we copy
as-is to nm-openvpn and nm-applet repository. So, that is our ground
base of utilities we want to have everywhere. libglnx would go in this
direction.



Thomas


[1] 
https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/shared/nm-glib.h?id=aae6f07fe50f0917a55e9cf02cafe177ea654dfe
[2] 
https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/shared?id=aae6f07fe50f0917a55e9cf02cafe177ea654dfe

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]