Game Development Community

Community testing of TorqueScript optimisations

by David Wyand · in Torque 3D Professional · 01/09/2013 (3:43 pm) · 40 replies

Greetings!

James Urquhart has submitted some TorqueScript optimisations as Pull Request 81 on GitHub. This involves hundreds of changes across many files. Almost everything to do with TorqueScript on the C++ side has been touched.

This is where you guys come in! Before I merge this request with the development branch I thought I would ask for your help in testing these changes. To make this as easy as possible I've created the consolefuncrefactor branch on the main Torque 3D repository. This means that if you've forked the repo you can do an update and start using this branch yourself (it is based on the T3D 2.0 development branch).

If you could try out the consolefuncrefactor branch and report back if it appears to be working well, or if you've found something odd, that would be great! I'm thinking we could leave this up for testing for a couple of weeks before merging back into the development branch (assuming all goes well).

Thanks!

- Dave

About the author

A long time Associate of the GarageGames' community and author of the Torque 3D Game Development Cookbook. Buy it today from Packt Publishing!

Page «Previous 1 2
#1
01/09/2013 (4:43 pm)
Do you want the code changes I made to the interpreter to try and take advantage of tail call optimizations? I can email that to the support email address.
#2
01/09/2013 (9:43 pm)
@Frank:
For this particular test I would like to keep the changes limited to this Pull Request. However, feel free to create a new Pull Request for your optimisations. Then we can review what you've done. Thanks!

- Dave
#3
01/10/2013 (8:15 am)
Dave, you might want to add this to a blog for higher visibility.
#4
01/10/2013 (4:01 pm)
Thanks David. Hopefully there shouldn't be too much of a problem with these changes since aren't as substantial as my "add arrays" branch. Most of the changes outside the console code are there to deal with typecasting issues with the console value type.
#5
01/11/2013 (1:11 pm)
@David,
That mean I need to understand GitHub better. Okay, I will set aside time to figure this out. So much "stuff" to learn. ;)

On this note, how do you download a repo that has been forked without it complaining that I have another project of the same name? I cannot for the life of me figure out how to do this from the GitHub GUI.
#6
01/11/2013 (2:55 pm)
Here are the github commands I used (I think these are right as i pulled them from my terminal history and tried to remove all the redundant ones)

Here are steps from my Mac using commandline git.

On github website fork repo to your account

//make a local directory and clone your repo
mkdir gitrepos
cd gitrepos
git clone https://github.com/<username>/Torque3D.git
cd Torque3D

//add GG repo as upstream
git remote add upstream https://github.com/GarageGames/Torque3D.git

//fetch it
git fetch upstream

//merge it
git merge upstream/master

//make sure your client is config with your info so your commits are setup right
git config --global user.name "yourname"
git config --global user.email "emailaddress"

//switch to master branch if you aren't already there
git checkout master

//checkout the development branch and put it in a local branch called development
git checkout -b development origin/development

//switch to development and make sure its up to date with gg development
git checkout development
git fetch upstream
git merge upstream/development

//Note: The following commands sets up the branch for the pull request

//Create your new branch for your pull request based on development
git checkout -b mynewbranchname development

//switch to new branch for pull request
git checkout mynewbranchname

//Edit the source files now to include your pull request changes

//git add your files

//git commit your files

//push your changes back to your fork on github
git push origin mynewbranchname

//Now you can setup the pull request on github website but make sure when you do that you select the correct branch on the GG side otherwise you might do a pullrequest of development with GG master which could be a ton of files you dont want to include.


Hope that helps.
#7
01/15/2013 (10:24 am)
Quote://Create your new branch for your pull request based on development
git checkout -b mynewbranchname development

//switch to new branch for pull request
git checkout mynewbranchname
Pretty sure the second step is unnecessary - doing git checkout -b creates the branch and checks it out instantly.

I'd help with this if I were at home! Unfortunately I won't be until March. Totally jumping right in then though.
#8
01/29/2013 (2:49 pm)
Got all my custom code merged into github.com/GarageGames/Torque3D/tree/consolefuncrefactor without too much trouble - most of the time was spent checking custom bugfixes and improvements over the last couple of years where already in the MIT.

Had a little play around with some basic Ai using stock scripts and some personal enhancements and other things for testing ( dynamically pose changing Ai from TS etc ) and a few simple TS tests on passing scripts back and forth. Everything seems fine with that.

I'll continue to port the entire game's script logic over tomorrow after reading through the MIT scripts for any major changes (I'm expecting the only additional content which I'm not using is going to be in player datablocks and first person weapon arms).

I know that there's been a few other script changes from the TSmanual.chm is different between 1.1F (my working version) and the new 1.2/2.0 MIT stuff, so I'll tackle that as issues arise.

I'll post an update when it appears to be working okay early on with a single battle play through and then give it some proper hard testing with a major campaign play through later.
#9
01/29/2013 (11:00 pm)
Cool beans, Steve. It is great to hear that someone is testing this out, and your game sounds like an excellent test!

- Dave
#10
01/30/2013 (8:48 am)

ISSUES ... of sorts ...


Note: all this happens in the stock github.com/GarageGames/Torque3D/tree/consolefuncrefactor code.

Array keys can only be added as a "string" not a numerical variable.

function startArrayTest()
{
	if(!isObject($arraytestList))
	{
		$arraytestList = new arrayobject();
		MissionCleanup.add($arraytestList);
	}
	
	$arraytestList.add(1,28);
	$arraytestList.add(3,18);
	$arraytestList.add(5,98);
	$arraytestList.add(7,38);
	$arraytestList.add(9,8);
	
	$arraytestList.echo();
}

The Value is written to the Key as well.
Quote:
==>startarraytest();
==>$arraytestlist.echo();
ArrayObject Listing:
Index Key Value
0 [28] => 28
1 [18] => 18
2 [98] => 98
3 [38] => 38
4 [8] => 8

Whilst passing as a string:
//...
	$arraytestList.add("1",28);
	$arraytestList.add("3",18);
	$arraytestList.add("5",98);
	$arraytestList.add("7",38);
	$arraytestList.add("9",8);
//...

Works as expected:
Quote:
ArrayObject Listing:
Index Key Value
0 [1] => 28
1 [3] => 18
2 [5] => 98
3 [7] => 38
4 [9] => 8

Now the docs do say "string" -
Quote:
add (string key, string value="")
- but this wasn't an issue in 1.1F.

Obviously passing as a %local is fine.

------------------------------

Array sorting value numerically ("sortna/sortda") has been reversed since 1.1F - something I was actually aware of from forum postings about a sorting issue using alpha sorting.

So "sorting numerical value ascending" now works as by going down as you read down the array - with highest first, so it ascends in numerical value if you read from the bottom of the array up
Quote:
==>$arraytestlist.sortna();
==>$arraytestlist.echo();
ArrayObject Listing:
Index Key Value
0 [5] => 98
1 [7] => 38
2 [1] => 28
3 [3] => 18
4 [9] => 8

And "sorting numerical value desending" works by going up as you read down the array - with lowest first, so it descends in numerical value if you read from the bottom of the array up
Quote:
==>$arraytestlist.sortnd();
==>$arraytestlist.echo();
ArrayObject Listing:
Index Key Value
0 [9] => 8
1 [3] => 18
2 [1] => 28
3 [7] => 38
4 [5] => 98

This is reversed from 1.1F to mention it again.

I'm not saying it's going the wrong way but can some one in programming authority check that this is working correctly? That an array's numerical value should be read from the back of the array and not the start?

EDIT

None of the above concerns appear to occur in the original T3D 2.0 github master branch - I've not tried the latest update, just the original ...because ... that bloody Windows interface is the devil's work.

So yeah - I do think it's doing it wrong now.

None "strings" go fine into array "keys" : eg: %array.add( 4, 80);

And numerical sorting works from the start/top of the array.
Quote:
==>$arraytestlist.sortna();
==>$arraytestlist.echo();
ArrayObject Listing:
Index Key Value
0 [9] => 8
1 [3] => 18
2 [1] => 28
3 [7] => 38
4 [5] => 98
==>$arraytestlist.sortnd();
==>$arraytestlist.echo();
ArrayObject Listing:
Index Key Value
0 [5] => 98
1 [7] => 38
2 [1] => 28
3 [3] => 18
4 [9] => 8
#11
01/30/2013 (9:16 am)
@Steve:
Thanks for testing things out. I'll have to look into your first issue of having to pass in a string to ArrayObject. I also believe that it should accept either a string or a number.

As for the sorting, there was a fix for 2.0 put in place for the sort() method and some of the other sorting methods. You can see the issue here: github.com/GarageGames/Torque3D/issues/120. So doing a sort(true) on your example array looks good to me (goes from low to high).

However, it looks like the numerical sorting doesn't match. Drat. I would think that sortna() should be equivalent to sortn(true), which should be equivalent to the string version of sort(true), at least for your example array.

As you mentioned in your edit, this doesn't have anything to do with the consolefuncrefactor branch. I'll open up a GitHub issue to track this.

- Dave
#12
01/30/2013 (11:12 am)
Yeah in the consoleTest, %array.sort() = %array.sort(false) = working descending in previous version
eg:
ArrayObject Listing:
Index Key Value
0 [5] => 98
1 [7] => 38
2 [1] => 28
3 [3] => 18
4 [9] => 8

And %array.sort(true); = working ascending in previous version
ArrayObject Listing:
Index Key Value
0 [9] => 8
1 [3] => 18
2 [1] => 28
3 [7] => 38
4 [5] => 98

I've got a feeling I used sortna/d because of the original issue in 1.1 with sort(bool).

Just to note, the latest version of the TS Manual.chm has:
void  sort (bool ascending=false) 
  Alpha sorts the array by value.  

//---------------

void ArrayObject::sort  ( bool  ascending = false  )   

Alpha sorts the array by value. 

Parameters:
 ascending  [optional] True for ascending sort, false for descending sort

Where I think ascending should be false - at least that's how it's working in practise.
#13
01/30/2013 (12:06 pm)
Just a little update on the var being eaten if not a string.

function startArrayTest()
{
	if(!isObject($arraytestList))
	{
		$arraytestList = new arrayobject();
		MissionCleanup.add($arraytestList);
	}
	
	%a = 97;
	%b = 42;
	
	$arraytestList.add(%a,14);
	$arraytestList.add(3,58);
	$arraytestList.add(5,0);
	$arraytestList.add(five,1);
	$arraytestList.add(9,icon);
	$arraytestList.add(87,%b);
	
	$arraytestList.echo();
}

Gives:

ArrayObject Listing:
Index   Key       Value
0      [97]    =>    14
1      [58]    =>    58
2      [0]    =>    0
3      [five]    =>    1
4      [9]    =>    icon
5      [87]    =>    42

So indexes 1 and 2 fail where numbers are used for key and value, but where word (string) or stringed number or local variable is used it's fine.
#14
01/31/2013 (3:06 pm)

Testing Update


Fully ported all scripts over, had to make a couple of minor changes here and there to how new things, mostly for newer engine changes (getPose() is now a string not a var, CameraOrbitObject has some awesome no penetrate code, really aggressive geometry avoidance - it's great but got stuck under my custom dirigible objects, swapping sortnd/a for sort(bool), etc).

Anyhow, I've had a full play through single battle mode with a mighty battle against the Ai and everything worked fine, nothing broke, nothing crashed, there were no errors in the console, game logic didn't do anything stupid. Things felt smoother performance-wise though that might just be me.

I've had a cursory test of the main campaign mode, flying around in a dirigble and annexing hexes for the regime, and that seems to work fine too at the moment.

Obviously I'll continue aggressive testing of the Campaign mode but things are certainly looking okay right now (save the code issues mentioned a few days earlier).
#15
02/01/2013 (3:09 pm)
@Steve:
Ascending should sort the array from the smallest value to the largest, so your example of:

Quote:And %array.sort(true); = working ascending in previous version
ArrayObject Listing:
Index Key Value
0 [9] => 8
1 [3] => 18
2 [1] => 28
3 [7] => 38
4 [5] => 98

looks correct, I believe. However, the default should probably be true rather than false, as ascending is usually what you want. Or did I not understand what you meant? Then we need to make sure the numeric versions work the same way.

- Dave
#16
02/01/2013 (3:12 pm)
Created a new issue to track the ArrayObject sorting: Issue 228

- Dave
#17
02/01/2013 (6:32 pm)
Yep, "sort(true)" works like that in practise, lowest first, getting higher. Script Manual CHM docs however say it's false <- hence I think the docs are wrong.

In other news, I've hit a repetitive crash bug ... but it's one of those annoying ones which crashes often but not everytime so repeating it is hit and miss. I know the vague circumstances of the crash, but not the exact location in the script/code - and I've had no luck getting it to crash on debug for feedback.

I'm thinking of porting it into the current 2.0 MIT release to see if it happens there as well.
#18
02/02/2013 (4:24 am)
@Steve, @David Thanks for taking the time to get to the bottom of this array sorting issue.

As for the crashing issue, please let me know if it's anything to do with the function refactor code.
#19
02/04/2013 (6:15 am)
Actually come to think of it, if "sort()" is descending than surely "false" should be ascending and not true ...
... ffs ... confusion! :P

------------------------------------------

In other news I'm getting odd behaivour in the "Options->Audio->Audio Provider". It should list xcode and OpenAL but OpenAL is replaced with the numbers "646466". I'm pretty certain it's OpenAL audio when I use it, but it lists the name as these numbers. Which is ... er, odd.

i.imgur.com/FnZcntH.jpg
[edit] Just to point out this doesn't happen on "master" branch which has directSound and Null also listed. I've not tried "development" branch.
#20
02/04/2013 (9:48 am)
Still can't get the Debug and Optimized Debug versions to exhibit the random crash I keep getting in Release. :(

I do notice a few bitStream errors called from BitStream.cpp line 337, BitStream::writeInt function.
BitStream::writeInt: value out of range"
Page «Previous 1 2