Replies: 17 comments 7 replies
-
You are saying you would like to access the previous task "effective" usage. not declared one, right? |
Beta Was this translation helpful? Give feedback.
-
Yes exactly. I would also be happy with assigned only, if that was easier to access, but in the best case scenario i'd need the used. |
Beta Was this translation helpful? Give feedback.
-
I have also been suggested to do this through a plugin, would this be a good approach? |
Beta Was this translation helpful? Give feedback.
-
Possibly, not 100% it will be possible to access it via the task retry retry tho |
Beta Was this translation helpful? Give feedback.
-
However I find this approach convoluted. Would not be enough check the exit status for OOM error and decide if increase the mem or not? |
Beta Was this translation helpful? Give feedback.
-
I would not be sure how to make it work, maybe i am missing something. The thing is that if I have error 137 for the first 3 attempts, and I only increase memory then, and then at attempt 4 I have 140 and I want to increase time by 1 step only (because i supposedly not increase it in the steps before), I would need to "remember" that I did not increase it the last 3 times and I am unsure how to get that information |
Beta Was this translation helpful? Give feedback.
-
because now I am only able to increase time and memory by task.attempt (I do not know any other way, if there is maybe it is all I need :D), but that is blind of whether the attempts before had an error related to that specific resource (OOM for memory or OOT for cpus/time) and would increase it as if all the ones before were failing for that specific resource |
Beta Was this translation helpful? Give feedback.
-
I was playing with a configuration similar to this one to test this behaviour - and this is an example of the resources i got: |
Beta Was this translation helpful? Give feedback.
-
Indeed, the memory request should be a function taking the attempt and the exit code and returning the desired amount of memory. Note that the logic can be defined into a plain function and used in the memory directive, for example
Note the use of resourceLimits to cap the max amount of memory instead of |
Beta Was this translation helpful? Give feedback.
-
i've realised it's quire straightforward to implement the solution tracking the state of the previous task as your are suggesting. def state = [:]
def my_mem_request(task, Map state) {
// index of current execution
// find out the previous mem
def previous = state["${task.process}-${task.index-1}"] ?: (1.GB)
// compute the new one
def result = ( task.exitStatus == 137 )
? previous *2 // add here your increasing logic
: previous // same as before
// store for the next one
state["${task.process}-${task.index}"] = result
return result
}
process foo {
debug true
memory { my_mem_request(task,state) }
errorStrategy 'retry'
resourceLimits memory: 10.GB
"""
echo mem: $task.memory
exit 137
"""
} update:
|
Beta Was this translation helpful? Give feedback.
-
Amazing!! Paolo's magic! Thanks a ton :) |
Beta Was this translation helpful? Give feedback.
-
Paologpt |
Beta Was this translation helpful? Give feedback.
-
@pditommaso what do you think about storing a reference to the previous task in the task object e.g. this way the previous attempt can be used in config settings, whereas your custom function won't be accessible in the config |
Beta Was this translation helpful? Give feedback.
-
Not so keen to implement it as a core feature. Tracking all tasks in memory could require a lot of memory for very big runs |
Beta Was this translation helpful? Give feedback.
-
@pditommaso would there be any way to access the actual used resources? I tried to store them with the afterScript but i was not able to access any of the task.rss or task.vmem variables. If not accessible, do you think I could make that work with a plugin? |
Beta Was this translation helpful? Give feedback.
-
New feature
I need to assign a specific amount of resources on retry depending on the amount of resources used in the process run that failed previously.
So for instance, if a process has used 99% of memory and 10% of the requested time, I would increase memory and not time/cpus.
I would like to be able to access the task.previous resources to take the decision.
Usage scenario
When running a big analysis, with input files of different size, instead of increasing blindly all cpus, time and memory resources, if only the time was insufficient, one could leave the memory unchanged and increase only time and cpus and vice-versa. This would allow to spare some resources, especially when one does not know the software well and it is difficult to predict and when the input file sizes can vary a lot.
Suggest implementation
As suggested by @bentsherman, we could provide something like task.previous which refers to the previous task attempt. then you could use task.previous.workDir to get the previous task directory and inspect the .command.trace file to see what the cpu/mem usage was
Beta Was this translation helpful? Give feedback.
All reactions