BAM file caching bug

Return to General Discussion

BAM file caching bug

Postby Sam » Wed May 02, 2012 10:37 pm

This is with release 1.8.0.

We do some of our own caching, where we explicitly write out bam file (and reload it on subsequent runs). It appears that when loading a bam file, panda immediately writes out a copy to its cache directory.

I haven't fully debugged it yet, but it appears that Loader::try_load_file is calling cache->store incorrectly under some circumstances.

Before I dig too much deeper into panda's loading/caching behavior, does any of this ring any bells with anyone?

Code: Select all
PT(PandaNode) Loader::
try_load_file(const Filename &pathname, const LoaderOptions &options,
              LoaderFileType *requested_type) const {
  BamCache *cache = BamCache::get_global_ptr();

  bool cache_only = (options.get_flags() & LoaderOptions::LF_cache_only) != 0;

  if (requested_type->get_allow_ram_cache(options)) {
    // If we're allowing a RAM cache, use the ModelPool to load the
    // file.
    if (!cache_only || ModelPool::has_model(pathname)) {
      PT(PandaNode) node = ModelPool::load_model(pathname, options);
      if (node != (PandaNode *)NULL &&
          (options.get_flags() & LoaderOptions::LF_allow_instance) == 0) {
        // But return a deep copy of the shared model.
        node = node->copy_subgraph();
      }
      return node;
    }
  }

  bool report_errors = (options.get_flags() & LoaderOptions::LF_report_errors) != 0;

  PT(BamCacheRecord) record;
  if (cache->get_cache_models() && requested_type->get_allow_disk_cache(options)) {
    // See if the model can be found in the on-disk cache, if it is
    // active.
    record = cache->lookup(pathname, "bam");
    if (record != (BamCacheRecord *)NULL) {
      if (record->has_data()) {
        if (report_errors) {
          loader_cat.info()
            << "Model " << pathname << " found in disk cache.\n";
        }
        PT(PandaNode) result = DCAST(PandaNode, record->get_data());
        if (premunge_data) {
          SceneGraphReducer sgr;
          sgr.premunge(result, RenderState::make_empty());
        }
        return result;
      }
    }
  }
 
  if (!cache_only) {
    PT(PandaNode) result = requested_type->load_file(pathname, options, record);
    if (result != (PandaNode *)NULL){
      if (record != (BamCacheRecord *)NULL) {
        record->set_data(result, result);
        cache->store(record);
      }
     
      if (premunge_data) {
        SceneGraphReducer sgr;
        sgr.premunge(result, RenderState::make_empty());
      }
      return result;
    }
  }
Sam
 
Posts: 19
Joined: Tue Mar 09, 2010 3:11 pm
Location: LA, CA

Postby drwr » Mon May 07, 2012 1:28 pm

It sounds like the intended behavior so far. The cache directory is intended to be a local cache of bam files (which might have been loaded from some slower media than the local cache directory).

It would be a bug if the cache file it is writing out is incorrect. Is that the case?

David
drwr
 
Posts: 11253
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby Sam » Mon May 07, 2012 5:06 pm

OK, turns out the explanation for the behavior I was seeing is that I was overflowing the 1GB default cache size, causing it to rewrite the cache on every run.
Sam
 
Posts: 19
Joined: Tue Mar 09, 2010 3:11 pm
Location: LA, CA


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests