]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/NavDataCache.cxx
Bug #1166, slow POI parsing.
[flightgear.git] / src / Navaids / NavDataCache.cxx
index db6c3b6ca466616bdf81b7399491f6321dcf96c3..2d44a88053dd4ce23e562d7e2d54c58d04f50dfb 100644 (file)
@@ -74,7 +74,7 @@ namespace {
 
 const int MAX_RETRIES = 10;
 const int SCHEMA_VERSION = 8;
-const int CACHE_SIZE_KBYTES= 16000;
+const int CACHE_SIZE_KBYTES= 32 * 1024;
     
 // bind a std::string to a sqlite statement. The std::string must live the
 // entire duration of the statement execution - do not pass a temporary
@@ -1065,7 +1065,6 @@ FGPositioned* NavDataCache::NavDataCachePrivate::loadById(sqlite3_int64 rowid)
       if (aptId > 0) {
         FGAirport* apt = FGPositioned::loadById<FGAirport>(aptId);
         if (apt->validateILSData()) {
-          SG_LOG(SG_NAVCACHE, SG_INFO, "re-loaded ILS data for " << apt->ident());
           // queried data above is probably invalid, force us to go around again
           // (the next time through, validateILSData will return false)
           return outer->loadById(rowid);
@@ -1173,7 +1172,6 @@ NavDataCache::~NavDataCache()
 {
   assert(static_instance == this);
   static_instance = NULL;
-  SG_LOG(SG_NAVCACHE, SG_INFO, "closing the navcache");
   d.reset();
 }
     
@@ -1229,55 +1227,76 @@ void NavDataCache::doRebuild()
   try {
     d->close(); // completely close the sqlite object
     d->path.remove(); // remove the file on disk
-    d->init(); // star again from scratch
+    d->init(); // start again from scratch
     
-    Transaction txn(this);
-  // initialise the root octree node
+    // initialise the root octree node
     d->runSQL("INSERT INTO octree (rowid, children) VALUES (1, 0)");
-    
+      
     SGTimeStamp st;
-    st.stamp();
-    
-    airportDBLoad(d->aptDatPath);
-    SG_LOG(SG_NAVCACHE, SG_INFO, "apt.dat load took:" << st.elapsedMSec());
-    
-    metarDataLoad(d->metarDatPath);
-    stampCacheFile(d->aptDatPath);
-    stampCacheFile(d->metarDatPath);
-    
-    st.stamp();
-    loadFixes(d->fixDatPath);
-    stampCacheFile(d->fixDatPath);
-    SG_LOG(SG_NAVCACHE, SG_INFO, "fix.dat load took:" << st.elapsedMSec());
-    
-    st.stamp();
-    navDBInit(d->navDatPath);
-    stampCacheFile(d->navDatPath);
-    SG_LOG(SG_NAVCACHE, SG_INFO, "nav.dat load took:" << st.elapsedMSec());
-
+    {
+        Transaction txn(this);
+      
+        st.stamp();
+        airportDBLoad(d->aptDatPath);
+        SG_LOG(SG_NAVCACHE, SG_INFO, "apt.dat load took:" << st.elapsedMSec());
+        
+        metarDataLoad(d->metarDatPath);
+        stampCacheFile(d->aptDatPath);
+        stampCacheFile(d->metarDatPath);
+        
+        st.stamp();
+        loadFixes(d->fixDatPath);
+        stampCacheFile(d->fixDatPath);
+        SG_LOG(SG_NAVCACHE, SG_INFO, "fix.dat load took:" << st.elapsedMSec());
+        
+        st.stamp();
+        navDBInit(d->navDatPath);
+        stampCacheFile(d->navDatPath);
+        SG_LOG(SG_NAVCACHE, SG_INFO, "nav.dat load took:" << st.elapsedMSec());
+        
+        st.stamp();
+        txn.commit();
+        SG_LOG(SG_NAVCACHE, SG_INFO, "stage 1 commit took:" << st.elapsedMSec());
+    }
+      
 #ifdef SG_WINDOWS
-    SG_LOG(SG_NAVCACHE, SG_ALERT, "SKIPPING POI load on Windows");
+      SG_LOG(SG_NAVCACHE, SG_ALERT, "SKIPPING POI load on Windows");
 #else
-    st.stamp();
-    poiDBInit(d->poiDatPath);
-    stampCacheFile(d->poiDatPath);
-    SG_LOG(SG_NAVCACHE, SG_INFO, "poi.dat load took:" << st.elapsedMSec());
+      {
+          Transaction txn(this);
+          
+          st.stamp();
+          poiDBInit(d->poiDatPath);
+          stampCacheFile(d->poiDatPath);
+          SG_LOG(SG_NAVCACHE, SG_INFO, "poi.dat load took:" << st.elapsedMSec());
+          
+          st.stamp();
+          txn.commit();
+          SG_LOG(SG_NAVCACHE, SG_INFO, "POI commit took:" << st.elapsedMSec());
+      }
 #endif
       
-    loadCarrierNav(d->carrierDatPath);
-    stampCacheFile(d->carrierDatPath);
-    
-    st.stamp();
-    Airway::load(d->airwayDatPath);
-    stampCacheFile(d->airwayDatPath);
-    SG_LOG(SG_NAVCACHE, SG_INFO, "awy.dat load took:" << st.elapsedMSec());
-    
-    d->flushDeferredOctreeUpdates();
-    
-    string sceneryPaths = simgear::strutils::join(globals->get_fg_scenery(), ";");
-    writeStringProperty("scenery_paths", sceneryPaths);
-    
-    txn.commit();
+      {
+          Transaction txn(this);
+          loadCarrierNav(d->carrierDatPath);
+          stampCacheFile(d->carrierDatPath);
+          
+          st.stamp();
+          Airway::load(d->airwayDatPath);
+          stampCacheFile(d->airwayDatPath);
+          SG_LOG(SG_NAVCACHE, SG_INFO, "awy.dat load took:" << st.elapsedMSec());
+          
+          d->flushDeferredOctreeUpdates();
+          
+          string sceneryPaths = simgear::strutils::join(globals->get_fg_scenery(), ";");
+          writeStringProperty("scenery_paths", sceneryPaths);
+          
+          st.stamp();
+          txn.commit();
+          SG_LOG(SG_NAVCACHE, SG_INFO, "final commit took:" << st.elapsedMSec());
+
+      }
+
   } catch (sg_exception& e) {
     SG_LOG(SG_NAVCACHE, SG_ALERT, "caught exception rebuilding navCache:" << e.what());
   }
@@ -1390,13 +1409,6 @@ bool NavDataCache::isCachedFileModified(const SGPath& path) const
     if (delta != 0)
     {
       SG_LOG(SG_NAVCACHE, SG_DEBUG, "NavCache: rebuild required for " << path << ". Timestamps: " << modtime << " != " << path.modTime());
-      if (delta < 30)
-      {
-          // File system time stamp has slightly changed. It's unlikely that the user has managed to change a file, start fgfs,
-          // and then changed file again within x seconds - so it's suspicious...
-          SG_LOG(SG_NAVCACHE, SG_ALERT, "NavCache: suspicious file timestamp change. Please report this to FlightGear. "
-                  << "Delta: " << delta << ", Timestamps: " << modtime << ", " << path.modTime() << ", path: " << path);
-      }
     }
     else
     {