systemd / pystemd

A thin Cython-based wrapper on top of libsystemd, focused on exposing the dbus API via sd-bus in an automated and easy to consume way.
GNU Lesser General Public License v2.1
409 stars 36 forks source link

Usage of LXML for faster performance #67

Closed Glandos closed 2 years ago

Glandos commented 2 years ago

I'm currently trying to build a tool for managing unused socket activated services using pystemd.

However, I found that the main performance hit was the XML parser (currently xml.dom.minidom). I modified base.py to use lxml.etree.fromstring instead and the overall performance is 2.6× times better when loading properties for all '*.service units of my running system.

I know that this bring an external dependency, but would you mind considering using lxml, maybe as an optional dependency?

aleivag commented 2 years ago

how is the build story around lxml these days?, i remember it been very bad on the 2010 the last time i tried to get it into a system...

i have no problem introducing a external that external dependency, just dont want folks to spend their days figuring out how to get lxml on a raspberrypi ... :)

davide125 commented 2 years ago

This is probably fine, lxml is packaged in pretty much all notable distros nowadays, so it shouldn't be too much trouble to add it as a dependency. If we can make it so we can fallback on minidom if it's not available, even better.

aleivag commented 2 years ago

i have landed (a.k.a merged) a experimental version of this will try to play around it in the afternoon...

Glandos commented 2 years ago

Thank you very much for your quick response.