kt线程和分片优化

This commit is contained in:
lushunming 2025-07-14 08:05:14 +08:00
parent c7752dc1be
commit da70913280
4 changed files with 11 additions and 11 deletions

View File

@ -65,13 +65,13 @@ object DownloadMT {
return proxy(url, headers) return proxy(url, headers)
} else if (total.toLong() < 1024 * 1024 * 1024L * 10L) { } else if (total.toLong() < 1024 * 1024 * 1024L * 10L) {
//10GB以下 //10GB以下
threadNum = CORE_NUM * 4 threadNum = CORE_NUM * 3
} else if (total.toLong() < 1024 * 1024 * 1024L * 40L) { } else if (total.toLong() < 1024 * 1024 * 1024L * 40L) {
//40GB以下 //40GB以下
threadNum = CORE_NUM * 8 threadNum = CORE_NUM * 4
} else { } else {
//40GB以上 //40GB以上
threadNum = CORE_NUM * 16 threadNum = CORE_NUM * 5
} }
var range = var range =
if (StringUtils.isAllBlank(headers["range"])) headers["Range"] else headers["range"] if (StringUtils.isAllBlank(headers["range"])) headers["Range"] else headers["range"]
@ -80,8 +80,11 @@ object DownloadMT {
val rangeObj = parseRange( val rangeObj = parseRange(
range!! range!!
) )
//没有range,无需分割
//视频开始,加大线程数
if (rangeObj["start"]!!.toLong() == 0L) {
threadNum = CORE_NUM * 4
}
val partList = generatePart(rangeObj, total, threadNum) val partList = generatePart(rangeObj, total, threadNum)
// 存储执行结果的List // 存储执行结果的List
@ -186,12 +189,9 @@ object DownloadMT {
if (totalSize < 1024 * 1024 * 1024L * 10L) { if (totalSize < 1024 * 1024 * 1024L * 10L) {
//10GB以下分片8MB //10GB以下分片8MB
partSize = 1024 * 1024 * 8L partSize = 1024 * 1024 * 8L
} else if (totalSize < 1024 * 1024 * 1024L * 40L) {
//40GB以下分片32MB
partSize = 1024 * 1024 * 8L * 4
} else { } else {
//40GB以分片128MB //40GB以下分片64MB
partSize = 1024 * 1024 * 8L * 4 * 4 partSize = 1024 * 1024 * 8L * 8
} }
var start = rangeObj["start"]!!.toLong() var start = rangeObj["start"]!!.toLong()

Binary file not shown.

View File

@ -1 +1 @@
a926c6e48bbffc73be39e17fcc6650a1 693338eb7794c8953b3fd0a8bed3a855

View File

@ -1,5 +1,5 @@
{ {
"spider": "https://ghproxy.net/https://raw.githubusercontent.com/lushunming/AndroidCatVodSpider/multiThreadkt/jar/custom_spider.jar;md5;a926c6e48bbffc73be39e17fcc6650a1", "spider": "https://ghproxy.net/https://raw.githubusercontent.com/lushunming/AndroidCatVodSpider/multiThreadkt/jar/custom_spider.jar;md5;693338eb7794c8953b3fd0a8bed3a855",
"lives": [ "lives": [
{ {
"name": "电视直播", "name": "电视直播",