Skip to content

refactor: createVectorStoreNode refactoring and embeddings batching support (no-changelog) #13674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 13, 2025

Conversation

OlegIvaniv
Copy link
Contributor

@OlegIvaniv OlegIvaniv commented Mar 4, 2025

Summary

  • Refactor vector store node architecture into modular operation-based components
  • Implement batched document embedding to reduce embeddings API calls and speed-up insertion
  • UI rendering performance optimizations with debounced node updates

Changes

Vector Store Architecture Improvements

  • Restructured createVectorStoreNode into separate modules organized by operation type
  • Created dedicated handlers for each operation (load, insert, retrieve, update, retrieve-as-tool)
  • Added test suite for each operation handler

Embedding Performance Optimization

  • Implemented batched document processing for vector store insertions
  • Added configurable batch size parameter to control embedding operations
  • For node version 1.1+, documents are processed in batches instead of individually
  • Single embedding operation performed per batch to significantly reduce API calls

UI Rendering Performance

  • Added debounced rendering of workflow nodes and connections in canvas
  • Implemented dynamic debounce timing based on workflow execution state:
    • Fast updates during editing (0ms debounce)
    • Throttled updates during execution (200ms debounce, 50ms max wait)
  • Reduces CPU/memory usage during execution with large workflows

In my tests populating 500 items to QDrant vector store went from ~5mins to 10s.

Before

CleanShot.2025-03-04.at.12.50.00121221.mp4

After

CleanShot.2025-03-04.at.12.46.28.mp4

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/AI-749

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

- Introduce new 'Embedding Batch Size' parameter for vector store nodes
- Support batched document processing in node version 1.1+
- Update documentation and tests to reflect new batching functionality
@OlegIvaniv OlegIvaniv force-pushed the ai-749-speed-up-vector-store-ingestion branch from 04a8f4e to 579d8da Compare March 4, 2025 12:12
@n8n-assistant n8n-assistant bot added the n8n team Authored by the n8n team label Mar 4, 2025
Copy link
Contributor

@jeanpaul jeanpaul left a comment

Choose a reason for hiding this comment

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

I tested it locally, and seems to work nicely. I like how this splits up the operations and adds tests for each operation individually. Nice work.

Request some changes, which are mostly docs-changes in the readme and some comments that don't really add a lot of value at the moment.

@OlegIvaniv
Copy link
Contributor Author

Thanks for the review, @jeanpaul! I tweaked the docs a bit and included also a very small fix for filtering in retrieve-as-tool mode. Can you re-review, please?

@OlegIvaniv OlegIvaniv requested a review from jeanpaul March 13, 2025 11:02
jeanpaul
jeanpaul previously approved these changes Mar 13, 2025
Copy link
Contributor

@jeanpaul jeanpaul left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comments and fixing AI-740 in the process too! Looks good to me, and works as expected, so let's ship it!

Copy link

cypress bot commented Mar 13, 2025

n8n    Run #9753

Run Properties:  status check passed Passed #9753  •  git commit 382766ce6a: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 OlegIvaniv 🗃️ e2e/*
Project n8n
Branch Review ai-749-speed-up-vector-store-ingestion
Run status status check passed Passed #9753
Run duration 04m 39s
Commit git commit 382766ce6a: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 OlegIvaniv 🗃️ e2e/*
Committer Oleg Ivaniv
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 5
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 440
View all changes introduced in this branch ↗︎

Copy link
Contributor

✅ All Cypress E2E specs passed

1 similar comment
Copy link
Contributor

✅ All Cypress E2E specs passed

@OlegIvaniv OlegIvaniv merged commit b4672b8 into master Mar 13, 2025
37 checks passed
@OlegIvaniv OlegIvaniv deleted the ai-749-speed-up-vector-store-ingestion branch March 13, 2025 15:23
guillaumejacquart pushed a commit that referenced this pull request Mar 13, 2025
guillaumejacquart pushed a commit that referenced this pull request Mar 13, 2025
guillaumejacquart pushed a commit that referenced this pull request Mar 13, 2025
guillaumejacquart pushed a commit that referenced this pull request Mar 14, 2025
@janober
Copy link
Member

janober commented Mar 17, 2025

Got released with n8n@1.84.0

MrJasperTan pushed a commit to MrJasperTan/n8n that referenced this pull request Mar 17, 2025
xbinaryx pushed a commit to xbinaryx/n8n that referenced this pull request Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants