Context :
In my game I use sqlite database (import sqlite3).
The game saved every 2 mn few parameters in order to avoid to the end user to do a save.
The game uses for the save a dedicated panda task (base.taskMgr.add)
Issue :
I have a issue with the game play.
When the end user move the character, the character slow down when the save of the x,y,z coordinates of the character is done in the database.
Solution:
My idea is to use the python processes and pipe (from multiprocessing import Process, Pipe)
one process for panda
one process for the database
and a pipe to communicate between the 2 processes
I have understood that the panda3D task is executed in one process, and the tasks are executed one by one between 2 frames.
My PC have 4 processors : if panda3D runs in one processor and the database access is running in an other processor, I expect no slow down during the game.
My questions :
Do I have a good understanding of the root cause of the slow down ?
Before to continue and change drastically the code I would like to know if there is no restrictions/issues with panda3d and packaging ?
Do you know if this kind of development has been done with panda3d and is successful ?
Other solutions to avoid this kind of slow down during the game are welcome.
I’m not sure how good Panda works with multiprocessing Process/Pipe, I never tried that, but there are a few thing I’d suggest first before going that rout.
Make the character movement speed framerate independent. Even if the rendering slows down the characters will move with the same speed… unless we are talking about a drop from 60fps to 15fps then the shuttering will be noticeable no matter what you do.
:downloader: [02F02BC8] begin GET [ http://runtime.panda3d.org/morepy/cmu_1.9/win_i386/morepy.cmu_1.9.win_i386.xml ]
:downloader: [02F02BC8] begin GET [ http://runtime.panda3d.org/morepy/cmu_1.9/win_i386/morepy.cmu_1.9.win_i386.mf.pz ]
Installing Python standard library
Install complete.
:PackageInfo: Package morepy uses 17 MB
:AppRunner: Total Panda3D disk space used: 349 MB
:AppRunner: Configured max usage is: 2048 MB
Traceback (most recent call last):
File "C:\buildslave\rtdist-windows-i386\build\built\direct\showbase\Messenger.py", line 354, in __taskChainDispatch
File "C:\buildslave\rtdist-windows-i386\build\built\direct\showbase\Messenger.py", line 412, in __dispatch
File "C:\buildslave\rtdist-windows-i386\build\built\direct\p3d\AppRunner.py", line 755, in __startIfReady
File "VFSImporter", line 148, in load_module
File "C:\Users\philippe\Documents\game\editor\test\multiprocess\mp-V7.py", line 68, in <module>
oPipeParent, oPipeChild = Pipe()
File "C:\thirdparty\win-python\lib\multiprocessing\__init__.py", line 107, in Pipe
File "C:\thirdparty\win-python\lib\multiprocessing\connection.py", line 223, in Pipe
WindowsError: [Error 161] the path is not valid
I have tried to prepare the package with panda3d 1.8.1
I got the folwoing error message :
File "c:\python27\lib\multiprocessing\__init__.py", line 107, in Pipe
return Pipe(duplex)
File "c:\python27\lib\multiprocessing\connection.py", line 222, in Pipe
win32.PIPE_WAIT,
WindowsError: [Error 123] the syntax of the file name or the directory is incorrect
Failure on startup.
With 1.8.1 the directory used is : c:\python27\lib\multiprocessing
With 1.9.0 the directory used is : C:\thirdparty\win-python\lib\multiprocessing