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

Performace optimization for project-saving #369

Closed
nighca opened this issue Apr 23, 2024 · 2 comments · Fixed by #630
Closed

Performace optimization for project-saving #369

nighca opened this issue Apr 23, 2024 · 2 comments · Fixed by #630
Assignees

Comments

@nighca
Copy link
Collaborator

nighca commented Apr 23, 2024

Possible approaches:

  • Avoid unnecessary uploading (when no change of file content) for

    for models (sprite/stage/...)

  • Avoid parseProjectData in save (models/common/cloud.ts)

  • Upload (local) file when added to project, instead of upload when saving project (Will revisit this after Automatically save project to cloud #541 is done)

  • Save code content to DB instead of OSS?

@aofei
Copy link
Member

aofei commented Jun 14, 2024

To minimize the occurrence of file uploads to OSS, we will implement the following changes:

  • For plain text files, we will no longer upload them to OSS. Instead, we will use Data URLs to store their contents, e.g., data:text/plain;charset=utf-8,Hello%2C%20world%21. Additionally, we need to impose some length restrictions on file contents. Thanks to the flexibility of Data URLs, we may consider extending this approach to other file types in the future.
  • For files with no content, such as empty code files or resource files, we will use data:, as the file URL.
  • For other files, we will adopt an "upload only upon addition" policy, as these files are unlikely to change once added.

To accelerate file uploads, we may consider the following strategies:

  • Given that our objects' universal URLs contain the file hash, and assuming that identical hashes indicate identical content, we can store all obtained universal URLs locally. Before uploading any file, we will compute its hash locally and check the local storage for existing entries. If a match is found, we can reuse the existing file without uploading, reducing redundant uploads (though this kind of improvement may not be that significant).
  • To prevent excessive local storage usage due to saving universal URLs, we can utilize an eviction algorithm, such as LRU.

@nighca
Copy link
Collaborator Author

nighca commented Jun 17, 2024

Now we save universal URLs with file instances (in file meta). Assuming that we save small plain text files directly in field files of project / asset. Most of the "uploading-to-OSS" behaviors are already avoided.

Then the adoption of local storage for existing entries (let's call it "entry-map") will not be urgent.

These files will still be uploaded:

  • Asset files generated by Buider (edited with sound-editor, image-editor, etc.)
  • Asset files directly from user's local disk

For asset files generated in Builder, they are edited in Builder, so it's not likely for them to keep the same hash after editing and the entry-map will not help.

For asset files directly from user's local disk, it's small probability event for a user to add the same file to project more than once —— whose uploading will be skipped with entry-map.

So I think we do not need to implement entry-map this time. It may become important in some future day, we can do it then.

Or we may treat the "universal URL in file meta" as a simple version of "entry-map", which does not require cache elimination mechanism like LRU.

aofei added a commit to aofei/.goplus.builder that referenced this issue Jun 28, 2024
aofei added a commit to aofei/.goplus.builder that referenced this issue Jun 28, 2024
aofei added a commit to aofei/.goplus.builder that referenced this issue Jun 28, 2024
aofei added a commit to aofei/.goplus.builder that referenced this issue Jun 28, 2024
aofei added a commit to aofei/.goplus.builder that referenced this issue Jul 2, 2024
- Removed the "codeFile" concept from sprite and stage models introduced
  in goplus#508. Since goplus#617, lazy-loading for plain text files is no longer
  needed.
- Avoided redundant `parseProjectData` in `@/models/common/cloud.save`.

Fixes goplus#369
aofei added a commit to aofei/.goplus.builder that referenced this issue Jul 3, 2024
- Removed the "codeFile" concept from sprite and stage models introduced
  in goplus#508. Since goplus#617, lazy-loading for plain text files is no longer
  needed.
- Avoided redundant `parseProjectData` in `@/models/common/cloud.save`.

Fixes goplus#369
@aofei aofei closed this as completed in #630 Jul 3, 2024
@aofei aofei closed this as completed in bccc791 Jul 3, 2024
nighca added a commit that referenced this issue Jul 25, 2024
* refactor: sound editor & recorder (#607)

* refactor: sound editor & recorder

* better animation & cache

* fix: export with gain

* fix: not emitting stop on end

* reset progress on stop

* cleanup & comments

* refactor:

* refactor:

* move to a seperate dir

* uninstall wavesurfer

* add comments

* Fix last-select issue when project switched (#612)

* fix last-select issue when project switched

* avoid effectScope

* Model `Animation` (#609)

* model animation

* prettier

* typo

* Costume pre-processing: split-sprite-sheet (#614)

* costume preprocessing

* details

* typo

* Remove right-click menu for backdrop (#616)

fix #606

* fix normalizeAssetName (#619)

* Save text files directly to the DB for performance (#617)

Updates #369

* update model animation (#620)

* component `AnimationSettings` (#621)

* component AnimationSettings

* use UIIcon instead of inline svg

* fix svg icon

* fix cancelled warning in console (#625)

* fix(spx-gui): save to cloud after sharing project and remove login requirement for making signed web URLs (#631)

Fixes #627

* refactor(spx-gui): remove "codeFile" concept and optimize project saving (#630)

- Removed the "codeFile" concept from sprite and stage models introduced
  in #508. Since #617, lazy-loading for plain text files is no longer
  needed.
- Avoided redundant `parseProjectData` in `@/models/common/cloud.save`.

Fixes #369

* Animation Editor UI (#626)

* feat: modal

* feat:

* modals

* remove checkerboard files

* feat: sound playing

* image preload

* refactor

* hide onTouched (#632)

* Update code-editor for animation (#629)

* update code-editor for animation

* update costume tools

* fix costume add

* Preload frames & audio / removal modal (#633)

* feat: remove costume & preload frames

* fix: use ref for muted

* animation details (#634)

* Update docs (#636)

* update docs

* add screenshot

* Use center point as sprite pivot (#615)

* use center point as sprite pivot

* upgrade spx

* refactor preload / modify translation (#635)

* refactor preload / modify translation

* do not update on zero duration

* refactor: disposer

* refactor: use single watch hook

* fix: start timing / remove deep watch

* disposer -> disposable

* fix: use old sound on switch

* `RotationStyle` support (#639)

* Debug animation sound on project load (#640)

* add preview for `GroupCostumesModal` (#646)

* Product doc for Widget (#644)

* add en docs

* doc for widget

* Support remove-background (#650)

* support remove-background

* debug details

* api for aigc

* details

* add comment for TODO

* exclude image url targeting private network

* optimize details

* spx-gui: implement automatic project save to cloud (#649)

- Added functionality to automatically save projects to the cloud.
- Implemented retry mechanism for failed save attempts with `5s`
  intervals.
- Ensured debounce handling for save operations with a `1.5s` delay to
  prevent frequent saves.
- Monitored changes in exported game files to trigger auto-save.
- Saved to local cache if auto-save to cloud fails to prevent data loss.
- Cleared local cache after successful cloud save.
- Switched between saving to cloud and local cache based on
  connectivity.
  - Save to cloud when online.
  - Save to local cache when offline.
- Replaced the `Save` button in the `TopNav` with an auto-save status
  icon.
- Prevented the user from leaving the current project (navigating away,
  refreshing, or closing the page) when there are unsynced changes.

Fixes #541

* Uniform item style (#641)

* refactor: editor items

* undo changes for library AssetItem

* refactor: library item

* fix type error

* update project item design

* refactor: use UIBlockItem

* fix: ScratchItemContainer

* refactor: UISpriteItem

* sound & backdrop

* remove editor item

* refactor:

* refactor & update design

* update slot name

* refactor: small editor sound/sprite

* style cleanup

* refactors

* uiBlockItem default color to primary

* move components to a folder

* use visible instead of v-if

* img loading mask

* remove noLoadingMask option

* Migrate to ghcr.io (#654)

* dockerfile: utilize pre-built images for Go+ and Nginx (#660)

- Replaced manual installation with pre-built images for Go+ and Nginx.
- Modified CMD to enable log output.

* dockerfile: fix nginx.conf copy path (#661)

* spx-gui: avoid calling `next` within `router.beforeEach` (#664)

See https://github.com/vuejs/rfcs/blob/master/active-rfcs/0037-router-return-guards.md#motivation

* spx-gui: remove unnecessary `defineProps` and `defineEmits` imports (#666)

* adapt animation for spx API change (#647)

* pr-preview: use mirrors for Go and Node modules downloads during `docker build` (#667)

- Updated `Dockerfile`:
  - Introduced `ARG`s for base images and custom mirror configs.
  - Modified the `CMD` instruction to use `exec` for proper signal
    handling.
- Updated `scripts/pr-preview.sh`:
  - Refined `docker build` command to utilize the newly introduced
    `ARG`s.

* spx-gui: implement batched object URL processing and optimize lazy loading (#668)

- Extended `util.makeObjectUrls` with batching to queue and merge object
  URL requests.
- Updated `cloud.universalUrlToWebUrl` to use batched processing.
- Refactored `cloud.getFiles` and file creation process to support lazy
  URL resolution, addressing potential URL expiry issues.

Fixes #653

---------

Co-authored-by: ComfyFluffy <24245520+ComfyFluffy@users.noreply.github.com>
Co-authored-by: Aofei Sheng <aofei@aofeisheng.com>
nighca added a commit that referenced this issue Aug 16, 2024
* dropdown with tooltip (#594)

* feat: UIDropdownWithTooltip

* fix: missing import for UILoading

* fix: logic

* lint: enable vue/no-undef-components (#595)

* lint: enable vue/no-undef-components

* add comments

* fix: delay on click to stop SoundPlayer (#596)

* smoother waveform (#589)

* smoothed waveform

* update comments

* do not reload audio on record end

* adjust waveform scale to match scratch

* add comments

* load audio after recording (#598)

* Product doc for animation support (#597)

* product doc for animation

* update doc for animation

* refactor: sound editor & recorder (#607)

* refactor: sound editor & recorder

* better animation & cache

* fix: export with gain

* fix: not emitting stop on end

* reset progress on stop

* cleanup & comments

* refactor:

* refactor:

* move to a seperate dir

* uninstall wavesurfer

* add comments

* Fix last-select issue when project switched (#612)

* fix last-select issue when project switched

* avoid effectScope

* Model `Animation` (#609)

* model animation

* prettier

* typo

* Costume pre-processing: split-sprite-sheet (#614)

* costume preprocessing

* details

* typo

* Remove right-click menu for backdrop (#616)

fix #606

* fix normalizeAssetName (#619)

* Save text files directly to the DB for performance (#617)

Updates #369

* update model animation (#620)

* component `AnimationSettings` (#621)

* component AnimationSettings

* use UIIcon instead of inline svg

* fix svg icon

* fix cancelled warning in console (#625)

* fix(spx-gui): save to cloud after sharing project and remove login requirement for making signed web URLs (#631)

Fixes #627

* refactor(spx-gui): remove "codeFile" concept and optimize project saving (#630)

- Removed the "codeFile" concept from sprite and stage models introduced
  in #508. Since #617, lazy-loading for plain text files is no longer
  needed.
- Avoided redundant `parseProjectData` in `@/models/common/cloud.save`.

Fixes #369

* Animation Editor UI (#626)

* feat: modal

* feat:

* modals

* remove checkerboard files

* feat: sound playing

* image preload

* refactor

* hide onTouched (#632)

* Update code-editor for animation (#629)

* update code-editor for animation

* update costume tools

* fix costume add

* Preload frames & audio / removal modal (#633)

* feat: remove costume & preload frames

* fix: use ref for muted

* animation details (#634)

* Update docs (#636)

* update docs

* add screenshot

* Use center point as sprite pivot (#615)

* use center point as sprite pivot

* upgrade spx

* refactor preload / modify translation (#635)

* refactor preload / modify translation

* do not update on zero duration

* refactor: disposer

* refactor: use single watch hook

* fix: start timing / remove deep watch

* disposer -> disposable

* fix: use old sound on switch

* `RotationStyle` support (#639)

* Debug animation sound on project load (#640)

* add preview for `GroupCostumesModal` (#646)

* Product doc for Widget (#644)

* add en docs

* doc for widget

* Support remove-background (#650)

* support remove-background

* debug details

* api for aigc

* details

* add comment for TODO

* exclude image url targeting private network

* optimize details

* spx-gui: implement automatic project save to cloud (#649)

- Added functionality to automatically save projects to the cloud.
- Implemented retry mechanism for failed save attempts with `5s`
  intervals.
- Ensured debounce handling for save operations with a `1.5s` delay to
  prevent frequent saves.
- Monitored changes in exported game files to trigger auto-save.
- Saved to local cache if auto-save to cloud fails to prevent data loss.
- Cleared local cache after successful cloud save.
- Switched between saving to cloud and local cache based on
  connectivity.
  - Save to cloud when online.
  - Save to local cache when offline.
- Replaced the `Save` button in the `TopNav` with an auto-save status
  icon.
- Prevented the user from leaving the current project (navigating away,
  refreshing, or closing the page) when there are unsynced changes.

Fixes #541

* Uniform item style (#641)

* refactor: editor items

* undo changes for library AssetItem

* refactor: library item

* fix type error

* update project item design

* refactor: use UIBlockItem

* fix: ScratchItemContainer

* refactor: UISpriteItem

* sound & backdrop

* remove editor item

* refactor:

* refactor & update design

* update slot name

* refactor: small editor sound/sprite

* style cleanup

* refactors

* uiBlockItem default color to primary

* move components to a folder

* use visible instead of v-if

* img loading mask

* remove noLoadingMask option

* Migrate to ghcr.io (#654)

* dockerfile: utilize pre-built images for Go+ and Nginx (#660)

- Replaced manual installation with pre-built images for Go+ and Nginx.
- Modified CMD to enable log output.

* dockerfile: fix nginx.conf copy path (#661)

* spx-gui: avoid calling `next` within `router.beforeEach` (#664)

See https://github.com/vuejs/rfcs/blob/master/active-rfcs/0037-router-return-guards.md#motivation

* spx-gui: remove unnecessary `defineProps` and `defineEmits` imports (#666)

* adapt animation for spx API change (#647)

* pr-preview: use mirrors for Go and Node modules downloads during `docker build` (#667)

- Updated `Dockerfile`:
  - Introduced `ARG`s for base images and custom mirror configs.
  - Modified the `CMD` instruction to use `exec` for proper signal
    handling.
- Updated `scripts/pr-preview.sh`:
  - Refined `docker build` command to utilize the newly introduced
    `ARG`s.

* spx-gui: implement batched object URL processing and optimize lazy loading (#668)

- Extended `util.makeObjectUrls` with batching to queue and merge object
  URL requests.
- Updated `cloud.universalUrlToWebUrl` to use batched processing.
- Refactored `cloud.getFiles` and file creation process to support lazy
  URL resolution, addressing potential URL expiry issues.

Fixes #653

* spx-gui: delay input URL processing in RemoveBackground component (#669)

* fix required prop warnings (#673)

* feat: add build script to support windows (#675)

* spx-gui: prevent event propagation on UICornerIcon click (#674)

* Fix animation sound loss during undo/redo (#718)

* fix warning

* fix animation sound during export & load

* keep order of sprites & sounds (#720)

* configurable AIGC feature (#726)

* Self-host monaco instead of `cdn.jsdelivr.net` (#729)

* spx-gui: upload files when adding resource (#732)

- Added loading message type for global loading-feedback.
- Integrated file upload process into `PreprocessModal`'s confirmation
  for files requiring preprocessing.
- Implemented loading message display for file uploads without
  preprocessing.
- Ensured resource addition only completes after successful file upload.
- Fixed filename change issue in `PreprocessModal` caused by
  `RemoveBackground` application.

Fixes #638

* feat: custom sprite transformer (#723)

* konva flip demo

* feat: sprite transformer

* update button color

* small refactors

* update vue-konva

* ui changes & flip in Transformer

* fix type error

* cursor behavior

* fix cursor when not dragging

* fix update on spriteRotationStyleChange

* move & refactor

* update cursor style

* not allowed cursor

* fix: centeredScaling

* add comment for flip button

* spx-gui: auto save unsaved changes on route change (#737)

We block route changes when there are unsaved changes using
`UIConfirmDialog`. For better UX, an automatic save is triggered when
the dialog is mounted, reducing the need for users to manually click the
`Save` button. If the save failes, users can simply retry by clicking
`Save`.

Fixes #665

* spx-gui(UIDropdown): fix `NPopover.setShow` not triggering `on-update:show` (#738)

* update favicon (#747)

* Automatically select the first animation on sprite switch (#749)

* Automatically select the first animation on sprite switch

* fix: not auto select on delete

* update casdoor config (#762)

* update casdoor config

* update backend env

* Widget Monitor (#676)

* widget monitor

* placeholder for empty widget list

* fix detail

* debug with spx

---------

Co-authored-by: ComfyFluffy <24245520+ComfyFluffy@users.noreply.github.com>
Co-authored-by: Aofei Sheng <aofei@aofeisheng.com>
Co-authored-by: molinla <61045398+molinla@users.noreply.github.com>
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 a pull request may close this issue.

2 participants