Issue1245

Title Reusing TaskSpecificComponents that are used only in the constructor
Priority feature Status chatting
Superseder Nosy List clemens, florian, jendrik, malte, simon
Assigned To Keywords
Optional summary

Created on 2026-11-06.14:26:33 by florian, last changed by florian.

Messages
msg12193 (view) Author: florian Date: 2026-11-16.15:02:09
We used an LLM to write a prototype with the intention of not using it directly but to see how it approached some of the problems we ran into while thinking about the design.

One such problem is that components are constructed bottom-up, while we need information from a top-down traversal of the DAG to figure out which components are still needed in the future. This can be done in the function `TaskIndependentComponent::bind_task`. The idea is that we pass a context object through the entire construction and when binding a task-independent component, it tells the context about subcomponents it plans to bind before recursing into them (or it just tells the context that a recursion starts and the context can ask about the subcomponents).

The context maintains its retention set and updates it before every recursion. For that it needs to know which task-independent components are part of the DAG but not yet bound to a task. We have to be careful here about which components we store in the context: components bound to the task we are currently considering could be reused by nodes in the DAG reachable through non-task-transforming edges (ignoring edge direction). We also have to keep components alive that are bound to different tasks further up the tree (before a task transformation) if their task-independent components can be reached through future edges in the DAG in some way that would use the same task. The LLM-prototype used stack frames in the binding context for each level of the recursion. The frame stored the task and the pending subcomponents (direct successors of the DAG node that have not been bound yet).

We already have a method to collect subcomponents of task-independent components which we introduced for this functionality in iterated search. It is recursive however and also returns subcomponents of subcomponents. For this functionality, we have to add (or replace it with) a function that just returns direct successors.

We also discussed the idea that the components we want to keep around are those that have an incoming edge in the DAG that we didn't handle yet. It is not exactly clear to us but likely computing these edges at some time is equivalent to what we have in mind with checking reachability from unexplored edges in the stack frame.
msg12187 (view) Author: florian Date: 2026-11-06.14:26:33
When working on issue1234 we noticed a problem with our current design of binding tasks to task-independent components. So far, we assumed that the DAG created by task-independent components is mirrored by the created task-specific components. However, if a task-specific component P uses a nested component C only in its constructor, this is not the case. In the DAG of task-independent components P is a parent of C but in the created DAG of task-specific components, P does not store a pointer to C. This is problematic if C is also used by another component P' that is bound to the same task later on (for example, two heuristics both using the same landmark factory but only storing the resulting landmark graph). After P is created, it doesn't store a shared pointer to C and the reference counting cleans up C even though it is later still needed in the construction of P'.

We will try to solve this in the following way:
* When binding a task we create a context object and pass this through the recursive call. This context object stored shared pointers to task-specific objects we want to keep alive, analogous to the retention set we used for iterated search.
* In each binding step, we update the stored pointer so objects that are no longer needed are not kept alive (also like in iterated search).
* This might mean that we can move the caching that is currently done inside the task-independent components into the context class.
* Ideally the solution works for iterated search as well, so that we do not need two separate implementations of this idea.

When we first implemented the solution for the iterated search, we moved from the concept of a context class (called cache back then) to storing the already created objects inside the task-independent classes, so in a sense, we are undoing this change. As far as we are aware, the problems that caused us to change back then would be solved by updating the stored values during the binding step with the retention set idea. We don't have a complete picture of the design yet, though.
History
Date User Action Args
2026-11-16 15:02:09floriansetmessages: + msg12193
status: unread -> chatting
2026-11-06 16:08:30simonsetnosy: + simon
2026-11-06 14:26:33floriancreate