w3c / IndexedDB

Indexed Database API
https://w3c.github.io/IndexedDB/
Other
245 stars 62 forks source link

Configurable task priority for IDBRequest and IDBTransaction? #428

Open SteveBeckerMSFT opened 1 month ago

SteveBeckerMSFT commented 1 month ago

TPAC 2024: The Prioritized Task Scheduling API shipping in Chromium introduces JavaScript task prioritization where applications can post tasks with high priority and background priority. Should we provide a way for developers to set the priority of the JavaScript tasks associated with IDBRequests and IDBTransactions?

For example, an application could indicate that an IDB read request is user blocking when the application needs results from IDB to load or display. Setting a user blocking priority could increase the priority of the JavaScript event tasks associated with the IDBRequest and IDBTransaction.

evanstade commented 1 month ago

My first inclination would be to be able to set this on the level of the entire IDB database. It will be easier to implement and reason about that way. Also because transactions block each other, so it's not particularly useful to be able to add a high priority transaction behind a low priority one.

And from an API perspective, I would suggest adding it via Storage Buckets. IDB is probably not the only storage API that could benefit from this, and one of the main advantages of Storage Buckets is to not have to update N APIs every time a generally useful dial, such as this one, is added.