CPU usage increases as a function of time (1 Viewer)

tourettes

Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    Seems like a majority of devs are in countries where analog is not common or even non-existent. An ongoing issue that I don't think will get any better as more and more countries go digital. Sucks for us here as STB are here to stay for the foreseeable future. I guess the only thing we can do is provide logs?

    Unfortunately usualy the logs dont tell anything useful when it comes to the performance issues :(
     

    jonesdb

    Portal Pro
    January 11, 2008
    113
    6
    Santa Clara, CA
    Home Country
    United States of America United States of America
    Inifinityloop,
    That helps to explain why there doesn't seem to be much interest in this analog issue. The USA will have analog for a long time to come as the cable systems will continue to carry it for a long time to come and that is also the primary signal available off many of the set top boxes.
    I have continued to invistigate the issue and have learned that analog signals (actually MPEG2 from the tuner hardware encoder) are handled differently from the digital signals for both timeshift and record activities. The digital signals are all all written to disk using TSFileWriter.ax, while the analog signals are all written using mpFileWriter.ax. The packets of data written using TSFileWriter are much larger than the packets written using mpFileWriter which are always 188 bytes. The TSFileWriter packets are 1880 bytes for timeshift and 255,868 for recording. It is obvious that there is much greater overhead when using the analog tuner. I willing to dig into MP a little to see if something can be done about the situtation, but I'm having a somewhat difficult time finding my way around among the various modules. If one of the developers could help point the way it would sure speed up the process. I'm not a programer by trainig (analog/RF IC design anyone?), but have supervised some software development and so can find my way around C++ programs fairly well......C# is totally new to me, but looks close enough that I think I can get there without too much trouble. Is there some knowledgable developer out there that I can bounce a few questions off that wouldn't mind taking a little time to point me in the right direction? (I'm willing to swap some IC design knowledge ;-) )
     

    misterd

    Retired Team Member
  • Premium Supporter
  • April 4, 2006
    1,597
    314
    Home Country
    Germany Germany
    Hi all,
    it is correct that for digital cards TsWriter is used for writing to disks and MPFileWriter is used for analog cards. This is because both filters are handling different streams. TsWriter gets a transport stream and only filters those data before it gets written to disk

    MPFileWriter gets a mpg stream and converts it internally into a transport stream. Both filters are using similar write operations. Unfortunately MPFileWriter has no buffer and therefore writes each ts packet to disk. TsWriter has a buffer and therefore writes 10 ts packets to disk while timeshifting. We can change the behavior of MPFileWriter so that it also buffers the ts packets before they are written to disk, but therefor multiple things have to be changed in the filters. The reason is that we have to take care of pausing etc. when we are working with a buffer.

    Since there is also another small issue in this part of the code I will look what I can do. If you want, you can also look into the sources. Just search for the method OnTsPacket() in MultiFileWriterSink. You can send me your questions via PM.

    MisterD
     

    jonesdb

    Portal Pro
    January 11, 2008
    113
    6
    Santa Clara, CA
    Home Country
    United States of America United States of America
    MisterD,
    Excellent explanation of the inter workings of MP. You have brought us a better understanding of the real issues and why some of the programming decisions were made. Thank you!! I will look into the sources as you suggest as I am quite interested in gaining a more detailed understanding of the program. Thank you also for being willing to answer questions. I will try not to abuse your generosity and will hopefully only ask questions that lean on your expertise on MP and not simply on general programming. Again, thank you!!!
     

    misterd

    Retired Team Member
  • Premium Supporter
  • April 4, 2006
    1,597
    314
    Home Country
    Germany Germany
    Hi all,
    I finally found the time to look at this issue. I have added a similar buffer like TsWriter already have to MPFileWriter.
    Please test the attached version. Especially if .ts-recording and timeshifting is still working.

    MisterD

    @edit: Removed file, because the modifications are in SVN now.
     

    jonesdb

    Portal Pro
    January 11, 2008
    113
    6
    Santa Clara, CA
    Home Country
    United States of America United States of America
    :D MisterD. Thanks for finding the time to look into this. I've tried the file and wasn't able to make it work. Maybe I'm missing something. What SVN were you using? I copied the file to the TVServer directory where the original mpFileWriter.ax file is, renaming the old one in the process. I then tired to tune to an analog channel.....the TVServer stops running. I tired several re-starts and even rebooted the system with the same results. No problem tuning to digital channels, just shuts down when tuning to analog channels. Then I noticed that the original file name was mpFileWriter not MPFileWriter so I change the name mpFileWriter ..... same results. I then renamed the original file back to mpFileWriter.ax and everything is working as before the whole exercise. I didn't see anything in the logs, but they are attached. FailLog.zip contains logs from starting an analog channel using the new mpFileWriter.ax. Log.zip contains the logs from starting an analog channel using the original mpFileWriter.ax.
    BTW, I've been looking at the code differences between TSWriter and mpFileWriter. I see that TSWriter uses a RecordBuffer_size of 256000 when in the record mode and a write_Buffer_size of 1880 which had been reduced from 32900 (apparently something to do with the radio function) for the timeshift operation. Do you have an understanding of what drove all the different buffer sizes between mpFileWriter and TSWriter for record and timeshift operations. None of them seem to be consistent. Any insight is appriciated.

    Again, thanks for putting in the time to help out:D
     

    misterd

    Retired Team Member
  • Premium Supporter
  • April 4, 2006
    1,597
    314
    Home Country
    Germany Germany
    The filter is build for latest SVN. You need at least a SVN build that has subchannel support (Rev. >19920)., becuse there was a change in the interface of the filter.

    MisterD
     

    jonesdb

    Portal Pro
    January 11, 2008
    113
    6
    Santa Clara, CA
    Home Country
    United States of America United States of America
    MisterD,
    Thanks for the effort. I did a clean install of SVN 20227 in order to start the testing of your modification. The preliminary results look good. As advertised, it writes 10 packets of 188 bytes to the files for both time shift and record. I have run both timeshift and recordings for the analog channels and CPU usage is down significantly. I will continue to evaluate the performance to determine if there are any other differences that result from your changes, though I don't expect to find anything. Again a BIG thanks for the effort.:D
     

    misterd

    Retired Team Member
  • Premium Supporter
  • April 4, 2006
    1,597
    314
    Home Country
    Germany Germany
    :D for testing.
    But for recording the buffer is 1361 ts packets (=255868 bytes) like in TsWriter.

    BTW, I've been looking at the code differences between TSWriter and mpFileWriter. I see that TSWriter uses a RecordBuffer_size of 256000 when in the record mode and a write_Buffer_size of 1880 which had been reduced from 32900 (apparently something to do with the radio function) for the timeshift operation. Do you have an understanding of what drove all the different buffer sizes between mpFileWriter and TSWriter for record and timeshift operations. None of them seem to be consistent. Any insight is appriciated.

    I don't know why there are these different buffer sizes in MpFileWrite and TsWriter, but most effort is put into TsWriter, because many devs have only DVB cards. This is why sometimes changes are made to TsWriter and TsReader which are not ported to MpFileWriter. The result is that analog cards are broken, because MpFileWriter doesn't fit to TsReader anymore. The only way is to create common parts for both filters, but therefor MPFileWriter has to be improved/modified first.
    The difference between the buffer size for timeshifting and recording has something to do with the different use-cases. Timeshift files are directly played while they are written to disk, which means that the buffer has to be small. But for recording it is better to have a bigger buffer size.
    I hope that a little bit to understand why we have these differences.

    MisterD
     

    Users who are viewing this thread

    Top Bottom