question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should parallel iterators support `copy.copy`?

See original GitHub issue

MutithreadIterators and MultiprocessIterator don’t correctly handles copy.copy. I propose to make MultithreadIterator.__copy__ and Multiprocessiterator.__copy__ raise NotImplementedError, if Chainer developers agreed.

Even though MultiprocessIterator once implemented (hopefully) correct __copy__ function (#3076), current code lacks some additional arguments. MultithreadIterator doesn’t implement __copy__ at all.

Currently there are very simple working tests about copy.copy as below. But these tests don’t ensure correct handling of race conditions, resource managements and etc.

I’m not sure about MultiNodeIteratorMaster or MultiNodeIteratorSlave, whereas I guess the situation is not much different.

In Chainer core, only this line uses copy.copy(iterator), and the usage is just a fallback of Itrator.reset. Both MultithreadIterator and MutliprocessIterator supports reset method.

The other usage founds in an example. This example uses a custom iterator, so it is unrelated.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Crissmancommented, Dec 11, 2018

Copy.copy approach has been replaced by the reset method, but for backward compatibility, we do not want to replace copy.copy with a NotImplementedError. We will raise a PR to add clarity to this.

0reactions
Crissmancommented, Jan 9, 2019

#5882 merged, so closing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parallel std::copy complexity - c++ - Stack Overflow
No, here is a counter-example, which if copying is expensive could incur some performance penalty due to the inability to move: struct S...
Read more >
Parallel Iterators — Ray 0.8.4 documentation
Print up to the first n items from this iterator. Copy this iterator n times, duplicating the data. of the data of this...
Read more >
Parallel Iterators Part 1: Foundations - Baby Steps
This means that the compiler will make a custom copy of the iterator specialized to that particular task, which is very amenable to...
Read more >
Iterator Concerns for Parallel Algorithms - open-std.org
This change guarantees that all iterators in parallel algorithms return a true reference, i.e., no copies are ever required, and the multi-pass guarantee ......
Read more >
Rayon support for walkdir iterators · Issue #21 - GitHub
Basically, parallel iterators generally require a rewrite to work in "push mode", versus sequential iterators, that act in pull mode.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found