FIX for high cpu usage

Home Forums Forum English (EN) FIX for high cpu usage

  • This topic contains 2 replies, has 1 voice, and was last updated by  David 4 weeks, 1 day ago.
  • Author
    Posts
  • #11773 Reply

    slash

    Hi Sébastien,
    you are using a busy loop and therefore blocking a whole core. See

    
    private void PageHandler(OpenSource.UPnP.UPnPDevice sender, OpenSource.UPnP.HTTPMessage msg, OpenSource.UPnP.HTTPSession WebSession, string VirtualDir) {
    // ...
    while (!sessionMp3Streams.TryRemove(s.SessionID, out value)) ;;
    

    A quick fix is to use wait handlers. Change the loop to

    
    while (!sessionMp3Streams.TryRemove(s.SessionID, out value))
                            ewh.WaitOne();
    

    and declare

    
    private static EventWaitHandle ewh = new EventWaitHandle(false, EventResetMode.AutoReset);
    

    After writing to sessionMp3Streams use ewh.Set(); E.g.

    
    PipeStream stream = sessionMp3Streams.GetOrAdd(WebSession.SessionID, new PipeStream());
    ewh.Set();
    

    and

    
    Parallel.ForEach<PipeStream>(sessionMp3Streams.Values, (p, s, l) =>
    {
         p.Write(bufferMp3, 0, bytesRead);
         ewh.Set();
    });
    

    Now the usage is at most 3% instead of 100%…

    #11802 Reply

    R0G

    Can this be fixed Sébastien? Experiencing problems as well.

    #12174 Reply

    David

    I’ve installed 1.4 and it’s using 36-45% of my cpu, even when I’m not playing any music. I also don’t see any recent activity on the Forum. If Sebastien is no longer doing development, perhaps “slash” above could produce a version with the fix?

Reply To: FIX for high cpu usage
Your information:




8 + = 11

Posted in