Skip to content

Misc optimization#324

Merged
inetol merged 1 commit intodevfrom
opt-trix
Apr 26, 2026
Merged

Misc optimization#324
inetol merged 1 commit intodevfrom
opt-trix

Conversation

@inetol
Copy link
Copy Markdown
Member

@inetol inetol commented Apr 26, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR focuses on small performance/cleanup optimizations across the backend, mainly by reducing repeated global lookups, tightening some parsing logic, and simplifying response streaming paths.

Changes:

  • Refactor global mutable state from a single mutable object into dedicated live bindings (mutableDatabase, mutableHttpServer, mutableRootId) initialized via setters.
  • Micro-optimize hashing/token parsing (reuse ASCII85 options, avoid split() allocations).
  • Simplify document read endpoints by returning the ReadableStream directly via ctx.body(...) instead of hono/streaming.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/global.ts Replaces mutable object with mutableDatabase/mutableHttpServer/mutableRootId and setter functions.
src/init.ts Initializes the new globals via setters; computes and stores mutableRootId after migrations.
src/utils/document.ts Uses mutableDatabase and cached mutableRootId for name generation / ownership checks.
src/utils/crypto.ts Reuses ASCII85 options and avoids string splitting in verifyHash.
src/http/middleware/authorization.ts Avoids split(".") and swaps to mutableDatabase access.
src/tasks/list/sweeper.ts Uses mutableRootId and hoists env-derived age computations out of the loop.
src/http/handler.ts Switches Cache-Control mutation from append to set.
src/endpoints/** Mechanical updates to use mutableDatabase; some document endpoints return ReadableStream directly.
src/database/migration.ts Updates global access usage inside a migration hook (see review comments).
src/database/index.ts Replaces savepoint name generation with an incrementing counter; adds savepointId.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/database/index.ts
Comment thread src/utils/crypto.ts Outdated
Comment thread src/database/migration.ts
@inetol inetol marked this pull request as ready for review April 26, 2026 20:54
@inetol inetol added this pull request to the merge queue Apr 26, 2026
Merged via the queue into dev with commit f054023 Apr 26, 2026
1 check passed
@inetol inetol deleted the opt-trix branch April 26, 2026 20:56
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