Skip to content

Commit

Permalink
Better Artifact Telemetry + Increase Upload chunk size (actions#535)
Browse files Browse the repository at this point in the history
* Differentiate user-agents for better internal telemetry

* Bump chunk size from 4 to 8 MB

* Update User-Agent Strings
  • Loading branch information
konradpabjan authored Jul 30, 2020
1 parent ccad190 commit 3a9dc00
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/artifact/src/internal/config-variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function getUploadFileConcurrency(): number {
// When uploading large files that can't be uploaded with a single http call, this controls
// the chunk size that is used during upload
export function getUploadChunkSize(): number {
return 4 * 1024 * 1024 // 4 MB Chunks
return 8 * 1024 * 1024 // 8 MB Chunks
}

// The maximum number of retries that can be attempted before an upload or download fails
Expand Down
5 changes: 4 additions & 1 deletion packages/artifact/src/internal/download-http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export class DownloadHttpClient {
private statusReporter: StatusReporter

constructor() {
this.downloadHttpManager = new HttpManager(getDownloadFileConcurrency())
this.downloadHttpManager = new HttpManager(
getDownloadFileConcurrency(),
'@actions/artifact-download'
)
// downloads are usually significantly faster than uploads so display status information every second
this.statusReporter = new StatusReporter(1000)
}
Expand Down
8 changes: 5 additions & 3 deletions packages/artifact/src/internal/http-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import {createHttpClient} from './utils'
*/
export class HttpManager {
private clients: HttpClient[]
private userAgent: string

constructor(clientCount: number) {
constructor(clientCount: number, userAgent: string) {
if (clientCount < 1) {
throw new Error('There must be at least one client')
}
this.clients = new Array(clientCount).fill(createHttpClient())
this.userAgent = userAgent
this.clients = new Array(clientCount).fill(createHttpClient(userAgent))
}

getClient(index: number): HttpClient {
Expand All @@ -22,7 +24,7 @@ export class HttpManager {
// for more information see: https://github.com/actions/http-client/blob/04e5ad73cd3fd1f5610a32116b0759eddf6570d2/index.ts#L292
disposeAndReplaceClient(index: number): void {
this.clients[index].dispose()
this.clients[index] = createHttpClient()
this.clients[index] = createHttpClient(this.userAgent)
}

disposeAndReplaceAllClients(): void {
Expand Down
5 changes: 4 additions & 1 deletion packages/artifact/src/internal/upload-http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export class UploadHttpClient {
private statusReporter: StatusReporter

constructor() {
this.uploadHttpManager = new HttpManager(getUploadFileConcurrency())
this.uploadHttpManager = new HttpManager(
getUploadFileConcurrency(),
'@actions/artifact-upload'
)
this.statusReporter = new StatusReporter(10000)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/artifact/src/internal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ export function getUploadHeaders(
return requestOptions
}

export function createHttpClient(): HttpClient {
return new HttpClient('actions/artifact', [
export function createHttpClient(userAgent: string): HttpClient {
return new HttpClient(userAgent, [
new BearerCredentialHandler(getRuntimeToken())
])
}
Expand Down

0 comments on commit 3a9dc00

Please sign in to comment.