Skip to content

2.0.0 | slow and steady wins the race #3044

Description

@mizulu

Describe the bug

updating store ~4000 times, 2 keys at a time
takes ~3s to complete

 import { createStore, flush } from "solid-js"

 const COUNT = 4000
  const [store, setStore] = createStore({})
  const start = performance.now()

  for (
    let i = 1; i < COUNT; i++
  ) {
    setStore(store => {
      store[i - 1] = false
      store[i] = true
    })
    flush()
  }

  console.log(
    (performance.now() - start).toFixed(3),
    "ms"
  )

hot path

Image

similar code in solid 1.x takes few ms for 100,000 updates
https://s.olid.uk/id/EGa-sTlDQuyeVbKU8nv3Sw

import { render } from 'solid-js/web';
import { createSignal, createEffect } from 'solid-js';

import { produce, createStore } from "solid-js/store"



const COUNT = 100000


const [store, setStore] = createStore({})


const start = performance.now()
for (
  let i = 1; i < COUNT; i++
) {
  queueMicrotask(() => {
    setStore(
      produce(store => {
        store[i - 1] = false
        store[i] = true
      })
    );

  })


}


console.log((performance.now() - start).toFixed(3) , "ms")

Your Example Website or App

https://s.olid.uk/id/r3tCfj0USguLi24fIhUXbg

Steps to Reproduce the Bug or Issue

see repro

Expected behavior

speed

Screenshots or Videos

No response

Platform

.

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions