I guess we could do it for anything where all two/four bytes of the fill
value are identical? Probably (aside from 0) an unusual case like you say,
but the complexity of checking it should be low enough.

On Fri, Jun 3, 2022 at 11:56 AM Marja Hölttä <[email protected]> wrote:

> Interesting, thanks for making us / me aware of this.
>
> It sounds like a generally reasonable optimization; at least in the
> fill(0) case. Not sure how common fill(-1) is but if it doesn't increase
> the code complexity too much, why not.
>
>
> On Fri, Jun 3, 2022 at 11:34 AM Ashton Six <[email protected]> wrote:
>
>> Hi,
>>
>> I noticed `new Int8Array(int32.buffer).fill(-1)` is equivalent to
>> `int32.fill(-1)` but 10x faster, since [Uint, Int]8.fill() uses memset
>> whereas every other implementation of TypedArray.fill() uses a for loop (
>> https://github.com/llvm/llvm-project/blob/8bb1dbbf7544eaac3afab8d1f91b71f383dab903/libcxx/include/algorithm#L1987-L2005).
>> Benchmark: https://jsbench.me/1zl3y8q6q7/1.
>>
>> Is it worth making this optimisation part of v8 for TypedArray.fill(0),
>> Int16Array.fill(-1) and Int32Array.fill(-1)?
>>
>> Regards,
>> Ashton
>>
>> --
>> --
>> v8-dev mailing list
>> [email protected]
>> http://groups.google.com/group/v8-dev
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "v8-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/v8-dev/3e9d1775-4c4b-4b6a-8d96-74d412e2d52an%40googlegroups.com
>> <https://groups.google.com/d/msgid/v8-dev/3e9d1775-4c4b-4b6a-8d96-74d412e2d52an%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
>
>
> Google Germany GmbH
>
> Erika-Mann-Straße 33
>
> 80636 München
>
> Geschäftsführer: Paul Manicle, Liana Sebastian.
>
> Registergericht und -nummer: Hamburg, HRB 86891
>
> Sitz der Gesellschaft: Hamburg
>
> Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten
> haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter,
> löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen,
> dass die E-Mail an die falsche Person gesendet wurde.
>
>
>
> This e-mail is confidential. If you received this communication by
> mistake, please don't forward it to anyone else, please erase all copies
> and attachments, and please let me know that it has gone to the wrong
> person.
>
> --
> --
> v8-dev mailing list
> [email protected]
> http://groups.google.com/group/v8-dev
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/v8-dev/CAED6dUCyryY%2B2a_u4qcEHCtFuyJvMxMrf0MCmO3DicijgbjXVg%40mail.gmail.com
> <https://groups.google.com/d/msgid/v8-dev/CAED6dUCyryY%2B2a_u4qcEHCtFuyJvMxMrf0MCmO3DicijgbjXVg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/CAGRskv-O3bkJtvm%3DTZD_zODy1KGT%3DRUUHKhaAU8pCZABmwt76Q%40mail.gmail.com.

Reply via email to