Skip to content

Parallelize font downloads in Install-GoogleFont #208

Description

A single Install-GoogleFont -Name 'Roboto' expands to many rows in FontsData.json (one per weight/style — regular, italic, 500, 600, ...), and Install-GoogleFont -All covers thousands of font files. Today every file is downloaded one after another via Invoke-WebRequest, so total time is dominated by serial network round-trips rather than available bandwidth.

Request

Current experience

Install-GoogleFont processes the selected font files in a single foreach loop. For each row it downloads the .ttf, installs it, removes it, and only then moves to the next row. Even installing a single family (-Name 'Roboto') downloads each weight sequentially.

Desired experience

Multiple font files are fetched concurrently so the total install time scales with the slowest of N parallel downloads instead of the sum of all of them. A bounded throttle keeps the host and fonts.gstatic.com from being hit too hard.

Acceptance criteria

  • Downloads of distinct font files run concurrently when more than one file is selected
  • A bounded degree of parallelism is used (configurable or sensibly defaulted)
  • Progress and error reporting per file remain clear — one failed download does not silently mask others
  • -WhatIf / ShouldProcess semantics are preserved
  • Single-file invocations behave identically to today

Related


Technical decisions

Parallelism primitive: Use ForEach-Object -Parallel (PowerShell 7+). Built-in -ThrottleLimit, no runspace plumbing.

Default throttle: 8 parallel downloads, exposed via a new -ThrottleLimit parameter for power users.

Phase to parallelize: Download is I/O bound and trivially parallel. Font registration via Install-Font writes to a shared system location and is kept sequential after downloads complete.

Error handling: Use -ErrorAction Continue inside the parallel block and aggregate failures into a list emitted after, so one bad URL does not abort the rest of the batch.

ShouldProcess: Evaluated up front per file (it cannot cross runspace boundaries safely). The parallel block only runs for files the user confirmed.


Implementation plan

  • Add [int] $ThrottleLimit = 8 parameter to Install-GoogleFont
  • Resolve and deduplicate the set of font files before any I/O (see companion dedup issue)
  • Evaluate ShouldProcess for each file sequentially, collecting the approved set
  • Run the download phase via ForEach-Object -Parallel -ThrottleLimit $ThrottleLimit, writing each file to the temp directory
  • Run Install-Font sequentially over the downloaded files
  • Aggregate per-file errors and surface them via Write-Error after the parallel phase
  • Update tests to cover multi-file parallel install and a simulated single-file failure

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions