From 09f4f7a6af62643ef4040983e5b6a5fe3c41f208 Mon Sep 17 00:00:00 2001 From: Monica Chintala Date: Tue, 4 Aug 2026 14:15:31 -0700 Subject: [PATCH] Editorial: use a per-cache dedicated parallel queue for Cache API methods Give each request response list (i.e. each Cache object) a dedicated parallel queue and route Cache.matchAll, Cache.addAll (batch commit step), Cache.put, Cache.delete, and Cache.keys through it, so reads and writes on the same Cache object are serialized. Cache.match and Cache.add are pure orchestrators that delegate to matchAll and addAll respectively, and do not touch the request response list themselves, so they are covered transitively without needing algorithm changes. Cache.addAll's initial fetch block is left as bare parallel since it only performs fetch and does not access the cache. Closes: #1841 --- index.bs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/index.bs b/index.bs index 7c11b834..06d750db 100644 --- a/index.bs +++ b/index.bs @@ -1962,6 +1962,8 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ A request response list is a [=list=] of [=tuples=] consisting of a request (a [=/request=]) and a response (a [=/response=]). + A [=request response list=] has an associated request response list parallel queue (a [=parallel queue=]) used to serialize reads and writes on the [=request response list=]. + The relevant request response list is the instance that [=this=] represents. A name to cache map is an ordered map whose [=map/entry=] consists of a [=map/key=] (a string that represents the name of a [=request response list=]) and a [=map/value=] (a [=request response list=]). @@ -2055,7 +2057,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Set |r| to the associated [=Request/request=] of the result of invoking the initial value of {{Request}} as constructor with |request| as its argument. If this [=throws=] an exception, return [=a promise rejected with=] that exception. 1. Let |realm| be [=this=]'s [=relevant realm=]. 1. Let |promise| be [=a new promise=]. - 1. Run these substeps [=in parallel=]: + 1. [=queue/Enqueue=] the following steps to [=this=]'s [=relevant request response list=]'s [=request response list parallel queue=]: 1. Let |responses| be an empty [=list=]. 1. If the optional argument |request| is omitted, then: 1. [=list/For each=] |requestResponse| of the [=relevant request response list=]: @@ -2135,7 +2137,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Increment |index| by one. 1. Let |realm| be [=this=]'s [=relevant realm=]. 1. Let |cacheJobPromise| be [=a new promise=]. - 1. Run the following substeps [=in parallel=]: + 1. [=queue/Enqueue=] the following steps to [=this=]'s [=relevant request response list=]'s [=request response list parallel queue=]: 1. Let |errorData| be null. 1. Invoke [=Batch Cache Operations=] with |operations|. If this [=throws=] an exception, set |errorData| to the exception. 1. [=Queue a task=], on |cacheJobPromise|'s [=relevant settings object=]'s [=responsible event loop=] using the [=DOM manipulation task source=], to perform the following substeps: @@ -2180,7 +2182,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Let |realm| be [=this=]'s [=relevant realm=]. 1. Return the result of the [=Upon fulfillment|fulfillment=] of |bodyReadPromise|: 1. Let |cacheJobPromise| be [=a new promise=]. - 1. Return |cacheJobPromise| and run these steps [=in parallel=]: + 1. Return |cacheJobPromise| and [=queue/Enqueue=] the following steps to [=this=]'s [=relevant request response list=]'s [=request response list parallel queue=]: 1. Let |errorData| be null. 1. Invoke [=Batch Cache Operations=] with |operations|. If this [=throws=] an exception, set |errorData| to the exception. 1. [=Queue a task=], on |cacheJobPromise|'s [=relevant settings object=]'s [=responsible event loop=] using the [=DOM manipulation task source=], to perform the following substeps: @@ -2207,7 +2209,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. [=list/Append=] |operation| to |operations|. 1. Let |realm| be [=this=]'s [=relevant realm=]. 1. Let |cacheJobPromise| be [=a new promise=]. - 1. Run the following substeps [=in parallel=]: + 1. [=queue/Enqueue=] the following steps to [=this=]'s [=relevant request response list=]'s [=request response list parallel queue=]: 1. Let |errorData| be null. 1. Let |requestResponses| be the result of running [=Batch Cache Operations=] with |operations|. If this [=throws=] an exception, set |errorData| to the exception. 1. [=Queue a task=], on |cacheJobPromise|'s [=relevant settings object=]'s [=responsible event loop=] using the [=DOM manipulation task source=], to perform the following substeps: @@ -2232,7 +2234,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Set |r| to the associated [=Request/request=] of the result of invoking the initial value of {{Request}} as constructor with |request| as its argument. If this [=throws=] an exception, return [=a promise rejected with=] that exception. 1. Let |realm| be [=this=]'s [=relevant realm=]. 1. Let |promise| be [=a new promise=]. - 1. Run these substeps [=in parallel=]: + 1. [=queue/Enqueue=] the following steps to [=this=]'s [=relevant request response list=]'s [=request response list parallel queue=]: 1. Let |requests| be an empty [=list=]. 1. If the optional argument |request| is omitted, then: 1. [=list/For each=] |requestResponse| of the [=relevant request response list=]: