1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:58:12 +00:00
serenity/Libraries
Linus Groh a82c56f9f7 LibJS: Speed up IndexedPropertyIterator by computing non-empty indices
This provides a huge speed-up for objects with large numbers as property
keys in some situation. Previously we would simply iterate from 0-<max>
and check if there's a non-empty value at each index - now we're being
smarter and compute a list of non-empty indices upfront, by checking
each value in the packed elements vector and appending the sparse
elements hashmap keys (for GenericIndexedPropertyStorage).

Consider this example, an object with a single own property, which is a
number increasing by a factor of 10 each iteration:

    for (let i = 0; i < 10; ++i) {
        const o = {[10 ** i]: "foo"};
        const start = Date.now();
        Object.getOwnPropertyNames(o);  // <-- IndexedPropertyIterator
        const end = Date.now();
        console.log(`${10 ** i} -> ${(end - start) / 1000}s`);
    }

Before this change:

    1 -> 0.0000s
    10 -> 0.0000s
    100 -> 0.0000s
    1000 -> 0.0000s
    10000 -> 0.0005s
    100000 -> 0.0039s
    1000000 -> 0.0295s
    10000000 -> 0.2489s
    100000000 -> 2.4758s
    1000000000 -> 25.5669s

After this change:

    1 -> 0.0000s
    10 -> 0.0000s
    100 -> 0.0000s
    1000 -> 0.0000s
    10000 -> 0.0000s
    100000 -> 0.0000s
    1000000 -> 0.0000s
    10000000 -> 0.0000s
    100000000 -> 0.0000s
    1000000000 -> 0.0000s

Fixes #3805.
2020-10-20 08:51:41 +02:00
..
LibAudio LibAudio: Use new format functions. 2020-10-17 23:20:31 +02:00
LibC LibC: Make difftime a function 2020-10-15 13:45:00 +02:00
LibChess LibChess: Use new format functions. 2020-10-17 23:20:31 +02:00
LibCompress Everywhere: Fix typos 2020-10-02 16:03:17 +02:00
LibCore LibCore: Use new format functions in some places. 2020-10-17 23:20:31 +02:00
LibCpp LibCpp: Add library for working with c++ code 2020-09-30 21:46:59 +02:00
LibCrypt Everywhere: Port to String::copy_characters_to_buffer() 2020-08-30 17:35:27 +02:00
LibCrypto Meta+LibC through LibHTTP: Make clang-format-10 clean 2020-09-25 21:18:17 +02:00
LibDebug Everywhere: Fix more typos 2020-10-03 12:36:49 +02:00
LibDesktop Meta+LibC through LibHTTP: Make clang-format-10 clean 2020-09-25 21:18:17 +02:00
LibDiff LibDiff: Add library for working with diffs 2020-09-15 21:43:29 +02:00
LibELF Everywhere: Fix more typos 2020-10-03 12:36:49 +02:00
LibGemini LibGemini: Improve rendering of <pre> blocks 2020-10-06 20:29:11 +02:00
LibGfx Style: Remove uses of NULL, substituting nullptr 2020-10-13 13:52:52 +02:00
LibGUI Everywhere: Add missing <AK/TemporaryChange.h> includes 2020-10-15 23:49:53 +02:00
LibHTTP ProtocolServer+LibWeb: Support more detailed HTTP requests 2020-09-28 11:55:26 +02:00
LibImageDecoderClient AK: Add trivial structure validation to SharedBuffer 2020-10-02 15:38:07 +02:00
LibIPC LibIPC: Make IPC::encode() and ::decode() fail at compiletime when used 2020-10-04 23:12:28 +02:00
LibJS LibJS: Speed up IndexedPropertyIterator by computing non-empty indices 2020-10-20 08:51:41 +02:00
LibKeyboard Kernel+LibKeyboard: Store the keymap name when setting system keymap 2020-08-06 17:45:06 +02:00
LibLine Shell+LibLine: Record the input offset of completions 2020-10-04 23:12:28 +02:00
LibM Meta+LibHTTP through LibWeb: Make clang-format-10 clean 2020-09-25 21:18:17 +02:00
LibMarkdown LibMarkdown: Parse paragraphs line-wise 2020-09-27 21:14:18 +02:00
LibPCIDB LibPCIDB: Mark compilation-unit-only functions as static 2020-08-12 20:40:59 +02:00
LibProtocol AK: Add trivial structure validation to SharedBuffer 2020-10-02 15:38:07 +02:00
LibPthread Meta+LibHTTP through LibWeb: Make clang-format-10 clean 2020-09-25 21:18:17 +02:00
LibTar Userland: tar: support extracting gzipped files 2020-10-04 00:16:40 +02:00
LibTextCodec LibTextCodec: Mark compilation-unit-only functions as static 2020-08-12 20:40:59 +02:00
LibThread HackStudio: Detach from debugged process before terminating 2020-09-26 17:18:21 +02:00
LibTLS Everywhere: Fix typos 2020-10-02 16:03:17 +02:00
LibUnwind Everywhere: Fix typos 2020-10-02 16:03:17 +02:00
LibVT Everywhere: Fix typos 2020-10-02 16:03:17 +02:00
LibWeb LibWeb: Dispatch "load" on document and window 2020-10-18 13:45:28 +02:00
LibX86 LibX86: clang-format 2020-10-20 08:41:59 +02:00
CMakeLists.txt LibTar: Create LibTar and TarStream 2020-10-04 00:16:40 +02:00