Skip to content

perf(stack): reduce resource, chunk and actor stalls - #9

Draft
milesalexg-tech wants to merge 4 commits into
StackAnvil:mainfrom
milesalexg-tech:main
Draft

milesalexg-tech wants to merge 4 commits into
StackAnvil:mainfrom
milesalexg-tech:main

Conversation

@milesalexg-tech

@milesalexg-tech milesalexg-tech commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Resource-pack preparation could block connection threads, completed conversions accumulated without a retention limit, and chunk/actor work repeated while its inputs were unchanged. This change bounds background work and caches, skips irrelevant chunk cells, and reuses stable render data.

Changes

  • Move source ZIP loading, decryption, persistence, and definition construction onto bounded preparation workers. Hash and decode completed network downloads there as well, count missing chunks in constant time, and release ZIP inflater resources immediately. Keep storage publication and resource advertisement on the owning event loop, with stale tracker/storage/channel guards and explicit failure handling.
  • Separate in-flight conversion sharing from a completed LRU capped at 32 entries and 128 MiB of archive bytes plus estimated metadata. Bound converter/preparation queues, reject saturation without caller-thread fallback, and complete pending futures during shutdown. Preserve caching of unused downloaded INFO packs.
  • Classify palette entries once, skip sections without connected states, and limit neighbor refreshes to candidate cells on the relevant border. Preserve waterlogging and upper-door behavior.
  • Coalesce each connection's queued/executing chunk tick with a token-owned reservation. Release it on completion or rejection and retain dimension-replacement guards.
  • Fix private-profile preparation on macOS: canonicalize ancestor aliases while rejecting owned-root symlinks, copy profiles with portable filesystem APIs, and inspect exact process environments through Darwin APIs. Retry verified process-lifetime races without exposing arguments or environments.
  • Cache resolved actor draws across unchanged snapshots with a 1,024-entry LRU. Build a lazy effect-locator index once per accepted resource generation. Keep animated poses, UV expressions, scale, and yaw at their existing per-frame evaluation points.

The changes are folded into their owning upstreamable patches. Later patches are replayed with selected subpacks, builtin resource layers, custom conversion profiles, doors, and replaced-dimension checks preserved. Each owning patch includes updated review and testing context.

Validation

  • Full ViaBedrock build and all Checkstyle tasks: 1,155 tests passed, 30 skipped, zero failures/errors.
  • Full add-on build against the pinned ViaFabricPlus dependency and updated ViaBedrock library: 784 passed, 120 skipped, zero failures/errors; access-widener validation passed.
  • ViaProxy build: 4 tests passed. CubeConverter dependency build: 18 tests passed.
  • All 1,381 ViaBedrock classes/resources match both downstream packages byte for byte.
  • Clean full-stack replays reproduce the exact source trees used for the successful builds.
  • bun run pr check viabedrock applies the first upstreamable patch to the pinned upstream base without setup/deferred patches. That standalone checkout passes all 45 tests and both Checkstyle tasks.
  • bun run check and git diff --check pass. Full Bun suite on macOS: 206 passed, 4 skipped, zero failures. Six Python process-inspection regressions pass. The platform changes resolve the 18 original macOS failures; repeated process-churn checks exercise transient Darwin stack-copy races.
  • Focused regressions cover queue saturation/shutdown, cache eviction and oversized sharing, unused source downloads, stale publication, differential palette/border selection, tick reservation ownership, snapshot invalidation/LRU, and differential locator indexing. A 144-frame snapshot case resolves once; repeated locator requests across two geometries parse the model once.

No new live-server frame-time, FPS, or joining-time measurements were made. Completed-download inflation now runs off the event loop; client resource reloads and other workloads still need live profiling. These changes do not claim to eliminate every possible lag spike.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Bound completed conversions and background resource preparation, preserve
source caching, and guard lifecycle publication on connection event loops.
Skip irrelevant connected-block scans and coalesce queued chunk ticks.
Reuse immutable actor render snapshots and index effect locators once.

Fold improvements into their owning upstreamable patches and replay later
features with subpacks, builtin resources, doors and dimension guards intact.
Document focused regressions and complete build validation in review notes.
Resolve ancestor aliases before comparing owned paths, while rejecting
symlink roots and writable files and preserving exclusive creation,
ownership rechecks, source boundaries, and scoped fixture rollback. Bind
fixture previews and copied Java selections to their canonical paths.

Replace the GNU cp invocation with the filesystem copy API, preserving
timestamps and symlink bytes with a full-copy fallback. Share native
environment ownership inspection between launcher profiles and Wine
prefixes. On Darwin, use bounded KERN_PROCARGS2 reads through Python 3
instead of /proc or ambiguous ps output. Compare complete environment
values across path aliases, including destinations not created yet, and
fail closed if process inspection is unavailable without printing data.

Cover ancestor aliases, symlink refusals, source preservation, active
child processes, misleading arguments and variable names, and unavailable
inspection. All 18 baseline macOS failures are resolved; bun test passes
with 204 tests and four skips, and bun run check passes.
KERN_PROCARGS2 can return EIO when a process exits or changes its stack
after enumeration. The old helper treated that ordinary lifetime race as
an inspection failure, intermittently blocking safe prefix preparation.

Retry only stack-copy/parse races, at most three times with bounded waits.
Check PROC_PIDT_SHORTBSDINFO before discarding an exited or zombie entry,
and retain fail-closed behavior for persistent failures in a live process
or unavailable lifetime inspection. Keep exact NUL-delimited environment
matching and never publish process arguments or environments.

Add deterministic retry, lifetime, malformed-buffer, persistent-failure,
and native ABI tests, plus real rapid process-exit regression coverage.
Validate 1,000 live scans during process churn and ten repeated focused
native preparation suites without failures. Full bun test and typecheck
also pass.
Fold bounded completed-download decoding and constant-time chunk receipt into the resource cache owner. Preserve event-loop publication, session identity guards, exceptional negotiation completion, synchronous integration APIs, and ZIP inflater cleanup. Keep selected subpacks and archive path normalization in their existing owners. Full core, addon and proxy builds pass; the standalone owner passes 45 tests and Checkstyle. Clean replay reproduces the tested complete source tree.
AlexProgrammerDE added a commit that referenced this pull request Oct 10, 2026
Adapt the reviewed resource, chunk and actor optimizations from PR #9
onto the current stacks. Keep download verification and resource preparation
off connection event loops, bound worker queues and complete pending work
on shutdown. Reuse palette classifications, resolved actor draws and effect
locator indexes instead of repeating work for unchanged inputs.

Preserve the four-entry, 64 MiB conversion cache, weak actor ownership,
weak chunk reservations, sound sharing and repeated cursor crafting fixes.
Fold each feature into its existing owning patch and replay later features.
Leave the macOS tooling changes for separate integration because they
overlap existing workspace edits.

The full dependency build passes with 1,967 tests passed and 150 skipped.
The standalone cache patch passes 45 tests and both Checkstyle tasks.
TypeScript and patch whitespace checks pass. Live frame-time gains remain
unmeasured.

Co-authored-by: Miles Tech Studios <291174896+milesalexg-tech@users.noreply.github.com>
@AlexProgrammerDE

Copy link
Copy Markdown
Member

Manually integrated the reviewed resource, chunk and actor optimizations into main in eb94fe6. The commit and owning feature patches credit @milesalexg-tech as co-author.

Included:

  • Bounded resource workers for preparation and completed download hashing/ZIP decoding, with current-session publication guards and shutdown completion.
  • Constant-time download receipt accounting and immediate ZIP inflater cleanup.
  • Palette classification reuse and candidate-only connected shape scans, including border and upper-door behavior.
  • Resolved actor snapshot caching and an effect locator index with resource invalidation.

Preserved the current four-entry/64 MiB conversion cache limits, weak chunk reservations, weak actor ownership, sound sharing and cursor crafting fixes. Each change stays folded into its existing owning patch.

The macOS profile/process changes remain separate because they overlap existing workspace edits. This is a partial integration, so the PR remains open.

Validation: all four dependency builds pass, with 1,967 tests passed and 150 skipped. The standalone cache patch replays on pinned upstream and passes 45 tests plus both Checkstyle tasks. TypeScript and patch whitespace checks pass. No new live frame-time measurements were made.

This branch has not been deployed

No deployments
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.

2 participants