Skip to content

Conversation

metacosm
Copy link
Collaborator

Signed-off-by: Chris Laprun [email protected]

@metacosm metacosm self-assigned this Aug 28, 2025
@metacosm metacosm requested review from csviri and xstefank August 28, 2025 15:58
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 28, 2025
@csviri
Copy link
Collaborator

csviri commented Aug 28, 2025

I think we should agree that on these optimization issues we should see the numbers, so we can decide if it is worth it.
First of all on large resources this will have a huge memory overhead.
So we need to see, how faster is it (if it is faster at all), and how much more memory we consume.

But as we I think discussed before, there should be no blocking operation in desired state computation, that goes agains the pattern, calculating the desired (thus creating a pojo) is extremely fast - might be faster than getting a resource from a hash map (we need to measure), we should think though what we are actually optimizing with this.

@metacosm
Copy link
Collaborator Author

Agreed but it might also be a good idea to look at the different cache layers which are becoming too complex to properly maintain.

@csviri
Copy link
Collaborator

csviri commented Sep 22, 2025

Note that without this:
#2893
if the reconciler does not implement cleaner, there is no place where to clean those caches, since we don't receive the delete event now, when it should happen.

@metacosm
Copy link
Collaborator Author

Thinking about this some more, the memory usage should actually be minimal and there is no need to clean things because this isn't a new cache per se as the desired states are put in the Context object which doesn't survive past the reconciliation so these are short-lived versions of objects that are already computed so it shouldn't incur any additional memory than what is already used during the reconciliation.

@csviri
Copy link
Collaborator

csviri commented Sep 22, 2025

Thinking about this some more, the memory usage should actually be minimal and there is no need to clean things because this isn't a new cache per se as the desired states are put in the Context object which doesn't survive past the reconciliation so these are short-lived versions of objects that are already computed so it shouldn't incur any additional memory than what is already used during the reconciliation.

if it does not survive the reconiliation, why to cache it?
Now it does no use the context by a HashMap

@metacosm
Copy link
Collaborator Author

Thinking about this some more, the memory usage should actually be minimal and there is no need to clean things because this isn't a new cache per se as the desired states are put in the Context object which doesn't survive past the reconciliation so these are short-lived versions of objects that are already computed so it shouldn't incur any additional memory than what is already used during the reconciliation.

if it does not survive the reconiliation, why to cache it?
To avoid recomputing a potentially costly and non-idempotent desired state, which is something that people have run into several times already.

@csviri
Copy link
Collaborator

csviri commented Sep 22, 2025

To avoid recomputing a potentially costly and non-idempotent desired state, which is something that people have run into several times already.

In what use case is the desired state cumputation costy?
Could you pls link the issue here, so we have better clarity?
All that information should come from EventSource caches.

@csviri
Copy link
Collaborator

csviri commented Sep 22, 2025

TBH I don't like the fact that we are calling the desired either - and by definition idempotent function. But I'm not convinced that this is the way to solving or should be solved in generic way, users are able to optimize that in some edge cases already. But this is not a strong opinion, so if we are able to solve this elegantly withing the Context I'm open for that.

also maybe there is something I just don't see, so happy to dicuss further. Would be nice to see the users specific issue.

private final ControllerConfiguration<P> controllerConfiguration;
private final DefaultManagedWorkflowAndDependentResourceContext<P>
defaultManagedDependentResourceContext;
private final Map<DependentResource<?, P>, Object> desiredStates = new ConcurrentHashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This probably should be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants