Issues.00535 - lordmundi/wikidoctest GitHub Wiki

00535: optimize string stream operations in simdata transforms

« 00534 | Issues | 00536 »

Summary: optimize string stream operations in simdata transforms

Created: 2015–05–01 22:48

Status: Released

Category: Request

From: frankie

Version: 2.3

Released_In: 2.4

Description:

some of the transforms for the simdata plugin declare a stringstream object inside of a for loop which causes some overhead for allocation / deallocation.

This is a request to optimize this.


Comments

frankie May 01, 2015, at 11:34 PM: The tranforms have been optimized a bit to get rid of some of the stringstream operations. There are other stdlib operations that are still slowing down transforms, but this helps a bit. For example the code:

void input_matrix(double mat[][3], Values& ins, string prefix)
{
    for (int ii = 0; ii < 3; ii++) {
        for (int jj = 0; jj < 3; jj++) {
            stringstream strm;
            strm << "[" << ii << "][" << jj << "]";
            mat[ii][jj] = ins[prefix + strm.str()];
        }
    }
}

becomes:

void input_matrix(double mat[][3], Values& ins, string prefix)
{
    static char buf[4096];
    for (int ii = 0; ii < 3; ii++) {
        for (int jj = 0; jj < 3; jj++) {
            sprintf(buf, "%s[%d][%d]", prefix.c_str(), ii, jj);
            mat[ii][jj] = ins[buf];
        }
    }
}

Along with shifting away from stringstream to a standard C string and sprintf, this also gets rid of the allocation and deallocation that was happing inside the innermost loop.


« 00534 | Issues | 00536 »

Associated Commits

| commit | d4ee1ba7114163fe8806d2bc29f6a50575afc482 link5 | || | Author: | Frank Graffagnino | | Date: | Fri May 1 23:30:47 2015 -0500 | | Message: | [@Issue 00473, 00535, 00536, and 00537 Added crossplatform capability workaround specifying a transform in an api file when running on windows. I did this my moving the win32 versions of the transform binaries to .so files instead of .dll. I did this because they still seem to load just fine and it gets around having to put special new logic in simdata to try other file extensions. Also, as part of this commit, the makefiles were updated to produce these as .so files instead of .dll files. The tranforms have been optimized a bit to get rid of some of the stringstream operations. There are other stdlib operations that are still slowing down transforms, but this helps a bit. A new JEOD3 compatible transform that uses quaternions instead of rotation matrices was added in, but it should be noted that this transform does not convert things into ECEF like other do, so the earth (or other planet) nodes would need to be driven separately if using this transform. Lastly, the run batch files for windows were updated so that the search path (which is also used for libraries) will include the USERDATA/lib_Win32 path, which means that custom transforms can be saved off with the userdata as it should be. @] |

Affected Files:

lib_Darwin/orbital_body_transform.so               | Bin 0 -> 147840 bytes
 lib_Darwin/orbital_transform_jeod3_mod2.so         | Bin 147568 -> 156140 bytes
 lib_Darwin/orbital_transform_mmsev.so              | Bin 0 -> 129392 bytes
 lib_Linux_FC3/orbital_body_transform.so            | Bin 0 -> 405518 bytes
 lib_Linux_FC3/orbital_transform.so                 | Bin 412690 -> 295565 bytes
 lib_Linux_FC3/orbital_transform_jeod3_mod2.so      | Bin 482671 -> 414140 bytes
 lib_Win32/chutes.dll                               | Bin 1487285 -> 0 bytes
 lib_Win32/chutes.so                                | Bin 0 -> 1487285 bytes
 lib_Win32/cube.dll                                 | Bin 1487311 -> 0 bytes
 lib_Win32/cube.so                                  | Bin 0 -> 1487311 bytes
 lib_Win32/orbital_body_transform.so                | Bin 0 -> 3159689 bytes
 lib_Win32/orbital_transform.dll                    | Bin 3244850 -> 0 bytes
 lib_Win32/orbital_transform.so                     | Bin 0 -> 3244850 bytes
 lib_Win32/orbital_transform_jeod3_mod2.dll         | Bin 3271884 -> 0 bytes
 lib_Win32/orbital_transform_jeod3_mod2.so          | Bin 0 -> 3173492 bytes
 lib_Win32/plume.dll                                | Bin 1645769 -> 0 bytes
 lib_Win32/plume.so                                 | Bin 0 -> 1645769 bytes
 run_blank_graphics.bat                             |   2 &plusmn;
 run_client.bat                                     |   2 &plusmn;
 run_graphics.bat                                   |   2 &plusmn;
 run_manager.bat                                    |   2 &plusmn;
 run_standalone.bat                                 |   2 &plusmn;
 src.dist/defns.mk                                  |   2 &plusmn;
 &hellip;/plugins/playback/libapi/transforms/makefile    |   8 ++
 &hellip;/libapi/transforms/orbital_body_transform.cpp   | 154 +++++++++++++++++++++
 &hellip;/libapi/transforms/orbital_transform.cpp        |  24 +&plusmn;-
 &hellip;/transforms/orbital_transform_jeod3_mod2.cpp    |  24 +&plusmn;-
 27 files changed, 192 insertions(+), 30 deletions(-)