From 7e134111dbaf2d2edf1a4bacc0b7ef39e8e40890 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Tue, 23 Jan 2024 10:02:49 +0900 Subject: [PATCH] pref: optimize xrefmap download perforamance --- src/Docfx.Build/XRefMaps/XRefMapDownloader.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Docfx.Build/XRefMaps/XRefMapDownloader.cs b/src/Docfx.Build/XRefMaps/XRefMapDownloader.cs index 9b0eba9fd09..5e31a638f2d 100644 --- a/src/Docfx.Build/XRefMaps/XRefMapDownloader.cs +++ b/src/Docfx.Build/XRefMaps/XRefMapDownloader.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Net; using Docfx.Common; using EnvironmentVariables = Docfx.DataContracts.Common.Constants.EnvironmentVariables; @@ -127,11 +128,15 @@ protected static async Task DownloadFromWebAsync(Uri uri) using var httpClient = new HttpClient(new HttpClientHandler() { + AutomaticDecompression = DecompressionMethods.All, CheckCertificateRevocationList = !EnvironmentVariables.NoCheckCertificateRevocationList, - }); + }) + { + Timeout = TimeSpan.FromMinutes(30), // Default: 100 seconds + }; using var stream = await httpClient.GetStreamAsync(uri); - using var sr = new StreamReader(stream); + using var sr = new StreamReader(stream, bufferSize: 81920); // Default :1024 byte var map = YamlUtility.Deserialize(sr); map.BaseUrl = baseUrl; UpdateHref(map, null);