Skip to content

fix: Improve Azure Key Vault bulk load performance - #1218

Open
MqllR wants to merge 1 commit into
Consensys-Incorporated:masterfrom
MqllR:azure-keyvault-bulk-load-perf
Open

fix: Improve Azure Key Vault bulk load performance#1218
MqllR wants to merge 1 commit into
Consensys-Incorporated:masterfrom
MqllR:azure-keyvault-bulk-load-perf

Conversation

@MqllR

@MqllR MqllR commented Aug 6, 2026

Copy link
Copy Markdown

Summary

Fixes #1217

Secrets and keys are now fetched concurrently, up to a configurable limit, while the vault is still being listed, instead of one 25-item page at a time with per-page parallelStream() (which barely parallelizes under a constrained CPU limit, since parallelStream() sizes off Runtime.availableProcessors()).

  • New ConcurrentBulkLoader/BulkLoadOptions in keystorage.azure: bounded-concurrency dispatch over a lazily-consumed listing stream, with a deadline, interrupt handling, and per-item error accounting.
  • AzureKeyVault.mapSecrets/mapKeyProperties use the loader instead of page-by-page parallelStream().
  • New CLI options: --azure-bulk-load-max-concurrency (default 20) and --azure-bulk-load-timeout (default 900 seconds).
  • Retries for throttled/transient failures are left to the Azure SDK's own default retry policy rather than a custom classifier.

Performance

Same environment as #1217 (container limited to cpu: "1", memory: 2Gi; requests cpu: 500m, memory: 1Gi; vault with 20001 secrets):

  • Before: ~8m30s
  • After: ~210s (~2.4x faster)
2026-08-06 16:39:41.749+0000 | bulk-load-progress | INFO  | ConcurrentBulkLoader | Azure secrets bulk load: listed 19025, loaded 19025, failed 0
2026-08-06 16:39:46.750+0000 | bulk-load-progress | INFO  | ConcurrentBulkLoader | Azure secrets bulk load: listed 19475, loaded 19475, failed 0
2026-08-06 16:39:51.751+0000 | bulk-load-progress | INFO  | ConcurrentBulkLoader | Azure secrets bulk load: listed 19975, loaded 19975, failed 0
2026-08-06 16:39:52.000+0000 | artifact-signer-loader | INFO  | ConcurrentBulkLoader | Azure secrets bulk load: loaded 20001 values from 20001 of the 20001 items listed in 210s

Test plan


Note

Medium Risk
Changes affect startup/reload key loading for all Azure bulk users; mis-tuned concurrency or timeouts could increase errors or leave keys unloaded, though defaults and explicit error reporting mitigate silent partial loads.

Overview
Azure Key Vault bulk loading is reworked for much faster startup when many secrets or keys are loaded (eth1 and eth2).

Listing and fetching now overlap: mapSecrets and mapKeyProperties drive a new ConcurrentBulkLoader over lazily consumed SDK streams, with a semaphore-capped concurrency (virtual threads), periodic progress logs, and strict accounting for failures, deadlines, interrupts, and incomplete listing.

Operators can tune behavior via --azure-bulk-load-max-concurrency (default 20) and --azure-bulk-load-timeout (default 900s). BulkLoadOptions is wired through AzureKeyVaultParameters / CLI into eth1 and eth2 bulk load paths. Transient Azure errors rely on the SDK retry policy only (no custom retry layer in the loader).

Reviewed by Cursor Bugbot for commit 6ff268e. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Mael Regnery <mael@mqli.fr>
@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 6ff268e. Configure here.

recordFailure(e.getClass().getSimpleName(), nameOf.apply(item), e);
return false;
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deadline does not bound load

Medium Severity

--azure-bulk-load-timeout is documented as an overall time budget, but the deadline is only checked before limiter.acquire(). That acquire can block past the deadline with no timeout, work is still submitted afterward, and after abandoning dispatch ExecutorService.close() waits for in-flight tasks with no deadline-aware bound or cancellation. Startup can therefore continue well beyond the configured budget whenever Azure requests are slow or saturated.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6ff268e. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves Azure Key Vault bulk-loading performance through bounded concurrent processing and configurable timeouts.

Changes:

  • Adds concurrent, deadline-aware bulk-loading infrastructure.
  • Integrates concurrency settings into Azure loading paths and CLI options.
  • Adds loader and Azure mapping tests plus release documentation.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
CHANGELOG.md Documents the performance improvement and options.
commandline/build.gradle Adds the keystorage dependency.
commandline/.../PicoCliAzureKeyVaultParameters.java Defines Azure bulk-load CLI options.
core/.../Eth1Runner.java Logs configured Azure concurrency.
core/.../Eth2Runner.java Passes and logs bulk-load options.
keystorage/.../AzureKeyVault.java Uses concurrent loading for keys and secrets.
keystorage/.../BulkLoadOptions.java Defines concurrency and deadline settings.
keystorage/.../ConcurrentBulkLoader.java Implements bounded concurrent loading.
keystorage/.../AzureKeyVaultTest.java Updates Azure mapping tests.
keystorage/.../ConcurrentBulkLoaderTest.java Tests concurrency, failures, deadlines, and interrupts.
signing/.../SecpAzureBulkLoader.java Passes bulk-load options to key mapping.
signing/.../AzureKeyVaultParameters.java Exposes default bulk-load configuration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +213 to +218
if (loggedFailures.size() < MAX_LOGGED_FAILURES) {
loggedFailures.add(name + ": " + label);
LOG.warn("{}: failed to load '{}' - {}", description, name, label, cause);
} else {
LOG.debug("{}: failed to load '{}' - {}", description, name, label, cause);
}
Comment on lines +169 to +170
try {
limiter.acquire();
"Maximum number of concurrent requests to Azure Key Vault during bulk key loading "
+ "(Default: ${DEFAULT-VALUE})",
paramLabel = "<MAX_CONCURRENCY>")
private int maxConcurrency = BulkLoadOptions.DEFAULT_MAX_CONCURRENCY;
@MqllR MqllR changed the title Improve Azure Key Vault bulk load performance fix: Improve Azure Key Vault bulk load performance Aug 11, 2026
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

Successfully merging this pull request may close these issues.

Bulk loading many secrets from Azure Key Vault is very slow under CPU-constrained containers

2 participants