Skip to content

PATCH /text Runtime Improvements#429

Merged
thehabes merged 9 commits into
developmentfrom
investigate-optimistic-locking-overwrite
Dec 10, 2025
Merged

PATCH /text Runtime Improvements#429
thehabes merged 9 commits into
developmentfrom
investigate-optimistic-locking-overwrite

Conversation

@thehabes
Copy link
Copy Markdown
Member

@thehabes thehabes commented Dec 9, 2025

Optimizes PATCH /line/:lineId/text endpoint performance by parallelizing Page and Layer RERUM updates.

Before: 4-5 seconds per request
After: ~0.75 seconds per request (85% improvement)

Changes

  • Parallelized independent Page and Layer RERUM writes using Promise.all()
  • Predict RERUM page ID upfront to enable parallel execution (Layer only needs the page ID, not the full update result)

Technical Details

The updatePageAndProject() function previously ran Page and Layer updates sequentially. Now it:

Determines if page will be saved to RERUM:

const willBeSavedToRerum = isAlreadyInRerum || hasContent

For pages with content (common case): Runs parallel optimization

const [, finalLayer] = await Promise.all([
  page.update(),
  updatedLayer.update()
])

For temp page updates runs sequential without RERUM layer update

const updatedPage = await page.update()
layer.pages[pageIndex] = updatedPage  // keeps local ID

Notes

This optimization works in conjunction with a MongoDB index (__rerum.slug) applied to the RERUM database via MongoDB Atlas UI. The index reduced db.findOne from ~460ms to ~30ms.

Closes #426

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread utilities/shared.js
@thehabes thehabes marked this pull request as ready for review December 10, 2025 17:17
@thehabes thehabes merged commit 2dae7bf into development Dec 10, 2025
11 checks passed
@thehabes thehabes deleted the investigate-optimistic-locking-overwrite branch February 20, 2026 16:42
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