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

Idea: Immutable lists with modifications returning new lists - look into Relaxed Radix Binary Trees #104

Open
TysonAndre opened this issue Feb 3, 2022 · 1 comment

Comments

@TysonAndre
Copy link
Owner

TysonAndre commented Feb 3, 2022

Google searching mentioned Relaxed Radix Binary Trees, an immutable datastructure surprisingly claiming performance near arrays in most operations.
https://hypirion.com/musings/thesis https://github.com/hyPiRion/c-rrb

  • gc may be difficult, immutable lists should either contain ranges of values or other immutable lists?
  • once a reference count drops to 1 (the container is the only reference) lists can be extracted and reused (and unused elements can be garbage collected)?
@TysonAndre
Copy link
Owner Author

Those are technically logarithmic, the log depth is just small for realistic amounts of memory (only several times slower than arrays in that language).

Transients are a lot less convenient in php.

PHP's gc algorithm also poses unique problems - gc will be slow if a lot of immutable collections reference the same array

Something simpler that would have okay typical-case but worse worst-case performance: Storing references to at most 4 zend_array (packed list) instances/ImmutableList/individual zvals internally (and ranges of those arrays) may work for some common use case, for the head/tail for appending/prepending, combining them in place/freeing internally when reference counts drop to 1

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

No branches or pull requests

1 participant