Skip to content

Conversation

KDr2
Copy link
Member

@KDr2 KDr2 commented Jan 5, 2022

Besides adding TapeInstruction, I did a little code refactor in #100, and I'd like to move that refactor onto master branch before doing benchmark and performance optimization.

@KDr2
Copy link
Member Author

KDr2 commented Jan 5, 2022

It mainly did two things:

  • Moved instruction counter from task to tape.
  • Optimized the code structure of task copying.

@KDr2 KDr2 requested a review from yebai January 5, 2022 01:00
@yebai yebai requested a review from phipsgabler January 5, 2022 10:34
@yebai
Copy link
Member

yebai commented Jan 5, 2022

@phipsgabler @devmotion we are now entering the design and performance optimisation phase of the new tape mechanism since the functionality has been proven correct (TuringLang/Turing.jl#1757). Please comment on any issues so that we can gradually build a lightweight, performant, maintainable tape implementation. The tape implementation will be moved into Tapir later when it is more mature.

@KDr2 KDr2 requested a review from yebai January 5, 2022 12:19
for instruction in tape
instruction()
increase_counter(tape)
end
end
Copy link
Member

Choose a reason for hiding this comment

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

Intuitively, I'd have expected this to also return the result of the function. Or is that extracted in another place?

Copy link
Member Author

Choose a reason for hiding this comment

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

The result is stored in Instruction.output.

tape.owner = tf
return tf
end

function Base.show(io::IO, tf::TapedFunction)
buf = IOBuffer()
Copy link
Member

Choose a reason for hiding this comment

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

Why the extra buffer? You could directly println to io.

Copy link
Member Author

Choose a reason for hiding this comment

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

Here I use an extra buffer, because that there are too many calls to println with io (which is stdout in most situations). And between these calls, the current task may be switched off, then Juia does some print in another task, and then switched on. In that case, the output will not be continuous and that makes it annoying to read.

Copy link
Member

Choose a reason for hiding this comment

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

Good reason. Then put a comment there to remind future readers why this should not be refactored.

@KDr2 KDr2 requested a review from phipsgabler January 6, 2022 00:18
@yebai yebai merged commit d27401a into master Jan 6, 2022
@delete-merged-branch delete-merged-branch bot deleted the basic-refactor branch January 6, 2022 10:26
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 this pull request may close these issues.

3 participants