Improve base64 encoding/decoding speeds#1985
Conversation
c064b80 to
5287026
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1985 +/- ##
==========================================
- Coverage 96.08% 96.08% -0.01%
==========================================
Files 267 269 +2
Lines 6240 6250 +10
Branches 1009 1008 -1
==========================================
+ Hits 5996 6005 +9
- Misses 244 245 +1 ☔ View full report in Codecov by Sentry. |
| await Promise.all( | ||
| auxiliaryFiles.map(async (file) => { | ||
| // This should still be safe | ||
| // eslint-disable-next-line require-atomic-updates | ||
| file.data.base64 = await asyncEncode(file); | ||
| }), | ||
| ); |
There was a problem hiding this comment.
Why are we doing this here? Wouldn't it mean we're storing files in memory multiple times?
There was a problem hiding this comment.
The main reason for this was to move it to a function that was already asynchronous, therefore "precomputing" the base64 string before trying to set it in state. Alternatively we could turn #set into an async function and do it there, but I'm not sure its worth the extra complexity? WDYT?
I think the increase in time the file is stored in memory should be neglible?
aa40071 to
d05a3ed
Compare
d05a3ed to
5be4c26
Compare
Adds new base64 encoding and decoding utilities that have faster performance characteristics than the current implementation. This also fixes an issue where the client would sometimes get unresponsive while encoding large files.
Fixes #1984