Changeset 9004 in josm for trunk/src/org


Ignore:
Timestamp:
2015-11-14T11:43:02+01:00 (4 years ago)
Author:
wiktorn
Message:

Fix high CPU usage when showing small tiles.

  • AbstractTileSourceLayer - check insane() zoom level based on TileCache size instead of hardcoded value
  • TileCache - add interface to check size of the cache
  • TMSCachedTileLoader - remove unnnecessary TileCache interface and its methods
  • HostLimitQueue - correct log message
  • JCSCachedTileLoaderJob - add debug logs for putting request into queue and start of processing
Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/cache/HostLimitQueue.java

    r8783 r9004  
    5454                        return job;
    5555                    } else {
    56                         // we have acquired the semaphore, but we didn't manage to remove it, as someone else did
     56                        // we have acquired the semaphore, but we didn't manage to remove job, as someone else did
    5757                        // release the semaphore and look for another candidate
    5858                        releaseSemaphore(job);
     
    6767                        }
    6868                    }
    69                     Main.debug("TMS - Queuing job {0} because host limit reached", url);
     69                    Main.debug("TMS - Skipping job {0} because host limit reached", url);
    7070                }
    7171            }
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java

    r8840 r9004  
    174174        if (first || force) {
    175175            // submit all jobs to separate thread, so calling thread is not blocked with IO when loading from disk
     176            log.log(Level.FINE, "JCS - Submitting job for execution for url: {0}", getUrlNoException());
    176177            downloadJobExecutor.execute(this);
    177178        }
     
    221222        final String oldName = currentThread.getName();
    222223        currentThread.setName("JCS Downloading: " + getUrlNoException());
     224        log.log(Level.FINE, "JCS - starting fetch of url: {0} ", getUrlNoException());
    223225        ensureCacheElement();
    224226        try {
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoader.java

    r8846 r9004  
    1010import org.openstreetmap.gui.jmapviewer.Tile;
    1111import org.openstreetmap.gui.jmapviewer.interfaces.CachedTileLoader;
    12 import org.openstreetmap.gui.jmapviewer.interfaces.TileCache;
    1312import org.openstreetmap.gui.jmapviewer.interfaces.TileJob;
    1413import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader;
     
    2625 *
    2726 */
    28 public class TMSCachedTileLoader implements TileLoader, CachedTileLoader, TileCache {
     27public class TMSCachedTileLoader implements TileLoader, CachedTileLoader {
    2928
    3029    protected final ICacheAccess<String, BufferedImageCacheEntry> cache;
     
    108107    }
    109108
    110     @Override
    111     public Tile getTile(TileSource source, int x, int y, int z) {
    112         return createTileLoaderJob(new Tile(source, x, y, z)).getTile();
    113     }
    114 
    115     @Override
    116     public void addTile(Tile tile) {
    117         createTileLoaderJob(tile).getTile();
    118     }
    119 
    120     @Override
    121     public int getTileCount() {
    122         return 0;
    123     }
    124 
    125     @Override
    126     public void clear() {
    127         cache.clear();
    128     }
    129 
    130109    /**
    131110     * @return cache statistics as string
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r8864 r9004  
    12151215
    12161216        private boolean tooLarge() {
    1217             return this.tilesSpanned() > 20;
     1217            return insane() || this.tilesSpanned() > 20;
    12181218        }
    12191219
    12201220        private boolean insane() {
    1221             return this.tilesSpanned() > 100;
     1221            return size() > tileCache.getCacheSize();
    12221222        }
    12231223
Note: See TracChangeset for help on using the changeset viewer.