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

feat(core): Add factory destroy policy 'never' (9.1) #2027

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

ibgreen
Copy link
Collaborator

@ibgreen ibgreen commented Mar 13, 2024

For #

Background

  • We have implemented caching via the Pipeline and Shader Factory classes.
  • This means that if the app is creating several identical such objects at the same time, we will only create one copy.
  • However we destroy cached elements as soon as they are no longer referenced.
  • An app that repeatedly creates and destroys an object (perhaps a temporary layer or transform) won't benefit.
  • While the perfect model would probably be a system that held on to only a certain number of released objects on an LRU-basis, that would require more book-keeping.
  • This. PR adds an experimental Device option _factoryDestroyPolicy: 'never' that simply stops destroying unused objects and keeps them in the cache.
  • Intended to allow us to test whether longer life of cached items has sufficient performance advantages to be worthwhile.

Change List

  • experimental Device option _factoryDestroyPolicy: 'never'
  • Factory classes copy the option and avoid destroying object if it is set.

@ibgreen ibgreen marked this pull request as ready for review March 13, 2024 11:54
// @deprecated Attach to existing context. Rename to handle? Use Device.attach?
gl?: WebGL2RenderingContext | null;
/** Never destroy cached shaders and pipelines */
_factoryDestroyPolicy?: 'unused' | 'never';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This line with the new option is the only significant change in this file, the rest was reorganization for readability as number of options grows.

@ibgreen ibgreen changed the title feat(core): Add factory destroy policy 'never' feat(core): Add factory destroy policy 'never' (9.1) Mar 13, 2024
@ibgreen ibgreen merged commit d472e79 into master Mar 13, 2024
2 checks passed
@ibgreen ibgreen deleted the ib/never-destroy branch March 13, 2024 16:58
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.

None yet

2 participants