Convert eligible columns to typed arrays when outputting from profiler-edit#6167
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6167 +/- ##
==========================================
- Coverage 83.55% 83.49% -0.07%
==========================================
Files 343 344 +1
Lines 36859 36882 +23
Branches 10357 10241 -116
==========================================
- Hits 30796 30793 -3
- Misses 5635 5661 +26
Partials 428 428 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| export function toInt32Array( | ||
| arr: Array<number> | Int32Array<ArrayBuffer> | ||
| ): Int32Array<ArrayBuffer> { | ||
| return arr instanceof Int32Array ? arr : new Int32Array(arr); | ||
| } | ||
|
|
||
| export function toUint8Array( | ||
| arr: Array<number> | Uint8Array<ArrayBuffer> | ||
| ): Uint8Array<ArrayBuffer> { | ||
| return arr instanceof Uint8Array ? arr : new Uint8Array(arr); | ||
| } | ||
|
|
||
| export function toFloat64Array( | ||
| arr: Array<number> | Float64Array<ArrayBuffer> | ||
| ): Float64Array<ArrayBuffer> { | ||
| return arr instanceof Float64Array ? arr : new Float64Array(arr); | ||
| } |
There was a problem hiding this comment.
Nit: I wonder if it's better to move them to a utils file?
There was a problem hiding this comment.
Yeah I wasn't sure, but I've gone ahead and moved it to src/utils/typed-arrays.ts now.
| * of the file. | ||
| * | ||
| * Profile compaction already handles the columns that reference other tables; | ||
| * this function handles the remaining eligible columns. |
There was a problem hiding this comment.
Hm, so this requires the compaction to run before this. I don't love that coupling. Should we include these fields no matter what?
Since the toInt32Array etc. functions that we added already check if they are typed array, it should be no extra cost to add them here.
There was a problem hiding this comment.
Good point. I've made that change.
281bda2 to
3d43eac
Compare
…r-edit. profiler-edit runs profile compacting on the output profile, and profile compacting converts some columns to their typed array form but not others - it only touches columns which contain indexes which refer to other tables. So this is done as a separate pass over the profile. We'll be able to use this new function for the "upload profile" code path once we switch that to uploading JSLB files; before we make that change, converting to typed arrays would be a waste because serializing to JSON would need to convert them back to regular arrays again.
3d43eac to
fe04f38
Compare
Main | Deploy preview
profiler-edit runs profile compacting on the output profile, and profile compacting converts some columns to their typed array form but not others - it only touches columns which contain indexes which refer to other tables. So this adds a separate pass over the profile to "optimize the profile for storage".
We'll be able to use this new function for the "upload profile" code path once we switch that to uploading JSLB files; before we make that change, converting to typed arrays would be a waste because serializing to JSON would need to convert them back to regular arrays again.
I had these patches applied when I generated the "after" profile in #6139 (comment) - without this, profiler-edit would have left most of those columns alone and the size profile wouldn't have looked much different.