perf(cloudfront): skip the host lookup when no distribution exists (#7467)

* perf(cloudfront): skip the host lookup when no distribution exists

CloudFrontDistributionFilter scanned the distribution store on every
request of every service. CloudFrontService.hasDistributions() lets the
filter return at once while the store is empty, which is what findByHost
answered then anyway.

* perf(cloudfront): keep the distribution check free once one exists

AccountAwareStorageBackend.isEmpty() copies every key once the store holds
an entry, so a distribution in any account made each request pay that copy
before the same host scan as before. The filter only needs to know whether
any distribution exists, which the backing store answers without a copy.
This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-11-03 22:09:18 -04:00
1 parent 62bfd5e5ce
commit d7a3461fbc
4 files changed
+33 -2

No files matched your search

@@ -52,6 +52,22 @@ class AccountAwareStorageBackendTest {
assertTrue(second.isEmpty());
}
@Test
void isEmptyInAllAccountsSeesEveryAccount() {
InMemoryStorage<String, String> raw = new InMemoryStorage<>();
AccountAwareStorageBackend<String> first =
new AccountAwareStorageBackend<>(raw, null, "111111111111");
AccountAwareStorageBackend<String> second =
new AccountAwareStorageBackend<>(raw, null, "222222222222");
assertTrue(second.isEmptyInAllAccounts());
first.put("resource", "value");
assertTrue(second.isEmpty());
assertFalse(second.isEmptyInAllAccounts());
}
@Test
void putAllPrefixesEveryEntryWithTheRequestScope() {
InMemoryStorage<String, String> raw = new InMemoryStorage<>();