Skip to content

perf(machinery): improve built-in machinery performance#18665

Open
nijel wants to merge 1 commit intoWeblateOrg:mainfrom
nijel:weblatetm-perf
Open

perf(machinery): improve built-in machinery performance#18665
nijel wants to merge 1 commit intoWeblateOrg:mainfrom
nijel:weblatetm-perf

Conversation

@nijel
Copy link
Member

@nijel nijel commented Mar 26, 2026

  • add focused index with the exact conditions we use
  • cap limit of fetched results to avoid streaming too much data from the database
  • do cheaper exact lookup with 100% similarity

This is actually part of #18627, which has proven good results on production data. It won't fully address #18611 because the translation memory seems to be the bigger problem there.

@nijel nijel added this to the 5.17 milestone Mar 26, 2026
@nijel nijel requested a review from amCap1712 March 26, 2026 13:26
@nijel nijel self-assigned this Mar 26, 2026
@nijel nijel requested a review from AliceVisek as a code owner March 26, 2026 13:26
@nijel nijel requested a review from Copilot March 26, 2026 13:28
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 35d5ce511f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
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

Improves performance of built-in Weblate translation memory (machinery) lookups by tightening database indexing and reducing the amount of data fetched/processed per request.

Changes:

  • Add a partial trigram GIN index on Unit.source for translated, non-empty targets to better match TM lookup conditions.
  • Refactor Weblate TM lookup to build a narrower base queryset and cap fetched candidates; use exact lookup when threshold is 100.
  • Add/adjust tests for lookup behavior and document the improvement in release notes.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
weblate/trans/models/unit.py Adds a conditional trigram GIN index intended to accelerate TM source lookups.
weblate/trans/migrations/0068_unit_source_tm_index.py Creates the new partial index at the database level.
weblate/machinery/weblatetm.py Refactors the query strategy (subquery-based base queryset, exact-match path, candidate cap).
weblate/machinery/tests.py Adds tests covering the refactored lookup helpers and similarity threshold behavior.
docs/changes.rst Notes the machinery lookup performance improvement for 5.17.

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

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c44d936a61

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
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 6 out of 6 changed files in this pull request and generated 1 comment.


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

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 685a8dfcfe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@argos-ci
Copy link

argos-ci bot commented Mar 26, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 21 changed Mar 26, 2026, 5:22 PM

@nijel nijel requested a review from Copilot March 26, 2026 16:21
- add focused index with the exact conditions we use
- cap limit of fetched results to avoid streaming too much data from the
  database
- do cheaper exact lookup with 100% similarity
- order matches by similarity
Copy link
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 6 out of 6 changed files in this pull request and generated no new comments.


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

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