From: Yuan X. <xuy...@gm...> - 2008-01-27 14:31:49
|
Hi Hesham and all, > After profiling the server I saw SDL_GetTicks() is taking around 25% of the > time (in the tests I used 7 robots and with the single thread mode). To make > long short, I saw this loop (while) in simulationserver.cpp: > .... > Since SimulationServer::Step() takes care of this case > (int(mSumDeltaTime*100) < int(mSimStep*100)) I thought that while in Run() > is not necessary. So after commenting it out, SDL_GetTicks() takes less than > 10% of the time: The phenomenon is reasonable. Since the time queries are needed for timing in single thread, the percentage of queries means that your machine are light underload( not too busy ), I guess your robots did not do anything. You will notice that the percentage of queries will lower if robots are collides... But if you remove the codes, the timer is noneffective. Then if the robots collides, the server will very very slow, otherwise the simulation time elapse very quickly. You may ask why use query to get time, ok, I do not think it is a good idea. The server cycle is 20ms, but the time precision of Linux is only 10ms, some function such as "sleep" also can not help on it. In fact, SDL_GetTicks() is used to get "preciser"(seemly). And it is possibly that SDL causes the Input problem in multi-threads. I have some idea to this: 1. to get precise time, use RealTime-Linux as platform [It will narrow OS platform] 2. use a new thread to time, The timing is in InputControl thread in current multi-thread implementation, but query is also used(It can be improved little). [It may make the timing-thread busy, and can not guarantee precision.] 3. use other timer instead SDLTimer, such as boost::xtime. [It need more investigation.] > BTW, the other day I came across the multi-threaded version of ODE by Intel. Sounds interesting. > I think it's worth a try if Yuan has time to help :-) There is something > wrong with the multi-threaded mode of the server on my system. So first I > need to find out what's the problem. I am free recently. Give some hints of your problem. -- Best wishes! Xu Yuan School of Automation Southeast University, Nanjing, China mail: xuy...@gm... xy...@ya... web: http://xuyuan.cn.googlepages.com -------------------------------------------------- |