Coder Social home page Coder Social logo

daemon mode runs at 100% cpu about openbr HOT 7 CLOSED

biometrics avatar biometrics commented on July 19, 2024
daemon mode runs at 100% cpu

from openbr.

Comments (7)

caotto avatar caotto commented on July 19, 2024

I looked into this a little bit,
http://stackoverflow.com/questions/11145109/is-it-possible-to-read-intermittently-sent-data-through-a-named-pipe-using-redir
it seems doing this just by redirecting stdin is infeasible (since the stream will close after the first process that sends data ends), so br -daemon may need to deal with the pipe more explicitly

from openbr.

caotto avatar caotto commented on July 19, 2024

I should mention, as far as I can tell the situation is worse than reported, after the first writing process closes br is in a busy-wait, and also will not get input from any new processes that try and write to the pipe.

from openbr.

jklontz avatar jklontz commented on July 19, 2024

Added in an explicit sleep when no input is available, seems to work for me now:

$ mkfifo mypipe
$ br -daemon < mypipe &
$ echo "-algorithm FaceRecognition" > mypipe
$ top

But @caotto is right about the pipe being closed, more on this to come...

from openbr.

jklontz avatar jklontz commented on July 19, 2024

Ok thank you @caotto for working this out with me. The correct usage is now:

$ mkfifo mypipe
$ br -daemon mypipe &
$ echo "-algorithm FaceRecognition" > mypipe
$ echo "-enroll ../data/MEDS/img" > mypipe
$ top

from openbr.

cyrusadkisson avatar cyrusadkisson commented on July 19, 2024

I'm not sure I follow this about the pipe being closed. I have been able to echo commands to the daemon via the pipe repeatedly without it closing (and ceasing to accept commands) for the past few days since jklontz and I worked on it. In any case, the commands you showed above are exactly what I've been doing except I've been using "br -daemon < mypipe" (+ a less-than sign and minus the ampersand). Should I use the above for future builds?

update: Actually, the ampersand is irrelevant. Without it, the terminal becomes occupied. With it, the terminal is released for future commands. So I guess the only difference between what I've been doing and what your instructions say is the "<". Which way is correct?

from openbr.

caotto avatar caotto commented on July 19, 2024

jklontz modified br -daemon to take the name of the pipe to read from as an input argument (instead of just reading from stdin, which is what br -daemon previously did).

"br -daemon < mypipe" redirects stdin to read from mypipe, which was previously the correct thing to do (br didn't do anything with mypipe directly, it just read from stdin).
For new builds, the correct use is "br -daemon mypipe". br expects the pipe name "mypipe" to be passed as an argument, and br reads directly from that pipe rather than reading from stdin.

The &, like < is a shell command, & tells the shell to run the command asynchronously, so you don't need an ampersand unless you want to run br in the same console you use to send commands to mypipe.

Regarding the pipe closing issue, what OS are you using? I think both Josh and I were using OSX, I don't know offhand but it's possible other operating systems have nicer implementations of named pipes.

Actually, I wonder do you get a busy wait all the time (when running br -daemon with an old build), or only after one process has written to the pipe then exited?

from openbr.

cyrusadkisson avatar cyrusadkisson commented on July 19, 2024

Sweet. Just tested it out. Barely any CPU usage at all when no commands are coming through. Thanks!

from openbr.

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.