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

NodePort generates garbage on GetConnections #148

Open
lucasmontec opened this issue May 26, 2019 · 7 comments
Open

NodePort generates garbage on GetConnections #148

lucasmontec opened this issue May 26, 2019 · 7 comments

Comments

@lucasmontec
Copy link

The method GetConnections() in line 210 of the class NodePort.cs, generates a list (line 211) for every call. This list could instead be in the class and be cleared every time the method is called, just updating references.

@Siccity
Copy link
Owner

Siccity commented May 27, 2019

I think silently altering a list after returning it could lead to some frustration if a user decides, for some reason, to store a reference to the list. How about a void GetConnectionsNonAlloc(List<NodePort>)?

Alternatively you can use ConnectionCount and GetConnection(int).

@lucasmontec
Copy link
Author

GetConnectionsNonAlloc(List)?

That would be perfect. Also, after trying to work with xNode I found really hard to extend it. All classes are very tight and allow for little modification. You should add more protected methods instead of private, or at least provide interfaces for us to implement our own versions of the same classes. I could do a PR for that if you want.

@Siccity
Copy link
Owner

Siccity commented Jun 1, 2019

Which methods do you mean in particular? I try to make it as open as possible, but I also sometimes mark methods private so internal stuff doesn't bloat the API

@Siccity
Copy link
Owner

Siccity commented Jun 1, 2019

As for interfaces, I'm already working on it for V2 at https://github.com/Siccity/xNode/tree/dev
It's a huge undertaking with many considerations to be taken.

@lucasmontec
Copy link
Author

Which methods do you mean in particular? I try to make it as open as possible, but I also sometimes mark methods private so internal stuff doesn't bloat the API

The main methods I was working with were Node methods. I wanted to override how they work to improve performance and reduce garbage to 0. We did this a while ago, me and a friend. We removed 100% of all allocations that xNode was doing. Since we use it in runtime and call some methods every frame, we needed to remove any allocations. But recently I wanted to update xNode to get all of the bug fixes and other things being developed, so I had to revert every change we made.

We changed mostly the usage of foreach, the creation of lists and other temporary variables. I don't remember exactly which methods, but having interfaces will solve this problem.

Thanks for xNode! This tool is indeed amazing. I'll wait for V2 then.

@lucasmontec
Copy link
Author

Have a coffee. That will replenish your energy ;)

@Siccity
Copy link
Owner

Siccity commented Jun 7, 2019

So here's an update. I tried making a NonAlloc method, but adding the ports to an existing list also creates garbage. I discovered ReadOnlyCollection and made a branch which is still very early in development. Performance wise it's much faster though.

https://github.com/Siccity/xNode/tree/dev-connections-performance

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

No branches or pull requests

2 participants