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

Add alignment_base #61

Open
tpgillam opened this issue Aug 3, 2022 · 0 comments
Open

Add alignment_base #61

tpgillam opened this issue Aug 3, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@tpgillam
Copy link
Owner

tpgillam commented Aug 3, 2022

Some nodes depend only on when knots occur, and not on their values.

For example, consider:

x = pulse(Hour(1))
y = align(1, x)

z = align(2, y)
w = align(2, x)

Because of the semantics of align, we know that z and w are identical timeseries, but currently TimeDag can't infer this.

We can add a class of optimisations by adding alignment_base(::Node) -> Node, which takes a node, and returns the "oldest ancestor" node which is known to have knots exactly aligned with it.

A new implementation of align(x, y) would then only depend on alignment_base(y), and not y itself.

In general, it is valid for alignment_base(x) = x as a fallback, but in some cases it's possible to do better — we just have to decide where on the node the alignment base is stored.

Option 1:

Add a Node.alignment_base::Maybe{Node} field, which is set iff the node has an alignment base other than itself.
The only problem with this is increasing the size of all Node objects, even when there isn't any more optimisation.

Option 2:

Add a level of abstraction, and only specify the new member on a new NodeWithAlignmentBase <: AbstractNode.
This avoids extra memory usage, but might create other issues

NB: care should be taken that everything works nicely with the identity map!

@tpgillam tpgillam added the enhancement New feature or request label Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant