| 184 | | // Make sure we preload the next step once we get past the length |
| 185 | | // here. This is just some testing, don't include this with the |
| 186 | | // release. (Yet) |
| 187 | | // if (m_peerChunks.upload_throttle()->rate()->rate() >= 10 << 10) |
| 188 | | // m_upChunk.chunk()->preload(m_upPiece.offset(), m_upChunk.chunk()->size()); |
| 189 | | // m_upChunk.chunk()->preload(m_upPiece.offset(), std::min(128u << 10, m_peerChunks.upload_throttle()->rate()->rate() * 10)); |
| | 185 | // Also check if we've already preloaded in the recent past, even |
| | 186 | // past unmaps. |
| | 187 | ChunkManager* cm = manager->chunk_manager(); |
| | 188 | |
| | 189 | if (cm->preload_min_pipelined() == 0 || |
| | 190 | m_upChunk.object()->time_preloaded() >= cachedTime - rak::timer::from_seconds(60)) |
| | 191 | return; |
| | 192 | |
| | 193 | uint32_t preloadSize = m_upPiece.offset() < cm->preload_min_size(); |
| | 194 | |
| | 195 | if (preloadSize < cm->preload_min_size() || |
| | 196 | m_peerChunks.upload_throttle()->rate()->rate() < cm->preload_required_rate() * (preloadSize + (2 << 20) - 1) / (2 << 20)) |
| | 197 | return; |
| | 198 | |
| | 199 | m_upChunk.chunk()->preload(m_upPiece.offset(), m_upChunk.chunk()->chunk_size()); |