google / ripunzip

Other
168 stars 18 forks source link

Performance improvements to URI unzip. #3

Closed adetaylor closed 1 year ago

adetaylor commented 1 year ago

Use of criterion, plus 'cargo flamegraph', showed that we were CPU-bound due to excessive thrashing on the BTreeMap readahead 'cache'. This was because it was full of many very tiny reads; we were creating an entry for every single read during random-access mode, and then potentially more tiny entries by splitting cache cells later. All this thrash happened while we had the 'state' mutex claimed, effectively reducing ripunzip performance to be single-threaded.

With this change, we:

Together, these changes eliminate significant CPU usage from the BTreeMap.