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

Adds progress Allocation to represent Decentralized Allocation Tree node. #1298

Merged
merged 3 commits into from
Dec 5, 2018

Conversation

coollog
Copy link
Contributor

@coollog coollog commented Dec 4, 2018

Part of #1297. The Allocation class will be used by the ProgressEvent.

@coollog coollog requested a review from a team December 4, 2018 21:42
@loosebazooka
Copy link
Member

Not specifically about this, but autobuilder is a great alternative to writing these out by hand.

@coollog
Copy link
Contributor Author

coollog commented Dec 4, 2018

Hmm, I'm not sure if AutoValue Builder is able to work for the single-method builder we have here?

@chanseokoh
Copy link
Member

I see this will have no problem constructing the allocation tree.

However, I think I don't fully understand the intended usage in practice yet. I thought about some scenarios from the perspective of a developer trying to construct the whole tree with multiple depth of method calls and am left with some questions. For example, it isn't yet clear if whether it would be a caller or callee that should call newChild, if it is OK to pass the root or some child node to multiple, sequential method calls and/or pass the node down multiple call depth, if we can enforce matching the allocation units with the minimum number of newChild calls (or if it is necessary), what a callee should do if it just wants to mark completion (i.e., what info to emit as an event) when the allocation the callee got is a root node, etc. Perhaps better to ask these offline.

}

@Test
public void testFractionOfRoot_tree_complete() {
Copy link
Member

Choose a reason for hiding this comment

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

So I see this example shows that the expect normal usage is to match the number of children and the parent allocation units. As I said in my previous comment, I am really curious how this can pan out or be enforced efficiently in practice. But I think we can move forward with this now, and I'd be able to see if the API will work out to minimize errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, the user of the Allocation class will be responsible for sub-allocating the correct number of allocations. For example, for a task that knows it will launch 3 subtasks, it will first create its own allocation as 3 allocation units, and then launch the 3 subtasks, passing down its own allocation as the "parent" allocation, knowing that each of the subtasks will thus make a suballocation, resulting in 3 total suballocations.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, in that example, what if the writer of one of the subtasks (think of as separate methods) that get the "parent" allocation doesn't have anything to report progress or if the writer simply wants to mark completion before returning using the given parent allocation node? Should it emit an event with the parent node and 1 allocation done? But, in turn, what if the subtask called other methods and propagated down the parent node as-is? In that case, if the sub-subtasks did the same thing as what the subtask did (emitting the event with the parent node and 1 allocation done), the progress will go over the allocated amount.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, emitted an event with the parent node and 1 allocation done can work, or the subtask can create a suballocation and emit an event with all progress units in the suballocation. The allocation(s) are only to represent the subdivision of the overall progress and it will be up to the tasks to coordinate how to emit progress on those allocations (with the premise that parent tasks have power over child tasks) and up to the progress event listener to process the emitted progress in whichever way it chooses to do so (allow or disallow going over allocated amount, for eg.).

Copy link
Member

Choose a reason for hiding this comment

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

with the premise that parent tasks have power over child tasks)

Yeah, I think this premise is required for this work well. When the premise is applied recursively, I think it implies having power over all descendants. For example, if you are some subtask at some point, and you call several long-running external methods in sequence, you don't really know about whose internals. So, you just pass the allocation node you have, but you basically have no idea how those will make use up the node. They may or may not consume 1 allocation, or more. And those external methods may in the same situation recursively. So, basically, it looks to me that we should have the premise that parent tasks should have an idea about all descendants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, in our use case in the builder steps, this premise will be met by a constraint that

  1. A task may only create at most one suballocation of the parent allocation passed to it, and
  2. A task cannot pass the parent allocation on to subtasks

@coollog coollog merged commit af93240 into master Dec 5, 2018
@coollog coollog deleted the progress-1-allocation branch December 5, 2018 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants