Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU bottlneck when downloading at very high speeds #620

Open
baryluk opened this issue Nov 11, 2023 · 4 comments
Open

CPU bottlneck when downloading at very high speeds #620

baryluk opened this issue Nov 11, 2023 · 4 comments

Comments

@baryluk
Copy link
Contributor

baryluk commented Nov 11, 2023

Platform

Operating system and version: Linux 6.6, amd64
Legendary version (legendary -V):

Software Versions:
  Heroic: 2.10.0 Jewelry Bonney
  Legendary: 0.20.33 Undue Alarm
  gogdl: 0.7.3
  Nile: 1.0.0 Jonathan Joestar

First world problem, but I noticed that there is CPU bottlneck when downloading big games on very fast network connection.

Games can be big, and often are the biggest monolithic download one would be downloading.

Example here, downloading 90GB of Alan Wake 2.

My educated guess is that the issue is in OpenSSL. More on that later.

I cannot get more than about 850MB/s per second download.

(11:08:07) INFO:    [Backend]:          Finished uninstalling
(11:08:07) INFO:    [Frontend]:         Refreshing legendary Library
(11:08:07) INFO:    [Legendary]:        Refreshing library...
(11:08:07) INFO:    [Legendary]:        Refreshing Epic Games...
(11:08:07) INFO:    [Legendary]:        Game list updated, got 1 games & DLCs
(11:08:07) INFO:    [Backend]:          Desktop shortcut removed
(11:08:07) INFO:    [Backend]:          Applications shortcut removed
(11:08:07) DEBUG:   [Legendary]:        Using cached install info
(11:08:07) DEBUG:   [Legendary]:        Using cached install info
(11:08:07) DEBUG:   [Legendary]:        Using cached install info
(11:08:07) DEBUG:   [Legendary]:        Using cached install info
(11:08:07) DEBUG:   [Legendary]:        Using cached install info
(11:08:07) INFO:    [Legendary]:        Running command: LEGENDARY_CONFIG_PATH=/home/user/.config/heroic/legendaryConfig/legendary /home/user/heroic/heroic-2.10.0/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
(11:08:09) DEBUG:   [Legendary]:        Using cached install info
(11:08:09) DEBUG:   [Backend]:          Unable to load Steam Libraries, libraryfolders.vdf not found
(11:08:10) DEBUG:   [Backend]:          {"free":118756048896,"diskSize":135081836544,"message":"110.6 GiB / 125.8 GiB","validPath":true,"validFlatpakPath":true}
(11:08:10) DEBUG:   [Backend]:          {"free":118756048896,"diskSize":135081836544,"message":"110.6 GiB / 125.8 GiB","validPath":true,"validFlatpakPath":true}
(11:08:18) INFO:    [Backend]:          Writing config for dc9d2e595d0e4650b35d659f90d41059
(11:08:18) INFO:    [Backend]:          Changed config: wrapperOptions from [{"exe":"/home/user/mesa-opt","args":""}] to []
(11:08:18) INFO:    [Backend]:          Changed config: savesPath from  to undefined
(11:08:18) INFO:    [Backend]:          Changed config: useGameMode from true to false
(11:08:18) DEBUG:   [Legendary]:        Using cached install info
(11:08:18) INFO:    [DownloadManager]:  Alan Wake 2  was added to the download queue.
(11:08:18) INFO:    [Backend]:          Preventing machine to sleep
(11:08:18) DEBUG:   [Legendary]:        Using cached install info
(11:08:18) DEBUG:   [Legendary]:        Using cached install info
(11:08:18) DEBUG:   [Legendary]:        Using cached install info
(11:08:18) INFO:    [Legendary]:        Installing dc9d2e595d0e4650b35d659f90d41059: LEGENDARY_CONFIG_PATH=/home/user/.config/heroic/legendaryConfig/legendary /home/user/heroic/heroic-2.10.0/resources/app.asar.unpacked/build/bin/linux/legendary install dc9d2e595d0e4650b35d659f90d41059 --platform Windows --base-path /home/user/Games/Heroic --skip-dlcs -y --skip-sdl
(11:08:18) DEBUG:   [Legendary]:        Logging to file "/home/user/.config/heroic/GamesConfig/dc9d2e595d0e4650b35d659f90d41059.log"
(11:08:18) DEBUG:   [Legendary]:        Using cached install info
(11:08:18) DEBUG:   [Legendary]:        Using cached install info
(11:08:22) INFO:    [Legendary]:        Progress for Alan Wake 2: 0%/0.00MB/00:00:00 Down: 420.57MB/s / Disk: 486.5MB/s
(11:08:23) INFO:    [Legendary]:        Progress for Alan Wake 2: 0.96%/750.08MB/00:02:51 Down: 328.03MB/s / Disk: 332.07MB/s
(11:08:24) INFO:    [Legendary]:        Progress for Alan Wake 2: 1.37%/1070.13MB/00:03:09 Down: 319.54MB/s / Disk: 335.42MB/s
(11:08:25) INFO:    [Legendary]:        Progress for Alan Wake 2: 1.81%/1417.63MB/00:03:17 Down: 346.95MB/s / Disk: 363.29MB/s
(11:08:26) INFO:    [Legendary]:        Progress for Alan Wake 2: 2.22%/1740.61MB/00:03:20 Down: 322.46MB/s / Disk: 344.88MB/s
(11:08:27) INFO:    [Legendary]:        Progress for Alan Wake 2: 2.74%/2144.10MB/00:03:18 Down: 402.8MB/s / Disk: 443.25MB/s
(11:08:28) INFO:    [Legendary]:        Progress for Alan Wake 2: 3.58%/2802.26MB/00:02:57 Down: 657.31MB/s / Disk: 730.41MB/s
(11:08:29) INFO:    [Legendary]:        Progress for Alan Wake 2: 4.5%/3525.08MB/00:02:37 Down: 722.11MB/s / Disk: 801.06MB/s
(11:08:30) INFO:    [Legendary]:        Progress for Alan Wake 2: 5.45%/4269.63MB/00:02:24 Down: 743.27MB/s / Disk: 766.1MB/s
(11:08:31) INFO:    [Legendary]:        Progress for Alan Wake 2: 6.34%/4967.49MB/00:02:14 Down: 696.76MB/s / Disk: 827.03MB/s
(11:08:32) INFO:    [Legendary]:        Progress for Alan Wake 2: 7.13%/5590.99MB/00:02:08 Down: 623.07MB/s / Disk: 841.04MB/s
(11:08:33) INFO:    [Legendary]:        Progress for Alan Wake 2: 7.96%/6237.28MB/00:02:03 Down: 645.27MB/s / Disk: 837.86MB/s
(11:08:34) INFO:    [Legendary]:        Progress for Alan Wake 2: 8.85%/6938.16MB/00:01:59 Down: 699.86MB/s / Disk: 808.48MB/s
(11:08:35) INFO:    [Legendary]:        Progress for Alan Wake 2: 9.73%/7628.61MB/00:01:55 Down: 689.52MB/s / Disk: 789.19MB/s
(11:08:36) INFO:    [Legendary]:        Progress for Alan Wake 2: 10.63%/8332.28MB/00:01:52 Down: 703.1MB/s / Disk: 808.15MB/s
(11:08:37) INFO:    [Legendary]:        Progress for Alan Wake 2: 11.5%/9010.55MB/00:01:50 Down: 676.39MB/s / Disk: 753.57MB/s
(11:08:38) INFO:    [Legendary]:        Progress for Alan Wake 2: 12.38%/9703.38MB/00:01:48 Down: 692.19MB/s / Disk: 772.67MB/s
(11:08:39) INFO:    [Legendary]:        Progress for Alan Wake 2: 13.23%/10367.70MB/00:01:46 Down: 663.65MB/s / Disk: 765.61MB/s
(11:08:40) INFO:    [Legendary]:        Progress for Alan Wake 2: 13.94%/10928.24MB/00:01:45 Down: 559.68MB/s / Disk: 659.95MB/s
(11:08:41) INFO:    [Legendary]:        Progress for Alan Wake 2: 14.59%/11436.86MB/00:01:45 Down: 507.87MB/s / Disk: 529.76MB/s
(11:08:42) INFO:    [Legendary]:        Progress for Alan Wake 2: 15.48%/12132.89MB/00:01:47 Down: 694.83MB/s / Disk: 412.79MB/s
(11:08:43) INFO:    [Legendary]:        Progress for Alan Wake 2: 16.23%/12723.78MB/00:01:52 Down: 589.91MB/s / Disk: 0MB/s
(11:08:44) INFO:    [Legendary]:        Progress for Alan Wake 2: 17.16%/13449.68MB/00:01:50 Down: 724.3MB/s / Disk: 744.52MB/s
(11:08:45) INFO:    [Legendary]:        Progress for Alan Wake 2: 18.11%/14196.79MB/00:01:44 Down: 746.13MB/s / Disk: 1232.33MB/s
(11:08:46) INFO:    [Legendary]:        Progress for Alan Wake 2: 19.04%/14926.19MB/00:01:39 Down: 728.38MB/s / Disk: 1306.88MB/s
(11:08:47) INFO:    [Legendary]:        Progress for Alan Wake 2: 19.94%/15626.18MB/00:01:37 Down: 698.89MB/s / Disk: 856.51MB/s
(11:08:48) INFO:    [Legendary]:        Progress for Alan Wake 2: 20.76%/16270.28MB/00:01:40 Down: 643.17MB/s / Disk: 0MB/s
(11:08:49) INFO:    [Legendary]:        Progress for Alan Wake 2: 21.67%/16987.81MB/00:01:39 Down: 716.43MB/s / Disk: 675.29MB/s
(11:08:50) INFO:    [Legendary]:        Progress for Alan Wake 2: 22.64%/17746.89MB/00:01:34 Down: 757.94MB/s / Disk: 1318.76MB/s
(11:08:51) INFO:    [Legendary]:        Progress for Alan Wake 2: 23.55%/18454.49MB/00:01:29 Down: 706.51MB/s / Disk: 1368.84MB/s
(11:08:52) INFO:    [Legendary]:        Progress for Alan Wake 2: 24.57%/19256.22MB/00:01:28 Down: 800.51MB/s / Disk: 906.77MB/s
(11:08:53) INFO:    [Legendary]:        Progress for Alan Wake 2: 25.54%/20020.08MB/00:01:26 Down: 762.81MB/s / Disk: 860.09MB/s
(11:08:54) INFO:    [Legendary]:        Progress for Alan Wake 2: 26.6%/20847.44MB/00:01:25 Down: 826.4MB/s / Disk: 834.95MB/s
(11:08:55) INFO:    [Legendary]:        Progress for Alan Wake 2: 27.57%/21607.88MB/00:01:26 Down: 759.65MB/s / Disk: 277.83MB/s
(11:08:56) INFO:    [Legendary]:        Progress for Alan Wake 2: 28.43%/22285.34MB/00:01:28 Down: 675.7MB/s / Disk: 1.99MB/s
(11:08:57) INFO:    [Legendary]:        Progress for Alan Wake 2: 29.4%/23041.42MB/00:01:25 Down: 755.06MB/s / Disk: 1377.09MB/s
(11:08:58) INFO:    [Legendary]:        Progress for Alan Wake 2: 30.29%/23740.64MB/00:01:24 Down: 698.62MB/s / Disk: 591.07MB/s
(11:08:59) INFO:    [Legendary]:        Progress for Alan Wake 2: 31.3%/24529.04MB/00:01:21 Down: 787.34MB/s / Disk: 1338.15MB/s
(11:09:00) INFO:    [Legendary]:        Progress for Alan Wake 2: 32.33%/25343.17MB/00:01:19 Down: 812.71MB/s / Disk: 1037.16MB/s
(11:09:01) INFO:    [Legendary]:        Progress for Alan Wake 2: 33.33%/26125.07MB/00:01:17 Down: 780.67MB/s / Disk: 1057.63MB/s
(11:09:02) INFO:    [Legendary]:        Progress for Alan Wake 2: 34.4%/26962.80MB/00:01:15 Down: 836.58MB/s / Disk: 871.11MB/s
(11:09:03) INFO:    [Legendary]:        Progress for Alan Wake 2: 35.48%/27809.24MB/00:01:14 Down: 845.49MB/s / Disk: 813.76MB/s
(11:09:04) INFO:    [Legendary]:        Progress for Alan Wake 2: 36.53%/28633.66MB/00:01:13 Down: 823MB/s / Disk: 897.52MB/s
(11:09:05) INFO:    [Legendary]:        Progress for Alan Wake 2: 37.49%/29384.20MB/00:01:12 Down: 749.54MB/s / Disk: 787.58MB/s
(11:09:06) INFO:    [Legendary]:        Progress for Alan Wake 2: 38.44%/30124.78MB/00:01:11 Down: 739.81MB/s / Disk: 701.99MB/s
(11:09:07) INFO:    [Legendary]:        Progress for Alan Wake 2: 39.35%/30841.05MB/00:01:10 Down: 715.29MB/s / Disk: 820.25MB/s
(11:09:08) INFO:    [Legendary]:        Progress for Alan Wake 2: 40.37%/31637.97MB/00:01:07 Down: 795.42MB/s / Disk: 1222.24MB/s
(11:09:09) INFO:    [Legendary]:        Progress for Alan Wake 2: 41.32%/32383.19MB/00:01:05 Down: 744.13MB/s / Disk: 1126.2MB/s
(11:09:10) INFO:    [Legendary]:        Progress for Alan Wake 2: 42.19%/33067.41MB/00:01:04 Down: 683.64MB/s / Disk: 816.77MB/s
(11:09:11) INFO:    [Legendary]:        Progress for Alan Wake 2: 43.05%/33740.44MB/00:01:03 Down: 672.33MB/s / Disk: 799.5MB/s
(11:09:12) INFO:    [Legendary]:        Progress for Alan Wake 2: 43.91%/34416.93MB/00:01:01 Down: 675.16MB/s / Disk: 813.77MB/s
(11:09:13) INFO:    [Legendary]:        Progress for Alan Wake 2: 44.76%/35083.16MB/00:01:00 Down: 665.02MB/s / Disk: 827.94MB/s
(11:09:14) INFO:    [Legendary]:        Progress for Alan Wake 2: 45.61%/35747.94MB/00:00:59 Down: 663.34MB/s / Disk: 795.64MB/s
(11:09:15) INFO:    [Legendary]:        Progress for Alan Wake 2: 46.56%/36496.34MB/00:00:58 Down: 747.7MB/s / Disk: 867.92MB/s
(11:09:16) INFO:    [Legendary]:        Progress for Alan Wake 2: 47.58%/37290.73MB/00:00:58 Down: 793.55MB/s / Disk: 284.46MB/s
Warning: terminator_CreateInstance: Failed to CreateInstance in ICD 4.  Skipping ICD.
(11:09:17) INFO:    [Legendary]:        Progress for Alan Wake 2: 48.55%/38048.61MB/00:00:59 Down: 756.45MB/s / Disk: 0MB/s
(11:09:18) INFO:    [Legendary]:        Progress for Alan Wake 2: 49.38%/38700.84MB/00:00:58 Down: 651.31MB/s / Disk: 669.86MB/s
(11:09:19) INFO:    [Legendary]:        Progress for Alan Wake 2: 50.18%/39333.45MB/00:00:55 Down: 631.97MB/s / Disk: 1309.46MB/s
(11:09:20) INFO:    [Legendary]:        Progress for Alan Wake 2: 50.99%/39963.53MB/00:00:53 Down: 628.99MB/s / Disk: 1176.64MB/s
(11:09:21) INFO:    [Legendary]:        Progress for Alan Wake 2: 51.93%/40699.36MB/00:00:51 Down: 734.82MB/s / Disk: 1241.82MB/s
(11:09:22) INFO:    [Legendary]:        Progress for Alan Wake 2: 52.81%/41391.08MB/00:00:49 Down: 690.59MB/s / Disk: 1084.88MB/s
(11:09:23) INFO:    [Legendary]:        Progress for Alan Wake 2: 53.72%/42102.99MB/00:00:48 Down: 711.35MB/s / Disk: 812.77MB/s
(11:09:24) INFO:    [Legendary]:        Progress for Alan Wake 2: 54.61%/42805.41MB/00:00:47 Down: 701.33MB/s / Disk: 752.25MB/s
(11:09:25) INFO:    [Legendary]:        Progress for Alan Wake 2: 55.55%/43536.56MB/00:00:46 Down: 729.64MB/s / Disk: 875.7MB/s
(11:09:26) INFO:    [Legendary]:        Progress for Alan Wake 2: 56.5%/44284.50MB/00:00:45 Down: 746.67MB/s / Disk: 892.89MB/s
(11:09:27) INFO:    [Legendary]:        Progress for Alan Wake 2: 57.45%/45025.15MB/00:00:43 Down: 739.39MB/s / Disk: 850.34MB/s
(11:09:28) INFO:    [Legendary]:        Progress for Alan Wake 2: 58.36%/45738.20MB/00:00:43 Down: 711.78MB/s / Disk: 727.35MB/s
(11:09:29) INFO:    [Legendary]:        Progress for Alan Wake 2: 58.96%/46208.94MB/00:00:42 Down: 470MB/s / Disk: 589.27MB/s
(11:09:30) INFO:    [Legendary]:        Progress for Alan Wake 2: 59.67%/46769.61MB/00:00:41 Down: 559.81MB/s / Disk: 645.17MB/s
(11:09:31) INFO:    [Legendary]:        Progress for Alan Wake 2: 60.59%/47491.50MB/00:00:40 Down: 721.17MB/s / Disk: 810.63MB/s
(11:09:32) INFO:    [Legendary]:        Progress for Alan Wake 2: 61.54%/48232.72MB/00:00:39 Down: 739.62MB/s / Disk: 846.45MB/s
(11:09:33) INFO:    [Legendary]:        Progress for Alan Wake 2: 62.46%/48954.32MB/00:00:38 Down: 720.4MB/s / Disk: 839.62MB/s
(11:09:34) INFO:    [Legendary]:        Progress for Alan Wake 2: 63.38%/49679.15MB/00:00:37 Down: 723.86MB/s / Disk: 829.16MB/s
(11:09:35) INFO:    [Legendary]:        Progress for Alan Wake 2: 64.33%/50421.66MB/00:00:36 Down: 741.97MB/s / Disk: 823.32MB/s
(11:09:36) INFO:    [Legendary]:        Progress for Alan Wake 2: 65.3%/51184.10MB/00:00:35 Down: 761.68MB/s / Disk: 871.7MB/s
(11:09:37) INFO:    [Legendary]:        Progress for Alan Wake 2: 66.27%/51940.49MB/00:00:34 Down: 755.63MB/s / Disk: 850.78MB/s
(11:09:38) INFO:    [Legendary]:        Progress for Alan Wake 2: 67.23%/52694.26MB/00:00:33 Down: 752.35MB/s / Disk: 855.39MB/s
(11:09:39) INFO:    [Legendary]:        Progress for Alan Wake 2: 68.21%/53460.48MB/00:00:32 Down: 765.39MB/s / Disk: 864.06MB/s
(11:09:40) INFO:    [Legendary]:        Progress for Alan Wake 2: 69.19%/54227.41MB/00:00:30 Down: 766.09MB/s / Disk: 836.53MB/s
(11:09:41) INFO:    [Legendary]:        Progress for Alan Wake 2: 70.19%/55013.10MB/00:00:29 Down: 785.01MB/s / Disk: 894.88MB/s
(11:09:42) INFO:    [Legendary]:        Progress for Alan Wake 2: 71.19%/55797.63MB/00:00:28 Down: 782.91MB/s / Disk: 795.69MB/s
(11:09:43) INFO:    [Legendary]:        Progress for Alan Wake 2: 72.15%/56553.03MB/00:00:27 Down: 754.28MB/s / Disk: 881.47MB/s
(11:09:44) INFO:    [Legendary]:        Progress for Alan Wake 2: 73.16%/57339.76MB/00:00:26 Down: 785.56MB/s / Disk: 839.32MB/s
(11:09:45) INFO:    [Legendary]:        Progress for Alan Wake 2: 74.23%/58179.83MB/00:00:25 Down: 839.31MB/s / Disk: 889.7MB/s
(11:09:46) INFO:    [Legendary]:        Progress for Alan Wake 2: 75.3%/59014.41MB/00:00:24 Down: 833.32MB/s / Disk: 823.54MB/s
(11:09:47) INFO:    [Legendary]:        Progress for Alan Wake 2: 76.44%/59914.30MB/00:00:23 Down: 894.66MB/s / Disk: 875.6MB/s
(11:09:48) INFO:    [Legendary]:        Progress for Alan Wake 2: 77.6%/60824.74MB/00:00:22 Down: 909.69MB/s / Disk: 974.06MB/s
(11:09:49) INFO:    [Legendary]:        Progress for Alan Wake 2: 78.69%/61672.01MB/00:00:21 Down: 845.89MB/s / Disk: 815.67MB/s
(11:09:50) INFO:    [Legendary]:        Progress for Alan Wake 2: 79.73%/62489.18MB/00:00:21 Down: 815.85MB/s / Disk: 376.39MB/s
(11:09:51) INFO:    [Legendary]:        Progress for Alan Wake 2: 80.73%/63274.25MB/00:00:21 Down: 783.8MB/s / Disk: 0MB/s
(11:09:52) INFO:    [Legendary]:        Progress for Alan Wake 2: 81.31%/63732.51MB/00:00:20 Down: 456.33MB/s / Disk: 640.29MB/s
(11:09:53) INFO:    [Legendary]:        Progress for Alan Wake 2: 82.35%/64547.21MB/00:00:18 Down: 813.03MB/s / Disk: 1338.27MB/s
(11:09:54) INFO:    [Legendary]:        Progress for Alan Wake 2: 83.42%/65378.70MB/00:00:17 Down: 831MB/s / Disk: 1328.21MB/s
(11:09:55) INFO:    [Legendary]:        Progress for Alan Wake 2: 84.43%/66172.52MB/00:00:16 Down: 792.39MB/s / Disk: 723.7MB/s
(11:09:56) INFO:    [Legendary]:        Progress for Alan Wake 2: 85.41%/66945.39MB/00:00:16 Down: 771.78MB/s / Disk: 0MB/s
(11:09:57) INFO:    [Legendary]:        Progress for Alan Wake 2: 86.35%/67678.89MB/00:00:15 Down: 732.19MB/s / Disk: 574.41MB/s
(11:09:58) INFO:    [Legendary]:        Progress for Alan Wake 2: 87.37%/68480.00MB/00:00:14 Down: 800.19MB/s / Disk: 1321.12MB/s
(11:09:59) INFO:    [Legendary]:        Progress for Alan Wake 2: 88.45%/69324.33MB/00:00:12 Down: 842.75MB/s / Disk: 1319.99MB/s
(11:10:00) INFO:    [Legendary]:        Progress for Alan Wake 2: 89.51%/70153.76MB/00:00:11 Down: 828.24MB/s / Disk: 943.62MB/s
(11:10:01) INFO:    [Legendary]:        Progress for Alan Wake 2: 90.53%/70958.14MB/00:00:10 Down: 803.23MB/s / Disk: 786.88MB/s
(11:10:02) INFO:    [Legendary]:        Progress for Alan Wake 2: 91.61%/71797.89MB/00:00:09 Down: 838.43MB/s / Disk: 785.77MB/s
(11:10:03) INFO:    [Legendary]:        Progress for Alan Wake 2: 92.7%/72652.53MB/00:00:08 Down: 853.47MB/s / Disk: 893.78MB/s
(11:10:04) INFO:    [Legendary]:        Progress for Alan Wake 2: 93.82%/73536.63MB/00:00:07 Down: 882.9MB/s / Disk: 732.54MB/s
(11:10:05) INFO:    [Legendary]:        Progress for Alan Wake 2: 94.9%/74380.62MB/00:00:06 Down: 843.45MB/s / Disk: 1028.35MB/s
(11:10:06) INFO:    [Legendary]:        Progress for Alan Wake 2: 95.62%/74943.31MB/00:00:05 Down: 562.13MB/s / Disk: 575.85MB/s
(11:10:07) INFO:    [Legendary]:        Progress for Alan Wake 2: 96.3%/75475.61MB/00:00:05 Down: 531.43MB/s / Disk: 523.14MB/s
(11:10:08) INFO:    [Legendary]:        Progress for Alan Wake 2: 97%/76026.73MB/00:00:04 Down: 550.11MB/s / Disk: 553.99MB/s
(11:10:09) INFO:    [Legendary]:        Progress for Alan Wake 2: 97.68%/76558.45MB/00:00:03 Down: 530.93MB/s / Disk: 558.74MB/s
(11:10:10) INFO:    [Legendary]:        Progress for Alan Wake 2: 98.27%/77024.56MB/00:00:03 Down: 465.61MB/s / Disk: 510.8MB/s
(11:10:11) INFO:    [Legendary]:        Progress for Alan Wake 2: 99.3%/77829.76MB/00:00:01 Down: 803.59MB/s / Disk: 949.34MB/s
(11:10:12) INFO:    [Legendary]:        Progress for Alan Wake 2: 100%/78377.38MB/00:00:00 Down: 546.78MB/s / Disk: 1373.53MB/s
(11:10:13) INFO:    [Legendary]:        Progress for Alan Wake 2: 100%/78377.38MB/00:00:00 Down: 0MB/s / Disk: 32.11MB/s
(11:10:14) INFO:    [Legendary]:        installed.json updated, refreshing library
(11:10:14) INFO:    [Legendary]:        installed.json updated, refreshing library
(11:10:14) INFO:    [Backend]:          Adding shortcuts for Alan Wake 2
(11:10:14) INFO:    [DownloadManager]:  Finished Installation of dc9d2e595d0e4650b35d659f90d41059
(11:10:14) INFO:    [DownloadManager]:  dc9d2e595d0e4650b35d659f90d41059 added to download manager finished.
(11:10:14) INFO:    [DownloadManager]:  dc9d2e595d0e4650b35d659f90d41059 removed from download manager.
(11:10:14) INFO:    [Frontend]:         Refreshing legendary Library
(11:10:14) INFO:    [Legendary]:        Refreshing library...
(11:10:14) INFO:    [Legendary]:        Refreshing Epic Games...
(11:10:14) INFO:    [Legendary]:        Game list updated, got 1 games & DLCs
(11:10:14) INFO:    [Backend]:          Stopping Power Saver Blocker
(11:10:14) INFO:    [Legendary]:        Running command: LEGENDARY_CONFIG_PATH=/home/user/.config/heroic/legendaryConfig/legendary /home/user/heroic/heroic-2.10.0/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party

While my Threadripper 2950X, 16 core CPU struggles.

I do think this is because of OpenSSL, because I do notice something I know OpenSSL is doing similarly when using handling TLS reads.

read(46, "\27\3\3@\21", 5)              = 5
read(46, "\211 8j!M\221%h\245 |\225\217\7\33\4\262\202}\266\267\204\270\321(\350U\310\220\322\210"..., 16401) = 16401
read(46, "\27\3\3@\21", 5)              = 5
read(46, "\347*E\356\310\267\236\303W\370lm\4\373\34\333\266\225\330\2761pB\243\230\374\255Z:Kj\255"..., 16401) = 16401
read(46, "\27\3\3@\21", 5)              = 5
read(46, "\224Y\251\336:\331\324\0010hT\213\225#\273\t,\214\320\222dBYt@\251\26\262\16\234O|"..., 16401) = 16401
read(46, "\27\3\3@\21", 5)              = 5
read(46, "u`{2.7\344/\v\277C\226\377+nM\32\363\22\210\302\273\265\3345\r\315\335c\237c\34"..., 16401) = 16401
read(46, "\27\3\3@\21", 5)              = 5
read(46, "\374>E\3\223\377H\344\25\10\"I\2576!,o)\210/\246\243\221\"N\224\26\232'}!\342"..., 16401) = 16401
read(46, "\27\3\3@\21", 5)              = 5
read(46, "\276\322\320p\233\331\262\244J\20\206\231\3Y\23m\374\273D\316|\27\243\2337\3566\3\255b\264>"..., 16401) = 16401
read(46, "\27\3\3@\21", 5)              = 5
read(46, "1\3508\1\320\367\33\256g\277\263kO\241q\304\362;1h\350xe\270\200\356S\254r\v3\236"..., 16401) = 16401
read(46, "\27\3\3@\21", 5)              = 5
read(46, "Z\354\255\241L\361j\232\336\0327\263o\374\346f\257\343\317\220\0\370x)%>,,\275C\303\326"..., 16401) = 16401
read(46, "\27\3\3@\21", 5)              = 5
read(46, "\312\257O\353G\17\265\274\"\277\20z\20\346\361n\351\234\347\307\24J+\323\371B 2\274/>i"..., 16401) = 16401
read(46, "\27\3\3@\21", 5)              = 5
read(46, ")\376H\225\375\347\3\356(\313]\26\337\336\313A\37M\360\247\363\271\366\301B\253\324I e9}"..., 16401) = 16401
read(46, "\27\3\3@\21", 5)              = 5
read(46, ";z\254_\337\16\370\3104\375\221K)W\300\300\277Sbv\216\354\206_\267H\342?\233\207\3601"..., 16401) = 16401
read(46, "\27\3\0037\361", 5)           = 5
read(46, "M\301\350E{\222Y\376.\34\346\367$\f\274\177\35\201R\36\360G\274\22\205S\234\330\343R6\307"..., 14321) = 14321
read(46, "\27\3\3\0101", 5)             = 5
read(46, ^C"tT\221\335O`\213^\360\207L\317\265~\275\374\351:+\336[\365\322H)\207\206a\267\326|6"..., 2097) = 2097
strace: Process 3108355 detached

It is doing 5 byte TLS header read, then some amount of bytes read (corresponding to what TLS header says).

But that is not really too optimal, and causes a lot of syscalls to be done.

A more efficient way would be to read something like up to 128kB from the socket, then hand it to openssl as data.

This results in this:

image

(Please ignore gnome-shell CPU usage, this is because I was doing a screenshot, and this causes a raise in CPU. During actual download, gnome-shell sits idle)

image

Disk IO performance is not a major problem. There are probably also various inefficiencies in how data is moved between workers and main thread, and how things are done, but could be a second concern.

All tests were performed on tmpfs (256GB DDR4 RAM). tmpfs write using dd using 128KiB blocks, shows 3.4GB/s, and using 4MiB blocks 3.8GB/s. I cannot done more, not because of tmpfs or memory speed limitations, but because dd starts using 100% CPU for doing this 4MiB read and writes.

I know you are using Python, and requests library (which are not most efficient), but the ultimate issue is mostly in openssl from my experience.

I also did notice some suspiecious code in file worker:

current_file.write(self.shm.buf[shm_offset:shm_end].tobytes())

This tobytes() while not obviously documented, can and often will copy data, which is unecassary data copy in this case.

Proof:

user@debian:~$ python3
Python 3.11.6 (main, Oct  8 2023, 05:06:43) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> import gc
>>> psutil.Process().memory_info().rss / 1024/1024/1024
0.013671875  # starting with 13MiB memory usage
>>> gc.collect()
0
>>> psutil.Process().memory_info().rss / 1024/1024/1024
0.013671875
>>> a = memoryview(b"a" * 10 * 1024 * 1024 * 1024)
>>> gc.collect()
0
>>> psutil.Process().memory_info().rss / 1024/1024/1024
10.01370620727539   # 10 GiB
>>> b = a.tobytes()  # take about a second to finish.
>>> gc.collect()
0
>>> psutil.Process().memory_info().rss / 1024/1024/1024
20.013534545898438   # extra 10GiB
>>> 

But, write (on essentially all types of files) is perfectly happy to accept memoryview, no need to give it bytes.

>>> f = open("/tmp/foo222", "wb")
>>> f.write(a)    # giving it memoryview
10737418240

Some machine specs:

$ lspci | grep -i -E 'ether'
07:00.0 Ethernet controller: Intel Corporation I211 Gigabit Network Connection (rev 03)
08:00.0 Ethernet controller: Intel Corporation I211 Gigabit Network Connection (rev 03)
0a:00.0 Ethernet controller: Intel Corporation Ethernet Controller XL710 for 40GbE QSFP+ (rev 02)
0a:00.1 Ethernet controller: Intel Corporation Ethernet Controller XL710 for 40GbE QSFP+ (rev 02)

on the host (AMD Ryzen Threadripper 2950X 16-Core Processor) with heroic / legendary,

01:00.0 Ethernet controller: Broadcom Inc. and subsidiaries BCM57414 NetXtreme-E 10Gb/25Gb RDMA Ethernet Controller (rev 01)
01:00.1 Ethernet controller: Broadcom Inc. and subsidiaries BCM57414 NetXtreme-E 10Gb/25Gb RDMA Ethernet Controller (rev 01)

on the router (AMD Ryzen 7 3700X 8-Core Processor).

FS S5860-20SQ Ethernet switch.

@loathingKernel
Copy link
Contributor

loathingKernel commented Nov 11, 2023

Very interesting write-up and investigation, personally I will go over it again out of pure interest.

But, in what way is this a real world example? Why are you using legendary in what essentially is a datacenter environment?

I am not trying to dismiss it or anything. I am just amazed.

@baryluk
Copy link
Contributor Author

baryluk commented Nov 11, 2023

That is my home computer.

My Internet provider is Init7.

This setup is not that unusual. Not common of course, but there is now number of other places where you can get 10 or 25Gbps, in Europe, US and Asia.

Also this CPU bottleneck can be experienced easier on CPU with less cores.

I will submit a small patch (removing unnecessary memory view copies), that helps a little. (850MB/s -> 920MB/s).

I also do see some inefficiencies in decompression, as well in chunk.hash/chunk.sha1_hash, which does not really to be fully used during download itself.

baryluk added a commit to baryluk/legendary that referenced this issue Nov 11, 2023
This increases peek download speed from about 850MB/s to 960MB/s on my computer.

derrod#620
@derrod
Copy link
Owner

derrod commented Nov 11, 2023

In addition to the patch you submitted, have you tried --no-https to disable TLS for downloads? That should bypass OpenSSL after all.

But this whole downloader is kind of held together by hopes and dreams and not the most efficient, so to actually hit 10 Gbps maybe it's time to Rewrite it int Rust™️ 😛

@baryluk
Copy link
Contributor Author

baryluk commented Nov 11, 2023

I tried --no-https. And I didn't really get it faster. Same. I might dig deeper into strace trace and code later, to see why.

derrod pushed a commit that referenced this issue Nov 16, 2023
This increases peek download speed from about 850MB/s to 960MB/s on my computer.

#620
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants