Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #31.
Updates
Updates Meilisearch section to use Pydantic v2. Performance is GREAT!
meilisearch-python-async
code from the prior version (using latest meilisearch-python-async version1.4.5
as of today)bulk_index.py
script is due to firing up multiple processes viaconcurrent.futures.ProcessPoolExecutor
Earlier version using Pydantic v1 ran in ~3.3 seconds, the new version with Pydantic v2 runs in ~2.7 seconds (on M2 macbook pro)..
Most of the runtime is spent in firing up the multiprocessor module. Although the total run time reduction in this case was relatively small, in a larger dataset (with millions of records), the initial overhead of spawning multiple CPU processes is totally worth it, as the async client will very efficiently process each batch with faster underlying validation logic (enabled by Pydantic v2).
Rule of thumb
@sanders41, I think that for best performance for async loading, it makes sense to wrap the validation logic for the data within the multiprocess logic, as you originally suggested. That allows users to exploit the best of the underlying CPUs as well as the event loop that's handling many batches concurrently. Let me know if you see anything that's off.