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

Improve cache debugging with -dump-hashes #4367

Closed
bentsherman opened this issue Oct 3, 2023 · 1 comment · Fixed by #4369
Closed

Improve cache debugging with -dump-hashes #4367

bentsherman opened this issue Oct 3, 2023 · 1 comment · Fixed by #4369

Comments

@bentsherman
Copy link
Member

When I want to figure out why a cached task was unexpectedly re-executed, the current approach is to do both runs with -dump-hashes and diff the logs. But I have to do a lot of manual work to extract the relevant information from the logs in order to produce a proper diff.

@abhi18av used some bash magic in this blog post to do some of this work:

cat nextflow.log \
  | grep 'INFO.*TaskProcessor.*cache hash' \
  | cut -d '-' -f 3 \
  | cut -d ';' -f 1 \
  | sort \
  | tee tasks.log

But it is only a partial solution, still requires some manual effort to inspect the component hashes.

A simple improvement would be to log the hashes for a task in a single line, that way Abhinav's bash script could produce a diff with the component hashes.

The ideal solution would be to incorporate this bash script into Nextflow itself as some kind of report, or a new command like we did with nextflow inspect. Nextflow needs the information from two different runs, so it would be difficult to do in the run command, beyond logging separate reports during each run that the user must compare.

On the other hand, if the task cache could contain all the components of a task that are used to compute the task hash, we could reproduce the -dump-hashes output by querying the task cache and re-computing the component hashes. It could be a nice extension to nextflow log or a new command like nextflow diff.

The task cache current cannot do this, but we are planning to add inputs and outputs metadata to the cache as part of #3802 and #3849 , so maybe we can make it work for this purpose as well.

Related: #844

@pditommaso
Copy link
Member

A better approch could be to re-structure that output

private void traceInputsHashes( TaskRun task, List entries, CacheHelper.HashMode mode, hash ) {
def buffer = new StringBuilder()
buffer.append("[${safeTaskName(task)}] cache hash: ${hash}; mode: $mode; entries: \n")
for( Object item : entries ) {
buffer.append( " ${CacheHelper.hasher(item, mode).hash()} [${item?.getClass()?.getName()}] $item \n")
}
log.info(buffer.toString())
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants