Skip to content

faster JSObjectSpace (JS runtime retain / release)#676

Open
sliemeobn wants to merge 4 commits intoswiftwasm:mainfrom
sliemeobn:perf/object-space
Open

faster JSObjectSpace (JS runtime retain / release)#676
sliemeobn wants to merge 4 commits intoswiftwasm:mainfrom
sliemeobn:perf/object-space

Conversation

@sliemeobn
Copy link
Contributor

I added a tiny benchmark to measure the JSObjectSpace in isolation and made a few changes to speed things up.

results (two example runs)

JSObjectSpaceOriginal    retain: 31.53ms  release: 23.57ms  mixed(1k): 12.32ms  mixed(10k): 15.83ms  mixed(50k): 21.63ms
JSObjectSpace (current)  retain: 10.68ms  release: 14.31ms  mixed(1k): 7.20ms  mixed(10k): 6.37ms  mixed(50k): 9.19ms

JSObjectSpaceOriginal    retain: 27.85ms  release: 24.78ms  mixed(1k): 12.44ms  mixed(10k): 15.76ms  mixed(50k): 22.55ms
JSObjectSpace (current)  retain: 10.96ms  release: 13.62ms  mixed(1k): 6.18ms  mixed(10k): 6.32ms  mixed(50k): 9.63ms

I included the benchmark script (AI slop) but I can remove it if we want a clean commit.

Also, please note that there is a behavior difference: refs are not no longer "globally unique" - ie: they will be reused once freed. a "use after free" currently causes an exception - after this PR it could now theoretically go undetected.

@sliemeobn
Copy link
Contributor Author

ok, I just ran this in the ElementaryUI performance benchmark, the results are ... let's say "subtle"

current:
  Summary
  ───────

  01_run1k                    151.81 ms
  02_replace1k                298.86 ms
  03_update10th1k_x16          84.39 ms
  04_select1k                  12.84 ms
  05_swap1k                    27.64 ms
  06_remove-one-1k             19.76 ms
  08_create1k-after1k_x2      164.12 ms
  09_clear1k_x8                 50.1 ms
  21_ready-memory               1.03 MB
  22_run-memory                 2.56 MB
  25_run-clear-memory           3.09 MB

with new JSObjectSpace:
  Summary
  ───────

  01_run1k                    147.78 ms
  02_replace1k                293.08 ms
  03_update10th1k_x16           82.4 ms
  04_select1k                  12.72 ms
  05_swap1k                    27.76 ms
  06_remove-one-1k             19.44 ms
  08_create1k-after1k_x2      168.13 ms
  09_clear1k_x8                47.01 ms
  21_ready-memory               1.03 MB
  22_run-memory                 2.01 MB
  25_run-clear-memory           2.68 MB

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant