Re: [whatwg/storage] Define size of all storage actions (#110)

I found some notes from when I tried to sketch a storage cost model for IndexedDB. This was in 2018, and I knew a lot less about the implementation back then. So, the numbers are probably bad, but at least it's a list of things to consider.

Object cost:

* primitives (number, Date, null, true, false): 10 -- accommodates (tag + 8 bytes or tag + <= 9 bytes of varint)
* string: 8 + 2 * string length
* object: 8 + sum of keys and values
* array: 16 + sum of elements
* native arrays: 16 + buffer length
* Imagedata: 32 + the cost of ImageData.data as a native array
* Blob: 64 + cost of MIME type as string + length
* File: Blob + cost of filename as string

I might have missed some other object. The idea is to assign a cost based on a straightforward representation for each clonable. The cost doesn't have to be exact, because we expect implementations to have their own overhead.

IndexedDB transaction costs (get refunded when the transaction completes):

* 32 per open store and index in a transaction; write transactions open all indexes in their stores; versionchange transactions open all stores and indexes 
* write: 64 + inputs (key + value) + sum over indexes touched (16 + index key + primary key)
* delete: like a write, but with zero value cost
* store creation: 64  + store name and key path as strings
* index creation: 64 + index name and key path as strings
* store/index renames: same as creation
* store/index deletion: 64; deleting a store implies deleting all its indexes

This isn't a complete list. I hope it's a good starting point if someone is itching to start an explainer :smile: 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/storage/issues/110#issuecomment-662502743

Received on Wednesday, 22 July 2020 14:57:55 UTC