Skip to content

feat: add web-worker-perf variant to libavoid-standalone demo#19

Merged
kumilingus merged 5 commits into
mainfrom
feat/libavoid-web-worker-perf-demo
Apr 24, 2026
Merged

feat: add web-worker-perf variant to libavoid-standalone demo#19
kumilingus merged 5 commits into
mainfrom
feat/libavoid-web-worker-perf-demo

Conversation

@kumilingus
Copy link
Copy Markdown
Contributor

@kumilingus kumilingus commented Apr 24, 2026

Summary

Adds a web-worker-perf variant to the libavoid demo and tightens the existing web-worker variant.

New perf variant (src/web-worker-perf/)

  • Stress test for the worker-based router — two flowchart-style diagrams switchable via a dropdown (larger one has ~400 elements / ~450 links); routing time for each load is logged via console.time('worker routed').
  • Navigation: click on blank or a cell to fit to content, drag on blank to rubber-band zoom to a region.
  • The worker is terminated and recreated on each diagram switch so libavoid never carries stale state across loads.

Web-worker variant improvements

  • Now shares the sample graph with the UI-thread variant via src/shared/example-graph.js, so the two apps are apples-to-apples — the only substantive difference is where the router runs. The previous web-worker/example.json is deleted.
  • awaiting-update highlighter expanded to cover every pending-route state: initial load, element move/resize, new link drawn, endpoint dragged off a port. Removed per-link on routed replies (previously used a blanket removeAll).
  • Filters on both directions of the wire:
    • Outbound: skip link changes that don't touch source/target, and skip endpoint moves that stay dangling (no routability change) — previously re-routed on every pointer move during a dangling drag.
    • Inbound: skip applying a routed reply to a link the user has since disconnected locally (prevents a snap-back race).
  • Extracted markAwaiting / unmarkAwaiting to src/shared/awaiting.js.
  • Top-of-file comments document the async architecture and message protocol.

Build / tooling

  • Generalized USE_WEB_WORKERS=1VARIANT=<folder>. package.json keeps start-web-worker / build-web-worker working and adds matching *-web-worker-perf scripts; webpack.config.js reads process.env.VARIANT.
  • AvoidRouter.onGraphReset(previousModels = []) defaults to an empty array so the perf variant's reset-from-empty flow doesn't throw.
  • styles.scss: scoped .joint-paper border to .ui-thread, extended .web-worker rules to cover .web-worker-perf, added a fixed-position .diagram-selector dropdown style.

Docs

  • js/README.md gains a Variants section documenting all three variants with their purpose and run commands.

Lint (pre-existing on main, bundled here to unblock CI)

  • microservices-architecture/ts/src/*.ts: 68 issues auto-fixed (object-curly-spacing, @typescript-eslint/consistent-type-imports).
  • microservices-architecture/ts/src/link-routing.ts: replaced (target as any)[prop] with Reflect.get(target, prop) — idiomatic for a Proxy get trap, no any cast.

Test plan

  • cd libavoid-standalone-link-routing/js && npm install
  • npm start — ui-thread still loads and routes the shared 5-node graph
  • npm run start-web-worker — web-worker loads with the new VARIANT=web-worker env var; same graph routes through the worker; moving an element shows awaiting-update on connected links; creating a new link / dragging an endpoint off a port also flips the visual
  • npm run start-web-worker-perf — perf demo loads; selector switches between Diagram 1 and Diagram 2; drag on blank rubber-band zooms; click on blank or on a cell fits the paper
  • npm run lint at the repo root finishes clean

🤖 Generated with Claude Code

kumilingus and others added 5 commits April 24, 2026 21:12
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…add README

Move the 5-node demo graph into src/shared/example-graph.js so ui-thread
and web-worker variants differ only in where the router runs. Document
all three variants in js/README.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kumilingus kumilingus merged commit 416afc0 into main Apr 24, 2026
1 check passed
@kumilingus kumilingus deleted the feat/libavoid-web-worker-perf-demo branch April 24, 2026 20:43
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