Skip to content
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

@uppy/core: improve performance of validating & uploading files #4402

Merged
merged 21 commits into from
Apr 15, 2023

Conversation

mifi
Copy link
Contributor

@mifi mifi commented Apr 5, 2023

Pull out totals validation for Restrictions (maxTotalFileSize, maxNumberOfFiles)

don't do it for every file added, as it's very slow
instead do the check at the end, after all files are added/validated individually.
this allows us to easily work with 10k+ files
fixes #4389

also:

mifi added 6 commits April 4, 2023 23:09
don't do it for every file added, as it's very slow
instead do the check at the end when all files are added.
this allows us to easily work with 10k+ files
fixes #4389
packages/@uppy/core/src/Uppy.js Outdated Show resolved Hide resolved
packages/@uppy/core/src/Uppy.js Outdated Show resolved Hide resolved
Copy link
Member

@Murderlon Murderlon left a comment

Choose a reason for hiding this comment

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

Very nice!

packages/@uppy/core/src/Restricter.js Outdated Show resolved Hide resolved
packages/@uppy/core/src/Uppy.js Outdated Show resolved Hide resolved
@Murderlon Murderlon changed the title Performance improvements @uppy/core: improve performance of validating files Apr 5, 2023
mifi and others added 4 commits April 6, 2023 13:11
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
instead make more specific methods for sub-validation
also rename validateTotals to validateAggregateRestrictions
- handle errors centrally so that we can limit the amount of toasts (informers) sent to the users (prevent flooding hundreds/thousands of them)
- introduce FileRestrictionError which is a restriction error for a specific file
- introduce isUserFacing field for RestrictionError
@mifi
Copy link
Contributor Author

mifi commented Apr 6, 2023

I noticed another problem with massive amounts of toasts being generated if per file restrictions are added, so I did some rewriting so we can handle showing of toasts more centrally:

  • handle errors centrally so that we can limit the amount of toasts (informers) sent to the users (prevent flooding hundreds/thousands of them)
  • introduce FileRestrictionError which is a restriction error for a specific file
  • introduce isUserFacing field for RestrictionError which defines whether we should show it to the user or not (some restrictions are not to be shown to users)

packages/@uppy/core/src/Uppy.js Outdated Show resolved Hide resolved
packages/@uppy/core/src/Uppy.js Outdated Show resolved Hide resolved
packages/@uppy/core/src/Uppy.js Outdated Show resolved Hide resolved
mifi added 5 commits April 7, 2023 00:13
- show "%{count} additional restrictions were not fulfilled" for any restriction errors more than 4
- refactor/rename methods
- improve ghost logic/comments
- introduce new event "upload-start"  that can contain multiple files
- make a new patchFilesState method to allow updating more files
- unify "upload-start" logic in all plugins (send it before files start uploading)
- defer slicing buffer until we need the data
- refactor to reuse code
maybe it fixes the error
@socket-security
Copy link

socket-security bot commented Apr 10, 2023

New dependency changes detected. Learn more about Socket for GitHub ↗︎


👍 No new dependency issues detected in pull request

Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore foo@1.0.0 bar@* or ignore all packages with @SocketSecurity ignore-all

Pull request alert summary
Issue Status
Install scripts ✅ 0 issues
Native code ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues

📊 Modified Dependency Overview:

➕ Added Package Capability Access +/- Transitive Count Publisher
parcel@2.0.0-nightly.1278 None +0 devongovett
⬆️ Updated Package Version Diff Added Capability Access +/- Transitive Count Publisher
cypress@12.9.0 10.11.0...12.9.0 environment +0/-0 atofstryker

🚮 Removed packages: @parcel/transformer-vue@2.7.0

@mifi
Copy link
Contributor Author

mifi commented Apr 10, 2023

e2e issue seems to be cause by parcel: parcel-bundler/parcel#4155

however they haven't yet released a new version

@mifi
Copy link
Contributor Author

mifi commented Apr 10, 2023

ok i fixed it by upgrading to latest nightly build. do we accept the security risk of cypress' install script?

@mifi mifi changed the title @uppy/core: improve performance of validating files @uppy/core: improve performance of validating & uploading files Apr 10, 2023
Copy link
Member

@Murderlon Murderlon left a comment

Choose a reason for hiding this comment

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

Big PR with many improvements! I think this should be tested locally by at least another person before we merge.

packages/@uppy/core/src/Uppy.js Show resolved Hide resolved
packages/@uppy/core/src/Uppy.js Outdated Show resolved Hide resolved
packages/@uppy/core/src/Uppy.js Outdated Show resolved Hide resolved
merge it with RestrictionError
looks like the e2e tests are doing its job 👏
@mifi
Copy link
Contributor Author

mifi commented Apr 13, 2023

anyone else wanna do some testing/review of the code first or shall we merge this?:)

@arturi
Copy link
Contributor

arturi commented Apr 13, 2023

Yes, will test today!

this.#chunks[j++] = chunk

// Defer data fetching/slicing until we actually need the data, because it's slow if we have a lot of files
const getData = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to remember to port these to #4205, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, seems like that pr will get a merge conflict once we merge this

@arturi
Copy link
Contributor

arturi commented Apr 14, 2023

Tested, 10,000 small files — quick and smooth, tested S3 Multipart upload for good measure too — works :) Canceling the upload with 10,000 files results in UI not reacting for a couple of seconds (not frozen, but no feedback), then cancellation is successful. Not sure if we could (later) look into setting files: {} in state right away for better UX.

@mifi
Copy link
Contributor Author

mifi commented Apr 15, 2023

I noticed that too. Maybe we should introduce a "loading" state in Uppy when we need to wait for something, where we show a full-screen loading that blocks any user interaction. Else we could run into race conditions, e.g. if the user tries to cancel again, or they try to upload again, but the previous upload is still going on in the background, possibly causing issues.

Base automatically changed from concurrent-file-listing to main April 15, 2023 15:42
@mifi mifi merged commit 90f7fb9 into main Apr 15, 2023
20 checks passed
@mifi mifi deleted the performance-improvements branch April 15, 2023 15:50
@github-actions github-actions bot mentioned this pull request Apr 18, 2023
github-actions bot added a commit that referenced this pull request Apr 18, 2023
| Package                   | Version | Package                   | Version |
| ------------------------- | ------- | ------------------------- | ------- |
| @uppy/angular             |   0.5.2 | @uppy/progress-bar        |   3.0.2 |
| @uppy/audio               |   1.1.1 | @uppy/provider-views      |   3.3.0 |
| @uppy/aws-s3              |   3.1.0 | @uppy/react               |   3.1.2 |
| @uppy/aws-s3-multipart    |   3.2.0 | @uppy/react-native        |   0.5.1 |
| @uppy/box                 |   2.1.1 | @uppy/redux-dev-tools     |   3.0.2 |
| @uppy/companion           |   4.5.0 | @uppy/remote-sources      |   1.0.3 |
| @uppy/companion-client    |   3.1.3 | @uppy/screen-capture      |   3.1.1 |
| @uppy/compressor          |   1.0.2 | @uppy/status-bar          |   3.1.1 |
| @uppy/core                |   3.2.0 | @uppy/store-default       |   3.0.3 |
| @uppy/dashboard           |   3.4.0 | @uppy/store-redux         |   3.0.3 |
| @uppy/drag-drop           |   3.0.2 | @uppy/svelte              |   3.0.2 |
| @uppy/dropbox             |   3.1.1 | @uppy/thumbnail-generator |   3.0.3 |
| @uppy/facebook            |   3.1.1 | @uppy/transloadit         |   3.1.3 |
| @uppy/file-input          |   3.0.2 | @uppy/tus                 |   3.1.0 |
| @uppy/form                |   3.0.2 | @uppy/unsplash            |   3.2.1 |
| @uppy/golden-retriever    |   3.0.3 | @uppy/url                 |   3.3.1 |
| @uppy/google-drive        |   3.1.1 | @uppy/utils               |   5.3.0 |
| @uppy/image-editor        |   2.1.2 | @uppy/vue                 |   1.0.2 |
| @uppy/informer            |   3.0.2 | @uppy/webcam              |   3.3.1 |
| @uppy/instagram           |   3.1.1 | @uppy/xhr-upload          |   3.2.0 |
| @uppy/locales             |   3.2.0 | @uppy/zoom                |   2.1.1 |
| @uppy/onedrive            |   3.1.1 | uppy                      |   3.8.0 |

- @uppy/companion: increase max limits for remote file list operations (Mikael Finstad / #4417)
- @uppy/xhr-upload: fix type in README.md (Top Master / #4416)
- @uppy/core: improve performance of validating & uploading files (Mikael Finstad / #4402)
- @uppy/provider-views: Concurrent file listing (Mikael Finstad / #4401)
- @uppy/core,@uppy/locales,@uppy/provider-views: User feedback adding recursive folders take 2 (Mikael Finstad / #4399)
- @uppy/dashboard: Single File Mode: fix layout and make optional (Artur Paikin / #4374)
- @uppy/informer: add a check in `TransitionGroup` when component is null (Juan Belej / #4410)
- meta: Fix logos in all the readmes (Artur Paikin / #4407)
- meta: fix logo in readme (Kid / #4403)
HeavenFox pushed a commit to docsend/uppy that referenced this pull request Jun 27, 2023
| Package                   | Version | Package                   | Version |
| ------------------------- | ------- | ------------------------- | ------- |
| @uppy/angular             |   0.5.2 | @uppy/progress-bar        |   3.0.2 |
| @uppy/audio               |   1.1.1 | @uppy/provider-views      |   3.3.0 |
| @uppy/aws-s3              |   3.1.0 | @uppy/react               |   3.1.2 |
| @uppy/aws-s3-multipart    |   3.2.0 | @uppy/react-native        |   0.5.1 |
| @uppy/box                 |   2.1.1 | @uppy/redux-dev-tools     |   3.0.2 |
| @uppy/companion           |   4.5.0 | @uppy/remote-sources      |   1.0.3 |
| @uppy/companion-client    |   3.1.3 | @uppy/screen-capture      |   3.1.1 |
| @uppy/compressor          |   1.0.2 | @uppy/status-bar          |   3.1.1 |
| @uppy/core                |   3.2.0 | @uppy/store-default       |   3.0.3 |
| @uppy/dashboard           |   3.4.0 | @uppy/store-redux         |   3.0.3 |
| @uppy/drag-drop           |   3.0.2 | @uppy/svelte              |   3.0.2 |
| @uppy/dropbox             |   3.1.1 | @uppy/thumbnail-generator |   3.0.3 |
| @uppy/facebook            |   3.1.1 | @uppy/transloadit         |   3.1.3 |
| @uppy/file-input          |   3.0.2 | @uppy/tus                 |   3.1.0 |
| @uppy/form                |   3.0.2 | @uppy/unsplash            |   3.2.1 |
| @uppy/golden-retriever    |   3.0.3 | @uppy/url                 |   3.3.1 |
| @uppy/google-drive        |   3.1.1 | @uppy/utils               |   5.3.0 |
| @uppy/image-editor        |   2.1.2 | @uppy/vue                 |   1.0.2 |
| @uppy/informer            |   3.0.2 | @uppy/webcam              |   3.3.1 |
| @uppy/instagram           |   3.1.1 | @uppy/xhr-upload          |   3.2.0 |
| @uppy/locales             |   3.2.0 | @uppy/zoom                |   2.1.1 |
| @uppy/onedrive            |   3.1.1 | uppy                      |   3.8.0 |

- @uppy/companion: increase max limits for remote file list operations (Mikael Finstad / transloadit#4417)
- @uppy/xhr-upload: fix type in README.md (Top Master / transloadit#4416)
- @uppy/core: improve performance of validating & uploading files (Mikael Finstad / transloadit#4402)
- @uppy/provider-views: Concurrent file listing (Mikael Finstad / transloadit#4401)
- @uppy/core,@uppy/locales,@uppy/provider-views: User feedback adding recursive folders take 2 (Mikael Finstad / transloadit#4399)
- @uppy/dashboard: Single File Mode: fix layout and make optional (Artur Paikin / transloadit#4374)
- @uppy/informer: add a check in `TransitionGroup` when component is null (Juan Belej / transloadit#4410)
- meta: Fix logos in all the readmes (Artur Paikin / transloadit#4407)
- meta: fix logo in readme (Kid / transloadit#4403)
@mifi mifi mentioned this pull request Sep 13, 2023
2 tasks
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.

UI doesn't work satisfactory when adding 10k files
4 participants