Repository navigation
perf(android): read numeric array arguments in bulk - #128
Open
ammarahm-ed wants to merge 1 commit into
Open
ammarahm-ed wants to merge 1 commit into
ammarahm-ed wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A JS array passed as
int[]ordouble[]was read one element at a time: a handle, a conversion call and a status check per element. The elements are now copied into adoublebuffer in one pass and converted from there.js_get_array_doublesin each engine'sjsr.cpp. On V8 it walks the packed backing store withv8::Array::Iterate; the other engines loop overnapi_get_element.Array::copyNumberson each engine backend, the same split.If an element is not a number, or a dictionary-mode array skipped a hole, the bulk read reports failure and the existing per-element path runs, so conversion results do not change. For
int[]the buffer is also range-checked: a value outside theintrange falls back to the per-element path, which applies the engine's own wrapping, instead of a cast that is undefined for out-of-range doubles.Results
V8 release build on a Sony SO-01M (Android 11, arm64), AOT-compiled with
cmd package compile -m speed. One warm-up launch is discarded, then 5 launches; values are the median ns per call.The 3-element rows and the 16-element rows are the same code path, so the gain grows with the array length. String and boolean arrays do not use this path and are unchanged.
All cases
Only V8 was built and run. The Hermes, JSC, QuickJS-NG and PrimJS readers in this change have not been built or run.