Skip to content

Commit

Permalink
Merge pull request #235 from podusowski/use-max-parallel-dls-as-chann…
Browse files Browse the repository at this point in the history
…el-size

use MAX_PARALLEL_DOWNLOADS as channel size
  • Loading branch information
podusowski authored Nov 24, 2024
2 parents fd722c0 + e0fc35b commit a1588e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## Unreleased

* Tile download optimized by no longer queueing older requests.

## 0.30.0

* Add option for changing the zoom speed
Expand Down
2 changes: 1 addition & 1 deletion walkers/src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async fn download_complete(

/// Maximum number of parallel downloads. Following modern browsers' behavior.
/// https://stackoverflow.com/questions/985431/max-parallel-http-connections-in-a-browser
const MAX_PARALLEL_DOWNLOADS: usize = 6;
pub(crate) const MAX_PARALLEL_DOWNLOADS: usize = 6;

async fn download_continuously_impl<S>(
source: S,
Expand Down
6 changes: 3 additions & 3 deletions walkers/src/tiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use futures::channel::mpsc::{channel, Receiver, Sender};
use image::ImageError;
use lru::LruCache;

use crate::download::{download_continuously, HttpOptions};
use crate::download::{download_continuously, HttpOptions, MAX_PARALLEL_DOWNLOADS};
use crate::io::Runtime;
use crate::mercator::TileId;
use crate::sources::{Attribution, TileSource};
Expand Down Expand Up @@ -104,8 +104,8 @@ impl HttpTiles {
where
S: TileSource + Send + 'static,
{
// Minimum value which didn't cause any stalls while testing.
let channel_size = 20;
// This ensures that newer requests are prioritized.
let channel_size = MAX_PARALLEL_DOWNLOADS;

let (request_tx, request_rx) = channel(channel_size);
let (tile_tx, tile_rx) = channel(channel_size);
Expand Down

0 comments on commit a1588e3

Please sign in to comment.