Code Monkey home page Code Monkey logo

Comments (5)

Liupold avatar Liupold commented on May 24, 2024 1

pids.with.ps.txt
Here is a script with your suggested modification. (around 0.095s, almost twice as slow). If we left the pstree as it is. (The exception you had was a result of parsing the parser). (The sed was a pipe and a child to pstree). This will not be there while using this script. (I have tried with pipes it works fine, Eg: feh, mpv, zathura). With only the modification to the /proc/$cpid/comm -> ps -p $cpid -o comm:1= it's around 0.050s (execution).

  • I am going to change /proc to ps.
  • I am still not sure what to do with pstree. see if you can make any improvement. (1.5x base is the threshold). [execution time].
  • from what i can tell pstree is available on bsd too.
  • yes parsing pstree is not ideal. But it is the fastest way (till now).

Any improvement PR will be merged. (feel free to create one, you can always modify your PR and once it's good enough i will merged it.)

from pidswallow.

SeerLite avatar SeerLite commented on May 24, 2024

Speaking of... It looks like the proc filesystem is pretty linux-specific.

Now, I'm not completely sure if bspwm is linux-specific or not, but I guess since the script is already pretty POSIX, that ps is the only true way to deal with all of this. The commands are
ps -p <pid> -o comm= for process name
and
ps -p <pid> -o ppid= for parent pid.

Let me know what you think about this!

from pidswallow.

Liupold avatar Liupold commented on May 24, 2024

I think we can now add ps instead of pstree as the script now support a --loop feature.
(So it doesn't have to execute every line on node_add / node_remove). It will be slower but it will be must less impactful. Give it a try and let me know.

from pidswallow.

SeerLite avatar SeerLite commented on May 24, 2024

Hey, nice! The script looks a lot neater! I'll change some stuff I think is important and then maybe look into using ps.

The sed was a pipe and a child to pstree

Actually, it was a child of zsh. The issue isn't about pipes, it's about subprocesses. For example, if mpv creates a subprocess, then the tree will diverge like my example. Still, I'm gonna look into that. Maybe we can keep using pstree and just cut out the first line and try to ignore the subprocesses. Edit: I actually did this here.

from pidswallow.

SeerLite avatar SeerLite commented on May 24, 2024

Closed through 4a69df2

from pidswallow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.