View previous topic :: View next topic |
Author |
Message |
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Fri Nov 25, 2005 1:01 am Post subject: RakNet Port |
|
|
Clay,
Which parts of RakNet did you not finish porting to D? In your RakNet port, it looks like you completed a lot. Do you have a "todo" list anywhere that I can reference?
Thanks,
JJR |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Sat Nov 26, 2005 4:14 pm Post subject: |
|
|
Use the sources themselves as the 'todo' list.
dmd -c source.d , if it doesn't compile, it isn't completed.
Unzip raknet.zip, if there is not a source with the equivilent filename in my source, it still needs to be done.
RakPeer.d is quite a challenge to get ported to D, and it is the heart of raknet.
Are you interested in trying to finish it? Or you just wanted to sample how hard it is to port to D
You must remember, using RakNet you are forced to use the GPL liscense. GPL tends to scare away many people. |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Sat Nov 26, 2005 4:23 pm Post subject: |
|
|
clayasaurus wrote: | Use the sources themselves as the 'todo' list. |
Okay... I guess that will work as an informal method.
clayasaurus wrote: | RakPeer.d is quite a challenge to get ported to D, and it is the heart of raknet. |
I'll take a peek in there to see the worst. Best to get a good impression of this early.
clayasaurus wrote: | Are you interested in trying to finish it? Or you just wanted to sample how hard it is to port to D
|
An interest in a little of both... But mostly I want to see if it's even a good idea. If I feel I can handle it, I might proceed further. A resolutely refuse to commit to anything at this point.
clayasaurus wrote: | You must remember, using RakNet you are forced to use the GPL liscense. GPL tends to scare away many people. |
Oh no! I didn't realize that. I don't like GPL one bit. Oh well. I may just consider the effort a source of practice then.
-JJR |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Sat Nov 26, 2005 4:30 pm Post subject: |
|
|
FYI, I should've added RakNet uses a triple liscensing scheme.
GPL for free.
Shareware " Compatible with proprietary licenses and closed source" I believe you have to pay money to Rakkar or ask permission to use it for free.
Commercial " Compatible with proprietary licenses and closed source" You can either pay more money to Rakkar or ask permission to use it for free.
Check out the site http://www.rakkarsoft.com/ and scroll to the bottom for more information on the triple-liscencing scheme. |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Sat Nov 26, 2005 4:32 pm Post subject: |
|
|
Okay... yes, now I remember seeing that at the bottom of the site. |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Sat Nov 26, 2005 9:27 pm Post subject: |
|
|
clayasaurus wrote: | Shareware " Compatible with proprietary licenses and closed source" I believe you have to pay money to Rakkar or ask permission to use it for free.
Commercial " Compatible with proprietary licenses and closed source" You can either pay more money to Rakkar or ask permission to use it for free. |
You don't need to pay anything to use it. He requires you to submit a 'permission request' to use it in commercial apps just so he can know who is using it where. He used to sell licenses, but he scrapped that and made everything free some time ago.
I don't think anyone would be *forced* to use the GPL. I mean, if you were to create a project here on dsource then yeah, it would have to be GPL. But it should be enough for someone to request a shareware/commercial license as normal and then use the D version as they see fit. After all, the source is available to modify as needed, and a port to D is one form of modification.
The best thing to do though would be to fire of an email to Rakkar once the port is complete and ask his opinion. |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Sun Nov 27, 2005 2:15 am Post subject: |
|
|
aldacron wrote: | The best thing to do though would be to fire of an email to Rakkar once the port is complete and ask his opinion. |
Actually, that's exactly the direction I was thinking of taking if I completed the port.
-JJR |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Tue Dec 13, 2005 4:57 am Post subject: Raknet Port to D |
|
|
I'm doing this the long and hard way. I've started from scratch. Clay, I realize that you've done a lot of the D code already for Raknet, but as I worked through the C++ source, I noticed that the port to D would provide plentiful opportunities for improvement of Raknet:
1) D is gc based, so there's opportunities for simplifying and optimizing code sections. It's amazing how much code and various checking blocks can be eliminated by using D features.
2) Array slicing is extremely useful in numerous places. It further reduces the C++ code complexity. I'm trying to make copious use of this feature.
Also copious use of static and dynamic arrays throughout and there ability to be accessed through pointers is proving quite useful.
3) I'm going to use Ares and Mango.io for the base; Mango merely for some text io stuff. I'm half tempted to use Mango for the network connection code too since much of the networking classes are coded somewhat similarly. But I figured I shouldn't get too carried away with that yet: I'll stick with converting what's there because most of it becomes more specialized than what Mango offers (BitStream...). I'll leave such experimentation for later times.
In short it's amazing how much of RakNet can be greatly simplified just by using D. I'm also thinking it might be useful to add some DbC code to verify that some of the ported classes are operating as they should. Unittests would, at the very least, be useful here to make sure things are working the way they should.
Since this is a buggy conversion process, testing the output of the classes bit by bit would a good idea.
All this will take awhile, though. I'll keep plugging at it. It's really quite fun to see how D can improve on things. I look forward to seeing the performance comparisons between D and C++ in the end.
-JJR
PS. I'm also following mostly D name style conventions in the port. This may not be popular with some; but I'd like the port done in true D style. |
|
Back to top |
|
|
h3r3tic
Joined: 30 Mar 2004 Posts: 261 Location: Torun, Poland
|
Posted: Tue Dec 13, 2005 10:08 am Post subject: Re: Raknet Port to D |
|
|
JJR wrote: | 1) D is gc based, so there's opportunities for simplifying and optimizing code sections. It's amazing how much code and various checking blocks can be eliminated by using D features. |
I hope you're not going to depend on the GC to free any memory allocated. It will get really slow.
Quote: | PS. I'm also following mostly D name style conventions in the port. This may not be popular with some; but I'd like the port done in true D style. |
Great
Good luck with the port
/Tom |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Tue Dec 13, 2005 2:48 pm Post subject: |
|
|
Food for thought.
I'll see what needs to be done (or not be done!).
Thanks!
-JJR |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Wed Dec 14, 2005 7:04 pm Post subject: Re: Raknet Port to D |
|
|
h3r3tic wrote: | I hope you're not going to depend on the GC to free any memory allocated. It will get really slow. |
Why do you say that? |
|
Back to top |
|
|
h3r3tic
Joined: 30 Mar 2004 Posts: 261 Location: Torun, Poland
|
Posted: Wed Dec 14, 2005 7:20 pm Post subject: Re: Raknet Port to D |
|
|
aldacron wrote: | h3r3tic wrote: | I hope you're not going to depend on the GC to free any memory allocated. It will get really slow. |
Why do you say that? |
Bad experiences with the GC. The general rule for realtime apps is to allocate as little as possible in the main loop.
The GC can be fast, but when the application allocates lots of memory, garbage collections tend to take more than a few seconds. Even small allocations can cause this. I've been playing with my photon mapper, and while performing a walkthrough of the scene, I used to notice these freezes every few minutes that could last like 15 seconds when there was a lot of memory allocated. The interesting part was that these did only occur when the GUI was being drawn. I recognized this was because of the GC. Eventually, I've located the cause of these stalls. The GUI was doing some char -> dchar convertions every frame, which allocated memory on the heap. When I changed these by ripping the implementation out of phobos and giving it a fixed buffer allocated with malloc, stalls disappeared. Generally, I'm trying to use the normal 'new' as little as possible and call malloc instead. I'm eventually gonna do some memory pooling.
I wouldn't like to use any library which relied on the GC to clean it up, unless it had its own GC and memory allocated by it was really in small quantities.
Interestingly, there are more memory issues with dmd/win32. Try mallocing and freeing a randomly-sized block of memory in a loop. Check the program's memory usage curve. On my system it keeps rising and rising. Try the same thing with C++ thru MinGW, or whatever. The memory usage is constant. Yeah, DMD is trying to be smart by doing some chunked allocation or so. But it keeps quadrupling the memory usage for a program, thus making it thrash when it shouldn't.
This said, I prefer to keep my memory allocations as low as possible and manage them manually. The situation is likely to improve, but I wouldn't rely on a GC in a game's main loop anyway. AFAICS, dmd will look at any data that's similar to pointers, so if you have some semi-random data in huge amounts, like vertex data, textures, etc, it might classify some semi-random value as a pointer/reference and thus never free an unused resource. |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Thu Dec 15, 2005 11:32 pm Post subject: Re: Raknet Port to D |
|
|
Wow, I didn't realize I had so many posts here I'm in the time warp zone known as finals week right now.
Good luck on the port JRR! It is a huge task, but the rewards are great. I'm willing to be your beta tester when ever you are ready. Are you going to make a dsource project once/if you finish? How far along has you gotten, or did you just recently (3 days ago) decide to scrap and start over? RakNet is a great library and I'm sure everyone and their grandmother will want to get their hands on it once it is available for D However it is quite massive and I'll be very impressed if you manage to get not only native D code, but native D code from scratch with good D style in mind.
Also, another curious thing, what is motivating you to make the raknet port? I assume you need a good networking library for D, or is the gravitational pull of RakNet's greatness to big to escape .
Use as much DbC code as possible, too, and don't forget to triple comment /// important functions so you can DDoc them. |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Sat Jan 07, 2006 12:03 am Post subject: Re: Raknet Port to D |
|
|
clayasaurus wrote: | Good luck on the port JRR! It is a huge task, but the rewards are great. I'm willing to be your beta tester when ever you are ready. |
Clay, thanks. I'm still working on the port almost daily. I'm trying to do a clean job of it too. It is a huge task as I'm finding out; but if I do it steadily, I think I'll actually complete the task eventually . I'm also testing a some modules as I complete them. So far so good. As I get closer to completion, I would very much appreciate your help testing the whole thing.
claysaurus wrote: | Are you going to make a dsource project once/if you finish? |
I think that would be a good idea. Then others can give a hand cleaning it up and improving it. But I will have to talk with the Raknet author before any of that takes place (for proper permission).
claysaurus wrote: | How far along has you gotten, or did you just recently (3 days ago) decide to scrap and start over? |
Days go quickly, and I haven't got near as far as I wanted to. You wrote that on December 15, 2005 and already it's January 6, 2006. In that time, I've reimplemented (from scratch) only a few of the larger files and several of the smaller ones (almost 21 D source files completed; of course, some of these combine a C++ implementation and header file). Reformating the documentation takes a lot of time. Making sure I'm not making some huge D conversion errors takes even more. In many, many areas though, I'm finding D hugely simplifies the design. This, unfortunately, will lead to a slightly different RakNet interface for D... well, a much simpler interface so maybe it's not so unfortunate. I've decided against making a strict one-to-one port. I want this D port to be an improvement on the original, both in performance and readability; I think D is up to that challenge. Already, the D code formatting is a huge improvement on the C++ version.
claysaurus wrote: | RakNet is a great library and I'm sure everyone and their grandmother will want to get their hands on it once it is available for D However it is quite massive and I'll be very impressed if you manage to get not only native D code, but native D code from scratch with good D style in mind. |
I can only do my best. It may indeed be a miracle if it turns out okay. But if I do get it working as intended, I think it will be great. Most of the hard work of design has been done by Rakkar. If I successfully facilitate it's move to D, I'll be very happy. If the final style needs improvement, I'm sure some dsource contributers can help me get it up to par.
claysaurus wrote: | Also, another curious thing, what is motivating you to make the raknet port? I assume you need a good networking library for D, or is the gravitational pull of RakNet's greatness to big to escape . |
What is motivating me? I think it's the latter reason. RakNet's greatness struck me, and I got hopelessly intrigued with the idea of how it would look and work in D. I have no project at the moment that would make use of it. So that's why I'll benefit very much from anyone that can test the life out of the port when it's mostly complete.
I'm also attracted to the pure challenge of implementing something untried in D.
claysaurus wrote: |
Use as much DbC code as possible, too, and don't forget to triple comment /// important functions so you can DDoc them. |
I'm trying to use DbC where it's most fitting. As for DDoc, I will not look into it at present. There's way too much documentation to even deal with at this point. I'll leave that for a final cleanup task.
-JJR |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Sat Jan 07, 2006 12:21 am Post subject: |
|
|
Another wierd side effect of this port:
I've already come across a couple bugs in the C++ code.
It's amazing what a careful and slow conversion process can reveal.
-JJR |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|