Opened 18 years ago
Closed 17 years ago
#1660 closed defect (fixed)
Database updates in firewirerecorder.cpp cause dropped data
Reported by: | Owned by: | cpinkham | |
---|---|---|---|
Priority: | minor | Milestone: | 0.21 |
Component: | mythtv | Version: | head |
Severity: | medium | Keywords: | |
Cc: | nick.rosier@… | Ticket locked: | no |
Description
I've been fighting the
kernel: ivtv0: All encoder MPEG stream buffers are full. Dropping data. kernel: ivtv0: Cause: the application is not reading fast enough.
problem for months now. It turns out the biggest problem is updating the filesize and recordedmarkup in the same thread that reads from /dev/video. The attached patch creates a separate thread to run theses, redoes the multilple inserts to be more efficient, as well as changes to up the priority of the reader and writer threads. With these changes, the frequency of these errors have dropped from once per program to once per week.
Attachments (9)
Change History (34)
Changed 18 years ago by
Attachment: | speedup.patch added |
---|
comment:1 Changed 18 years ago by
Owner: | changed from Isaac Richards to danielk |
---|
Changed 18 years ago by
Attachment: | 1660-v1.patch added |
---|
comment:2 Changed 18 years ago by
Milestone: | → 0.20 |
---|---|
Version: | → head |
ajlill, can you try the attached patch?
It uses the DeviceReadBuffer? we use for the DVB recorder for the ivtv recorder. This should allow us to keep reading the ivtv device while the DB inserts are in progress.
I'm still interested in some of your improvements if you could break them into a patch for each one I might be able to apply at least some of them.
However, please test this patch without those improvements. I think this small change alone should be sufficient to address your problem.
comment:3 Changed 18 years ago by
I can put it in this weekend and run it over next week to see how it works. The only other thing in the patch was monkeying with priorities in the reader and writer threads. If your patch works, I'll have to move the priority bump from the MPeg thread to DeviceReadBuffer?, and I'll submit a new ticket.
comment:4 Changed 18 years ago by
I gave your patch a short trial (backported it to 0.19, actually) and I didn't see any ivtv errors during recording. However, it doesn't look like it stops recording properly. 15 seconds after the recording is supposed to end, I get the ivtv error, probably beause the driver is producing data after the DeviceReadBuffer? thread ends. This causes mythfrontend to crash when you change channels and looks like it skips a noticable ammount of time on consecutive recordings. Because of these problems I couldn't run it very long.
comment:5 Changed 18 years ago by
So I've been running the speedup.patch on my system for the past two days, and my ivtv errors have completely disappeared. I was also getting huge numbers of dropped frames every time a recording was just starting (on the order of 5 to 10 seconds), and those frame drops have also disappeared.
It was compiled into release-0.19-fixes.
comment:6 Changed 18 years ago by
Milestone: | 0.20 → 0.21 |
---|
Changed 18 years ago by
Attachment: | asyncdb.patch added |
---|
Updated speedup.patch to 0.20 - this is just the changes to make the programinfo class use an asynchronous db thread, since it make the realtime fixes superflous
Changed 17 years ago by
Attachment: | asyncdb.2.patch added |
---|
Fixed version of ajlill@…'s asyncdb.patch for 0.20 with two typos fixed that caused a "malformed patch" error. (In line 5, both ",11"s should be ",9" .)
comment:7 Changed 17 years ago by
Cc: | nick.rosier@… added |
---|
comment:8 Changed 17 years ago by
The asyncdb.12631.patch version is incomplete, it appears to be missing changes to mythbackend/main.cpp where gAsyncDB is setup. Are there any other missing parts? If the QStringList is working fine, can the other adb_cmd_list parts be cleaned out?
comment:9 Changed 17 years ago by
If you download it in the original format, it's complete. There's something wonky with the patch fancy viewer.
comment:10 Changed 17 years ago by
Owner: | changed from danielk to cpinkham |
---|
comment:11 Changed 17 years ago by
Priority: | minor → major |
---|
When, oh when, will this patch make it in to SVN?
This problem has been plaguing all of my recordings, and I've been installing the latest build from SVN every week in the hope that it would disappear. Now that I've discovered this official bug and see that it dates back to April, I have to ask, what's the holdup?
comment:12 Changed 17 years ago by
Priority: | major → minor |
---|
Changed 17 years ago by
Attachment: | asyncdb.12694.patch added |
---|
Updated to 12694 and cleaned as requested
comment:13 Changed 17 years ago by
I cleaned out the adb_cmd_list. The patch by wilhelm.eger@… had a space missing at the beginning of a line that tricked the patch viewer (and the patch command) into thinking a couple of the changes to main.cpp was to another file. Strange... Anyway, this should be good to go.
comment:14 Changed 17 years ago by
Priority: | minor → major |
---|
Isaac, stop lowering the priority of this ticket.
comment:15 Changed 17 years ago by
Priority: | major → minor |
---|
Unless your name is Chris Pinkham, don't mess with the priority.
comment:16 Changed 17 years ago by
Don't you care when users of your software are encountering a problem that inhibits the function of the program you're writing?
It's only a matter of time before this project gets forked...
comment:17 Changed 17 years ago by
Status: | new → assigned |
---|
Can you guys try out my asyncdb_v1.diff version of the patch. It has a couple changes. It now takes a pointer to a MSqlQuery as an argument instead of a QString. This way we can continue using the prepare()/bindValue() methodology rather than having to build QString's all over the place and dealing with having to quote, format dates, etc.. The second change is the addition of a callback and data pointer to the add command. This allows you to specify a callback procedure to be called when the query is executed. The callback procedure will be called with the original MSqlQuery pointer and the passed-in data pointer as arguments. I added this because one of the things on my TODO list for a long time has been to try to optimize the loading of the seektable when we start playback. If we can load the seektable in the background, we can start playback quicker.
I've done minor testing of this on my dev system and everything appears to be working fine. I even tested the callback, but took the test callback out before I made this patch. Can you please try this out and report back and hopefully we can get this into SVN soon.
comment:18 Changed 17 years ago by
Nix the whole async idea. After talking this over on IRC, we are going to move these DB updates outside of the recorder and into the main TVRec class. The various *recorder classes will continue to populate the delta map but the TVRec class will be the consumer and will write the data out to the DB. I'm removing the patch I mentioned in my previous comment.
comment:19 follow-up: 20 Changed 17 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
For now, this should have been fixed in trunk in [12918] and in -fixes in [12919]. These changesets disable updating the filesize inside the main recording loop in order to get rid of the contention between the scheduler and the recorders.
I'm going to close this ticket for now, but may update it again for reference if we make any more changes related to updating the filesize during recording.
comment:20 Changed 17 years ago by
comment:21 Changed 17 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
I'd like to report my experiences with the above patches. Bottom line: I hope ajlill's asyncdb patch stays in the code.
I have two FireWire? cable boxes and an ATSC capture card, and routinely simultaneously record from all three sources. I've been using the asyncdb patch (to be accurate, asyncdb.2.patch with the typo correction I submitted) on top of my 0.20-fixes setup for several months now. With it, 60-minute FireWire? HD recordings typically come in at 59:55 to 59:59; i.e., exactly as long as they should, barring startup times.
Since the ATrpms 0.20-fixes package now incorporates r12919 I tried building it without the asyncdb patch. Not so much luck here; the same 60-minute FireWire? recordings came in about 30-250 seconds short, and during replay I saw frequent MPEG errors from dropped frames (slight skips in the video or the image blurring for a moment). (Interestingly, ATSC HD recordings were seemingly unaffected.)
comment:22 Changed 17 years ago by
I'v updated my patch to add some logic to restart the database connection if it fails. This only affects people using slave backends, since local database connections automagically restart. If you're using the 0.20 branch, apply the patch for that branch, then replace asyncdb.* files with the ones in this patch.
comment:23 Changed 17 years ago by
Summary: | database updates in *recorder.cpp cause dropped data → Database updates in firewirerecorder.cpp cause dropped data |
---|
Updating description to reflect current status.
comment:24 Changed 17 years ago by
I'm definitely still seeing this with my setup and I'm NOT USING FIREWIRE. Using the latest SVN, as of yesterday.
Recommend you look into it again; it's fking annoying as hell.
comment:25 Changed 17 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
(In [13619]) Move the seektable writing code out from the main recorder threads and into the TVRec main thread. Now the recorder threads fill in the positionMap and positionMapDelta and the TVRec class calls RecorderBase::SavePositionMap?() to consume the data.
If it is determined that we should write the delta to the database, a copy of the delta map is made and the positionMapLock is unlocked. This allows us to keep the position maps for as short of time as possible and allows the DB update to happen without impacting the recorders collecting data.
As part of this, I moved the *Recorder::SavePositionMap?() code into RecorderBase? because the only difference between the three was the positionmap type. The type is now stored in a variable set by the three *Recorder classes affected.
Closes #1660.
use devicereadbuffer for ivtv