replaced class with struct in ixy project - #2
Conversation
fixme in File.swift: deinit block commented out, so need to close(fd) somewhere else
|
Could you test the actual code or it's just a search / replace with compilation fixes? I don't have access to the actual hardware but replacing classes with structs would be my first guess too. But to get the most out of it I think a more functional approach would be better instead of going for OO-with-structs. |
it is just search/replace with compilation fixes, because have no hardware to test for real. |
|
I think using |
|
Thank you for your pull request, unfortunately it doesn't work :( Swift <= 5.0: doesn't compile Swift 5.1-dev LLVM b47beb8a70, Swift b9d082fac7: doesn't forward packets: (the I've also re-run master branch with this Swift 5.1-dev version and it slows down to 3.7 Mpps vs. 5.1 Mpps before |
|
It's been quite some time since I've written this code so I might be wrong, but I'm guessing that you'd have to rewrite a lot more of the code to support structs. |
i doubt i've found the problem. There is function withHugepageMemory in Queue, ReceiveQueue, TransmitQueue. in TransmitQueue: in ReceiveQueue: i tried compile the changed code with Swift version 5.0.3 (swift-5.0.3-RELEASE) and it was ok. |
yes, i'll try to change |
|
i replaced |
|
It might work, but as I said: there's more to it than just changing all classes to structs. This probably isn't the only place where structs are copied. You'll have to rework the whole code. tmpDescriptor is a copy from the descriptors, so processing it won't change the actual queue. |
yes, i think, it can be changed in this way: |
replaced for var with for indx removed passing by value
|
It's actually would be interesting to see how is Swift performing without ARC. |
changed class to struct where possible in ixy project; only class MemoryMap is still class.
Maybe replacing class with struct will solve retain/release problem: "A total of 76% of the CPU time is spent incrementing and decrementing reference counters".
fixme in File.swift: deinit block commented out, so need to close(fd) somewhere else.
used Swift version 5.1-dev (LLVM b47beb8a70, Swift fcc37cda9c)