SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Github Development
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Github Development Discussion related to SageTV Open Source Development. Use this forum for development topics about the Open Source versions of SageTV, hosted on Github.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-28-2015, 06:25 PM
dvd_maniac's Avatar
dvd_maniac dvd_maniac is offline
Sage Icon
 
Join Date: Mar 2004
Location: New England
Posts: 1,899
Any details around the Database Improvements?

From the release notes:
21. Significant performance improvements to overall database system

My wiz.bin hovers between 80 - 90MB lately and I am noticing some performance issues especially on the extenders.I want to try the Open Source version specifically for this update but am afraid of some of my installed plugins might then have issues.
It would be nice to know the details of this update to see if it would even be worth trying it out... Are there any specifics regarding this?
__________________
If this doesn't work right, Then:
"I'm going to blow up the Earth!"
Reply With Quote
  #2  
Old 09-29-2015, 06:46 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by dvd_maniac View Post
From the release notes:
21. Significant performance improvements to overall database system

My wiz.bin hovers between 80 - 90MB lately and I am noticing some performance issues especially on the extenders.I want to try the Open Source version specifically for this update but am afraid of some of my installed plugins might then have issues.
It would be nice to know the details of this update to see if it would even be worth trying it out... Are there any specifics regarding this?
I think Jeff mentioned the improvements were made in the areas of locking and concurrency.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #3  
Old 09-29-2015, 11:44 AM
will will is offline
Sage Fanatic
 
Join Date: Jul 2009
Location: New York
Posts: 798
Quote:
Originally Posted by tmiranda View Post
I think Jeff mentioned the improvements were made in the areas of locking and concurrency.
What is locking and concurrency exactly when it comes to STV?
__________________
Will

OS: Windows 7
Hardware: Intel Core i7-920 with 12GB RAM & an Adaptec 5805 with a Chenbro 36-port SAS Expander
Case: Antec 1200 with 4 iStarUSA trayless hot-swap cages (20 drives max)
Drives: 8 Toshiba/Hitachi 2TB drives in a RAID 6 & 7 Toshiba 3TB drives in a RAID 6
Capture Cards: HDHomeRun Connect Quatro 4, Hauppauge 60 HD-PVR
Players: 5 HD300s, 2 HD200s
Reply With Quote
  #4  
Old 09-29-2015, 11:52 AM
moothekow moothekow is offline
Sage Advanced User
 
Join Date: Oct 2008
Posts: 88
Quote:
Originally Posted by will View Post
What is locking and concurrency exactly when it comes to STV?
Basically it means it improves allowing multiple things to access the database at once. Locking = preventing other things from accessing the database while it's doing something. Concurrency = multiple things accessing it at once.

So - before it was possible that if the server was updating something in one part of the database - it could have made any clients wanting to read stuff wait until it was done even if there wasn't any overlap in the areas the two things were looking at. I'm assuming he's improved the code so if the server is writing something related to item A and the client wants to read information about item B it won't have to wait until the server is done. I don't know the specifics of what was slow before or what was improved - but this is my best guess :-).
Reply With Quote
  #5  
Old 09-29-2015, 12:25 PM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,514
There are also indexes that contained ID's sorted by something else. So when looking up something like a show by its title, the program doesn't have to scan all of the shows (which are in the order they were initially added to the DB). It instead can quickly locate the title by searching the index and checking only a few ID's to find the right one. If you want more detail I can make an illustration.
Reply With Quote
  #6  
Old 09-29-2015, 12:32 PM
Narflex's Avatar
Narflex Narflex is offline
Sage
 
Join Date: Feb 2003
Location: Redondo Beach, CA
Posts: 6,349
The improvements were pretty much all concurrency related. Previously, it had locks per-table. So if something was reading/writing the Airing table...then nothing else could access it at the same time. Now each table has separate locks for reading and writing...so many things are allowed to read a table in the DB simultaneously; and they are only blocked out that table DB if something has a write lock (which we only grab now when something is actually being modified). A main point of slowdown previously was after an EPG update when SageTV was saving out the database to disk and had to read the whole thing from memory to write it out, locking each table as it was written...and that took a fair amount of time and you'd usually see the spinning circle during this...now it should not cause the spinning circle at all since it will only be grabbing read locks.

Sorted indexes were always part of the database.

The other improvement was adding Lucene; so that when you do full text searches, they will execute much faster than before (although they already worked surprisingly fast for doing a linear search of the DB).
__________________
Jeffrey Kardatzke
Google
Founder of SageTV
Reply With Quote
  #7  
Old 09-29-2015, 12:40 PM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,514
Quote:
Originally Posted by Narflex View Post
Sorted indexes were always part of the database.
That's odd because when I disassemble my version 7 DB, there aren't any.
Reply With Quote
  #8  
Old 09-29-2015, 04:50 PM
Narflex's Avatar
Narflex Narflex is offline
Sage
 
Join Date: Feb 2003
Location: Redondo Beach, CA
Posts: 6,349
Quote:
Originally Posted by wnjj View Post
That's odd because when I disassemble my version 7 DB, there aren't any.
Then your disassembler doesn't work right. Indexes have been part of the DB since it was first created back in 2002.
__________________
Jeffrey Kardatzke
Google
Founder of SageTV
Reply With Quote
  #9  
Old 09-29-2015, 06:03 PM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,514
Quote:
Originally Posted by Narflex View Post
Then your disassembler doesn't work right. Indexes have been part of the DB since it was first created back in 2002.
Maybe indexes were always there, but it seems they are only recently written to wiz.bin (ver 83):

Code:
  // 83 added support for writing out index orders; this is backwards compatible since older versions will skip this section and create their own indices
So the improvement is reading them in rather than re-creating them every time.
Reply With Quote
  #10  
Old 09-30-2015, 12:32 PM
Narflex's Avatar
Narflex Narflex is offline
Sage
 
Join Date: Feb 2003
Location: Redondo Beach, CA
Posts: 6,349
Quote:
Originally Posted by wnjj View Post
Maybe indexes were always there, but it seems they are only recently written to wiz.bin (ver 83):

Code:
  // 83 added support for writing out index orders; this is backwards compatible since older versions will skip this section and create their own indices
So the improvement is reading them in rather than re-creating them every time.
Lol...yes, that is correct. I had totally forgotten about that it used to not store them on disk.
__________________
Jeffrey Kardatzke
Google
Founder of SageTV
Reply With Quote
  #11  
Old 10-01-2015, 08:41 PM
dvd_maniac's Avatar
dvd_maniac dvd_maniac is offline
Sage Icon
 
Join Date: Mar 2004
Location: New England
Posts: 1,899
I just cleared the watched flag of about 12,000 recordings using the WebUI and though that would shrink my wiz.biin down a bit but it did not. In fact it went form 81,302KB to 86,273KB. Is there some sort of process that I need to do to purge old recordings without starting from a completely fresh wiz.bin?
__________________
If this doesn't work right, Then:
"I'm going to blow up the Earth!"
Reply With Quote
  #12  
Old 10-02-2015, 12:35 AM
JREkiwi's Avatar
JREkiwi JREkiwi is offline
Sage Icon
 
Join Date: Jan 2005
Location: Auckland, New Zealand
Posts: 2,132
What ever you do with the wiz.bin it won't have an immediate effect on the size. You need to wait for the cleanup to occur. Normally happens on a SageTV restart or daily when doing an EPG update.

Something I have seen is UserRecords created by plugins taking up wiz.bin space as there is not an automated process to delete the UserRecords associated with a media file when the file is deleted.

John
Reply With Quote
  #13  
Old 10-02-2015, 01:13 AM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Quote:
Originally Posted by dvd_maniac View Post
I just cleared the watched flag of about 12,000 recordings using the WebUI and though that would shrink my wiz.biin down a bit but it did not. In fact it went form 81,302KB to 86,273KB. Is there some sort of process that I need to do to purge old recordings without starting from a completely fresh wiz.bin?
Changing the state of a flag is not going to remove that entry from the wiz.bin. Essentially, any recording that has been made will stay in the wiz.bin forever. There is no process to 'purge' this old metadata.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #14  
Old 10-02-2015, 06:26 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by JREkiwi View Post
Something I have seen is UserRecords created by plugins taking up wiz.bin space as there is not an automated process to delete the UserRecords associated with a media file when the file is deleted.
Some of my plugins are guilty of this. I think we need a PluginUninstalled event so plugins can clean up after themselves when uninstalled.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #15  
Old 10-02-2015, 06:55 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by tmiranda View Post
Some of my plugins are guilty of this. I think we need a PluginUninstalled event so plugins can clean up after themselves when uninstalled.
Or... If a UserRecord had the concept of an owner (ie, a Plugin) and SageTV could just clean them up automatically once a plugin is uninstalled. Having plugin authors do it, is good, but I have feeling not many would actually handle the event. It'll be like the windows registry

In addition to user records, mediafiles have custom metadata fields. Phoenix stuffs LOTS of information in these fields.
Reply With Quote
  #16  
Old 10-02-2015, 07:07 AM
dvd_maniac's Avatar
dvd_maniac dvd_maniac is offline
Sage Icon
 
Join Date: Mar 2004
Location: New England
Posts: 1,899
So whenever I record something or set something to watched it is going to stay in the wiz.bin forever?

I give up...
I'm ditching my wiz.bin and starting fresh.
The only thing that sucks is that I have a couple of odl classic favorite TV shows that I'm trying to get and now it will end up recording the ones I already have again.
No biggie...
__________________
If this doesn't work right, Then:
"I'm going to blow up the Earth!"
Reply With Quote
  #17  
Old 10-02-2015, 08:03 AM
Taddeusz Taddeusz is offline
SageTVaholic
 
Join Date: Nov 2004
Location: Yukon, OK
Posts: 3,919
On the face of it I guess it's not bad that SageTV loads the entire db into memory. However, I can see how this can be a problem as one's database grows larger. An 80MB database shouldn't necessarily be a problem. A more pragmatic approach using a cache might be better approach. Why should the whole database always be kept in memory when the majority of that database won't necessarily need to be accessed?

Yes, accessing data from disk would take more time than from memory but smart cache management could make any user impact negligible. For example, as someone is scrolling through the recordings list or through the videos list it could pre-cache the items forward and backward on the list as the user is scrolling. That way the user should never notice any interface impact from a cache miss.

Even if/when SageTV can run in a 64-bit JVM in Windows that 80MB database is still taking up a significant part of its overall memory footprint.

Another school of thought I just had is the current database format is kind of akin to the old legacy Office document formats. For those that don't know a .doc file is actually a dump of the memory representation of that document to disk. So when Word loads a .doc file it essentially plays back that file into memory. This is the reason that the legacy Office files can grow so huge compared to the newer format based on XML.

Not saying the current wiz.bin is necessarily a bad thing. It has most definitely served its purpose. Just thinking that even as difficult as it would be to change a more pragmatic approach might be necessary to continue to move SageTV into the future.

I'm not saying lets replace the Wizard just because. From an efficiency and maintainability perspective how much of the code is written specifically to deal with maintenance of the Wizard? Garbage collection, concurrency, locking? How often does this code run? How much more efficient could the core of SageTV be if we were to use a standard database, even something like SQLite or Mongo? I'm sure there are libraries already that can convert database objects to the Java objects that SageTV uses with little to no fuss. Yes, this would introduce necessary complexity. But it would also offload some of the maintenance of the database itself to a system specifically designed to store and manage data.

Not saying "let's do this". I know the Wizard is Jeff's baby. Just providing some perspective and food for thought.
__________________
Server: i5 8400, ASUS Prime H370M-Plus/CSM, 16GB RAM, 15TB drive array + 500GB cache, 2 HDHR's, SageTV 9, unRAID 6.6.3
Client 1: HD300 (latest FW), HDMI to an Insignia 65" 1080p LCD and optical SPDIF to a Sony Receiver
Client 2: HD200 (latest FW), HDMI to an Insignia NS-LCD42HD-09 1080p LCD
Reply With Quote
  #18  
Old 10-02-2015, 08:35 AM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Quote:
Originally Posted by Taddeusz View Post
On the face of it I guess it's not bad that SageTV loads the entire db into memory. However, I can see how this can be a problem as one's database grows larger. An 80MB database shouldn't necessarily be a problem. A more pragmatic approach using a cache might be better approach. Why should the whole database always be kept in memory when the majority of that database won't necessarily need to be accessed?

Yes, accessing data from disk would take more time than from memory but smart cache management could make any user impact negligible. For example, as someone is scrolling through the recordings list or through the videos list it could pre-cache the items forward and backward on the list as the user is scrolling. That way the user should never notice any interface impact from a cache miss.

Even if/when SageTV can run in a 64-bit JVM in Windows that 80MB database is still taking up a significant part of its overall memory footprint.

Another school of thought I just had is the current database format is kind of akin to the old legacy Office document formats. For those that don't know a .doc file is actually a dump of the memory representation of that document to disk. So when Word loads a .doc file it essentially plays back that file into memory. This is the reason that the legacy Office files can grow so huge compared to the newer format based on XML.

Not saying the current wiz.bin is necessarily a bad thing. It has most definitely served its purpose. Just thinking that even as difficult as it would be to change a more pragmatic approach might be necessary to continue to move SageTV into the future.

I'm not saying lets replace the Wizard just because. From an efficiency and maintainability perspective how much of the code is written specifically to deal with maintenance of the Wizard? Garbage collection, concurrency, locking? How often does this code run? How much more efficient could the core of SageTV be if we were to use a standard database, even something like SQLite or Mongo? I'm sure there are libraries already that can convert database objects to the Java objects that SageTV uses with little to no fuss. Yes, this would introduce necessary complexity. But it would also offload some of the maintenance of the database itself to a system specifically designed to store and manage data.

Not saying "let's do this". I know the Wizard is Jeff's baby. Just providing some perspective and food for thought.
I think the largest chunk of Wizard.java is likely detecting and repairing errors. In any case, I think that separating out 'live' and 'archived' data would make everything else far more complicated. You'd have to make dummy copies of every array that the wiz.bin contains, and have some way to move items in and out of them, while still providing the full contents on demand. At current memory prices, I can't see that ever really being worth it. The real advantage of keeping everything in java objects in the JVM is speed. Database lookups are very fast because of this, and because database lookups are so fast, much of the operations sage does with the database are coded for simplicity and robustness, and NOT for efficiency (repetetive iterations through an array, for instance). Slowing down those accesses is likely to cause a very noticeable slowdown on the end result. I don't believe a 90MB database, or even 256MB database size should be a problem, and the only real issue is that many people are now using a majority of miniclients instead of 'fat clients', so the JVM has been easily maxed in normal use, which i don't think was ever the design basis. This is an issue with the overall system architecture, not the database, so it should be fixed by changing the architecture. That's either going to a 64-bit JVM, or breaking out the MiniClientRenderer's to their own miniserver JVM's.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #19  
Old 10-02-2015, 09:07 AM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,514
Quote:
Originally Posted by dvd_maniac View Post
So whenever I record something or set something to watched it is going to stay in the wiz.bin forever?

I give up...
I'm ditching my wiz.bin and starting fresh.
The only thing that sucks is that I have a couple of odl classic favorite TV shows that I'm trying to get and now it will end up recording the ones I already have again.
No biggie...
Before you do that, have you checked out my SQL DB converter? I could get to work on the exporter back to wiz.bin if someone really needs it. . Then you could clean whatever you want.

http://forums.sagetv.com/forums/showthread.php?t=62512
Reply With Quote
  #20  
Old 10-02-2015, 09:12 AM
stanger89's Avatar
stanger89 stanger89 is offline
SageTVaholic
 
Join Date: May 2003
Location: Marion, IA
Posts: 15,188
Quote:
Originally Posted by dvd_maniac View Post
So whenever I record something or set something to watched it is going to stay in the wiz.bin forever?

I give up...
I'm ditching my wiz.bin and starting fresh.
Why? Are you having a problem? The only problems I've every had with Sage were not related to the database, they were always related to orphan files that no longer existed.

FWIW, since the beginning I've seen lots of people wanting to "improve" the Sage database, but rarely, if ever, have I seen anyone provide evidence of an actual problem with Sage's current database, performance or otherwise. It all seems largely academic/philosophical, people assume because it's not a standard format it's not good or something.

FWIW2, 80MB is nothing these days, I've got 80MB pictures.

Last edited by stanger89; 10-02-2015 at 09:15 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Limit to Day - V7 Improvements? bellyman SageTV Software 10 09-27-2011 04:34 PM
EPG Thread : Questions, Improvements, etc bialio Phoenix 2 06-26-2011 05:55 AM
Improvements needed for Sage TV HD Flash2k6 SageTV HD Theater - Media Player 7 12-04-2009 07:03 PM
Clear QAM Improvements to HVR-1600 bcjenkins SageTV Linux 1 11-14-2009 09:13 AM
general improvements loomdog32 SageMC Custom Interface 0 12-25-2008 10:30 PM


All times are GMT -6. The time now is 02:14 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.