-
Notifications
You must be signed in to change notification settings - Fork 370
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
Remove NodeCollection pointer from Node class #2601
Remove NodeCollection pointer from Node class #2601
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am seriously concerned about the performance consequences of this change. For spatial connectivity, neurons need to know which node collection they belong to. I expect that this change will make lookup noticeably slower, even though std::lower_bound()
has logarithmic complexity. We need to perform systematic benchmarks with spatial models before we proceed to avoid performance regressions on building.
I am also not happy with the mixed-camel-casing and would suggest clear_node_collection_container
and similar.
The functions using the |
@heplesser, I think last time you said that you might have been overthinking about the performance impact, but those new changes won't have any significant impact on the current performance. Can we merge this PR, as I need it for the new devices? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@med-ayssar Please see my comments inline. Also, the compiler seems to miss some things ;). My main concern is still performance. I will see if I can find some good benchmarks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy if you merge all my suggestions.
@heplesser: can you please re-review? Thanks! |
@jougs Sorry for the delay. I definitely want to run some benchmarks to check performance effects. I have located suitable benchmarks and will run them within two weeks. |
@heplesser: I think it can be merged now :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now. I performed benchmarks small and large and did not find any noticeable slowdown.
inline size_t | ||
NodeCollection::get_first() const | ||
{ | ||
return ( *begin() ).node_id; | ||
} | ||
|
||
inline size_t | ||
NodeCollection::get_last() const | ||
{ | ||
size_t offset = size() - 1; | ||
return ( *( begin() + offset ) ).node_id; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally realize that it is bad style if
- one of the original reviewers (me)
- comments on a merged pull request
- by a person not working on NEST anymore
🙈
But: couldn't this have been done like this?
inline size_t | |
NodeCollection::get_first() const | |
{ | |
return ( *begin() ).node_id; | |
} | |
inline size_t | |
NodeCollection::get_last() const | |
{ | |
size_t offset = size() - 1; | |
return ( *( begin() + offset ) ).node_id; | |
} | |
inline size_t | |
NodeCollection::get_first() const | |
{ | |
return begin()->node_id; | |
} | |
inline size_t | |
NodeCollection::get_last() const | |
{ | |
return ( end() - 1 )->node_id; | |
} |
Just sayin'...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was not that simple or better saying, things might get more ugly.
The begin
function returns an iterator
, and this iterator is a bit complex, as it hides the distinction between the primitive and composite types. Thus, begin()->node_id
won't work and also the operator-()
is not implemented.
The
Node
class does not need to know about the primitiveNodeCollection
object it belongs to. Therefore, theNodeManange
must keep track of the mapping between aNode
instance and theNodeCollection
container.This is a derived requirement for the Vectorization project of the Node class.