From 2ce22df8c4305ca18046e3bf685cb547349ff280 Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Tue, 17 Dec 2019 17:52:59 -0500 Subject: [PATCH] Test out 16 concurrency with 32mb chunks --- dist/restore/index.js | 10 +++++----- dist/save/index.js | 10 +++++----- src/cacheHttpClient.ts | 11 +++++------ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index cc9b6e3..2479753 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -1497,7 +1497,6 @@ const Handlers_1 = __webpack_require__(941); const HttpClient_1 = __webpack_require__(874); const RestClient_1 = __webpack_require__(105); const utils = __importStar(__webpack_require__(443)); -const MAX_CHUNK_SIZE = 4000000; // 4 MB Chunks function isSuccessStatusCode(statusCode) { return statusCode >= 200 && statusCode < 300; } @@ -1621,13 +1620,14 @@ function uploadFile(restClient, cacheId, archivePath) { const fileSize = fs.statSync(archivePath).size; const resourceUrl = getCacheApiUrl() + "caches/" + cacheId.toString(); const responses = []; - const fd = fs.openSync(archivePath, "r"); // Use the same fd for serial reads? Will this work for parallel too? + const fd = fs.openSync(archivePath, "r"); const concurrency = 16; // # of HTTP requests in parallel - core.debug(`Concurrency: ${concurrency}`); - const threads = [...new Array(concurrency).keys()]; + const MAX_CHUNK_SIZE = 32000000; // 32 MB Chunks + core.debug(`Concurrency: ${concurrency} and Chunk Size: ${MAX_CHUNK_SIZE}`); + const parallelUploads = [...new Array(concurrency).keys()]; core.debug("Awaiting all uploads"); let offset = 0; - yield Promise.all(threads.map(() => __awaiter(this, void 0, void 0, function* () { + yield Promise.all(parallelUploads.map(() => __awaiter(this, void 0, void 0, function* () { while (offset < fileSize) { const chunkSize = offset + MAX_CHUNK_SIZE > fileSize ? fileSize - offset : MAX_CHUNK_SIZE; const start = offset; diff --git a/dist/save/index.js b/dist/save/index.js index e7f8045..5134e5f 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -1497,7 +1497,6 @@ const Handlers_1 = __webpack_require__(941); const HttpClient_1 = __webpack_require__(874); const RestClient_1 = __webpack_require__(105); const utils = __importStar(__webpack_require__(443)); -const MAX_CHUNK_SIZE = 4000000; // 4 MB Chunks function isSuccessStatusCode(statusCode) { return statusCode >= 200 && statusCode < 300; } @@ -1621,13 +1620,14 @@ function uploadFile(restClient, cacheId, archivePath) { const fileSize = fs.statSync(archivePath).size; const resourceUrl = getCacheApiUrl() + "caches/" + cacheId.toString(); const responses = []; - const fd = fs.openSync(archivePath, "r"); // Use the same fd for serial reads? Will this work for parallel too? + const fd = fs.openSync(archivePath, "r"); const concurrency = 16; // # of HTTP requests in parallel - core.debug(`Concurrency: ${concurrency}`); - const threads = [...new Array(concurrency).keys()]; + const MAX_CHUNK_SIZE = 32000000; // 32 MB Chunks + core.debug(`Concurrency: ${concurrency} and Chunk Size: ${MAX_CHUNK_SIZE}`); + const parallelUploads = [...new Array(concurrency).keys()]; core.debug("Awaiting all uploads"); let offset = 0; - yield Promise.all(threads.map(() => __awaiter(this, void 0, void 0, function* () { + yield Promise.all(parallelUploads.map(() => __awaiter(this, void 0, void 0, function* () { while (offset < fileSize) { const chunkSize = offset + MAX_CHUNK_SIZE > fileSize ? fileSize - offset : MAX_CHUNK_SIZE; const start = offset; diff --git a/src/cacheHttpClient.ts b/src/cacheHttpClient.ts index 617528a..24a22dc 100644 --- a/src/cacheHttpClient.ts +++ b/src/cacheHttpClient.ts @@ -16,8 +16,6 @@ import { } from "./contracts"; import * as utils from "./utils/actionUtils"; -const MAX_CHUNK_SIZE = 4000000; // 4 MB Chunks - function isSuccessStatusCode(statusCode: number): boolean { return statusCode >= 200 && statusCode < 300; } @@ -179,14 +177,15 @@ async function uploadFile(restClient: RestClient, cacheId: number, archivePath: const fileSize = fs.statSync(archivePath).size; const resourceUrl = getCacheApiUrl() + "caches/" + cacheId.toString(); const responses: IRestResponse[] = []; - const fd = fs.openSync(archivePath, "r"); // Use the same fd for serial reads? Will this work for parallel too? + const fd = fs.openSync(archivePath, "r"); const concurrency = 16; // # of HTTP requests in parallel - core.debug(`Concurrency: ${concurrency}`); - const threads = [...new Array(concurrency).keys()]; + const MAX_CHUNK_SIZE = 32000000; // 32 MB Chunks + core.debug(`Concurrency: ${concurrency} and Chunk Size: ${MAX_CHUNK_SIZE}`); + const parallelUploads = [...new Array(concurrency).keys()]; core.debug("Awaiting all uploads"); let offset = 0; - await Promise.all(threads.map(async () => { + await Promise.all(parallelUploads.map(async () => { while (offset < fileSize) { const chunkSize = offset + MAX_CHUNK_SIZE > fileSize ? fileSize - offset : MAX_CHUNK_SIZE; const start = offset;