Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 22:31 18 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2 V5.05.06exp: Huge performance improvement - please test

     Page 4 of 8    
Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3865
Posted: 11:34am 22 Oct 2020
Copy link to clipboard 
Print this post

  matherp said  I assume you have a 400MHz CMM2?


Much to my chagrin "yes".

Then again, perhaps it is best for a developer to be running the lowest common denominator.

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3678
Posted: 12:14pm 22 Oct 2020
Copy link to clipboard 
Print this post

  thwill said  variable lookup in a subroutine depth N is always slower because if it first finds a global variable it has to keep searching to see if there is a LOCAL variable of the same name flagged with N.

I don't see why it would even look for a global until it has first looked for a local.

Only if there's no local (in the current SUB/FUNC) would it then look for a global.

John
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3865
Posted: 12:21pm 22 Oct 2020
Copy link to clipboard 
Print this post

  JohnS said  I don't see why it would even look for a global until it has first looked for a local.

Only if there's no local (in the current SUB/FUNC) would it then look for a global.

John


Except, at least in the model I've built up from what Peter has said previously in this thread and others, there is only one table containing the global and local variables and a traversal of that table under either scheme will almost always find the global definition first ... unless you did a linear search backwards, and even then it isn't guaranteed because a function/sub can create a global variable.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3865
Posted: 12:29pm 22 Oct 2020
Copy link to clipboard 
Print this post

... I think the way I would have done it would have been to store the local variables separately on a stack. Then when a lookup occurs first search down the stack until you reach the frame pointer (probably only a half dozen elements at most) and then switch to searching the global variables table. That would also make cleanup of local variables faster. However I assume there are good reasons for not doing it this way.

Another alternative (BBC Micro) is that when a local variable is declared the global variable that it shadows is transferred to the stack and the local variable takes its place in the main variables table. This makes lookup more efficient but declaration of locals and restoration of the main variables table on return more expensive.

Again this is only intellectual discussion not a request for a change to the implementation ... maybe I should put this in my signature

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 12:37pm 22 Oct 2020
Copy link to clipboard 
Print this post

  thwill said  Much to my chagrin "yes".

Then again, perhaps it is best for a developer to be running the lowest common denominator.

I would love to have a CMM2 running at 480Mhz too, but simultaneously I'm thinking in other users with 400Mhz playing my games.

I thinking a long time about the differences in the CPU speed, and this can occur in the future in a more aggressive way (imagine a CMM2 or CMM3 at 1Ghz).

I'm testing and trying to change the way my games are processed. Currently, all my programs use a frame limiter concept only, but if the demand for CPU is too higher the game will slow down and in some cases, this can be annoying for the gameplay.

In INTO THE DARKNESS I've implemented for the first time the frame time concept, and I will try to spread this to all my other programs, as with this implementation the speed always be the same making the pixel stepping go higher as per the demand on the CPU instead of slow down all the game.

Maybe in GAUNTLET, this doesn't work so well in some situations because in some type of games the slowdown is preferable because of the selected collision algorithm, but in the 3D games, the difference in gameplay is very positive using frame time instead of an unstable speed.

This outstanding firmware upgrade made it possible to test all this concept and now I'm very satisfied with the result.

PS.: Sorry, I know I was a little off-topic.
Edited 2020-10-22 22:39 by MauroXavier
 
PeteCotton

Guru

Joined: 13/08/2020
Location: Canada
Posts: 316
Posted: 03:50pm 22 Oct 2020
Copy link to clipboard 
Print this post

  thwill said  

All valid, but you'll still permit me to grumble given the 5-10% performance hit this imposes on my code because the "rules" have changed.


Grumble away my friend.


  thwill said  
  matherp said  I assume you have a 400MHz CMM2?


Much to my chagrin "yes".

Then again, perhaps it is best for a developer to be running the lowest common denominator.

Tom


I have no idea why, but there seems to be little difference between the 400mhz and 480mhz when running Heli-Blaster. It must be getting bound up on something not related to raw clock cycles. But I think you are correct. There is no harm, as a developer, having the lowest common denominator. Back in the day, I upgraded my Amiga 500 to a 1200. (7mhz 68000 to 14mhz 68020). It was a bit of a waste of money as hardly any programs actually made use of the extra power (given that 90% of the user base where 500's), and because it was bound by disk access speeds etc. it didn't really feel twice as fast.

Great work on optimising the Z-Machine for the CMM2 by the way. Next up Magnetic Scrolls? See Strand Games.

https://gitlab.com/strandgames/brahman/-/tree/master/zxnext_magnetic/games/pawn
Edited 2020-10-23 01:52 by PeteCotton
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3865
Posted: 05:55pm 22 Oct 2020
Copy link to clipboard 
Print this post

  PeteCotton said  Great work on optimising the Z-Machine for the CMM2 by the way. Next up Magnetic Scrolls?


Thanks it was fun, though it seems to have subsequently garnered little interest.

I imagine the Magnetic Scrolls games 'terp is no more computationally intensive than the Z-machine, it's just prettier, so it's probably possible on the CMM2. That said, I think I've done my bit with Text Adventures.

My next project, assuming I ever escape the clutches of the Welcome Tape, is an implementation of Core War ... which I imagine will be equally ignored by the denizens

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
PeteCotton

Guru

Joined: 13/08/2020
Location: Canada
Posts: 316
Posted: 07:33pm 22 Oct 2020
Copy link to clipboard 
Print this post

  thwill said  
My next project, assuming I ever escape the clutches of the Welcome Tape, is an implementation of Core War ... which I imagine will be equally ignored by the denizens

Tom


Nice. I've never played/programmed it, but I've been aware of it since the 90's. It's a neat concept.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8605
Posted: 03:54pm 23 Oct 2020
Copy link to clipboard 
Print this post



 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3865
Posted: 03:58pm 23 Oct 2020
Copy link to clipboard 
Print this post

Very nice, but did you optimise the firmware? ... or have you just spent the last 24 hours hand optimising my code? ... please don't tell me it's the latter.

Tom
Edited 2020-10-24 02:00 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8605
Posted: 04:02pm 23 Oct 2020
Copy link to clipboard 
Print this post

Haven't touched your code - just improved the hashing
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3865
Posted: 04:05pm 23 Oct 2020
Copy link to clipboard 
Print this post

  matherp said  Haven't touched your code - just improved the hashing


In that case we are truly not worthy to be blessed by your greatness

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8605
Posted: 05:19pm 23 Oct 2020
Copy link to clipboard 
Print this post

Please try the attached on as many programs as possible:

CMM2V1.5.zip

The OPTION NOHASH has been removed as it is no longer necessary
The variable table has been partitioned between global variables and local and a maximum of 512 of each are now allowed. The current list of local variables is now maintained on a LIFO stack which greatly improves performance removing them when the subroutine ends whilst still allowing instant access through the hash key. For many programs this version will be even faster than the first experimental release.

Notes for the manual:
ERASE only works on global variables.
CLEAR can only be executed from the main program.

For best performance one tip:

Try to avoid duplicate variable names between nested subroutines e.g.


sub fred
 local integer i,j
 bert i
end sub

'
sub bert i
local integer j
j=i
end sub

By definition this will create hash collisions which require additional processing to resolve.

Note to Mauro:
This version (and to some extent the previous) is completely rigorous in losing all context after a CLEAR command. Version 5.05.05 and previous seemed to allow you to get away with some strange things after a clear command. As before the TLS demo in DemoX is giving me a problem. I don't think I have a firmware code error as everything else I have tried works but there may be (it is also possible I've just b...d the Basic code). Please explore this and let me know.
 
Barbiani
Newbie

Joined: 18/10/2020
Location: Brazil
Posts: 6
Posted: 05:27pm 23 Oct 2020
Copy link to clipboard 
Print this post

This is a great improvement. Too bad it does not share code with the older mites.
Edited 2020-10-24 03:28 by Barbiani
 
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 05:47pm 23 Oct 2020
Copy link to clipboard 
Print this post

  matherp said  Note to Mauro:
This version (and to some extent the previous) is completely rigorous in losing all context after a CLEAR command. Version 5.05.05 and previous seemed to allow you to get away with some strange things after a clear command. As before the TLS demo in DemoX is giving me a problem. I don't think I have a firmware code error as everything else I have tried works but there may be (it is also possible I've just b...d the Basic code). Please explore this and let me know.

Ok! I will gladly fix the DEMOX to run in this version. Yesterday I was testing each part of the demo and adjusted to use this speed gain to put more visual effects and to make some parts more smooth. The difference is so positively aggressive that maybe I will call it DEMOX+...

I must upload in GitHub this version of DEMOX when this firmware became gold, as I will put a firmware version check because the demo will run correctly only in this version or above.
Edited 2020-10-24 03:51 by MauroXavier
 
elk1984

Senior Member

Joined: 11/07/2020
Location: United Kingdom
Posts: 227
Posted: 06:45pm 23 Oct 2020
Copy link to clipboard 
Print this post

  thwill said  
  matherp said  I assume you have a 400MHz CMM2?


Much to my chagrin "yes".

Then again, perhaps it is best for a developer to be running the lowest common denominator.

Tom


Is there a way of telling which I have from a query (rather than opening the case  )
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8605
Posted: 06:46pm 23 Oct 2020
Copy link to clipboard 
Print this post

  Quote  s there a way of telling which I have from a query (rather than opening the case  


Look at the last line on the screenshot I posted
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3865
Posted: 07:49pm 23 Oct 2020
Copy link to clipboard 
Print this post

So far so good, and the spurious "Local variable already declared" error with "spflow" is gone too.



Will try to test the contents of the latest version of the "Welcome Tape" over the weekend.

Best wishes,

Tom
Edited 2020-10-24 06:03 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
elk1984

Senior Member

Joined: 11/07/2020
Location: United Kingdom
Posts: 227
Posted: 08:15pm 23 Oct 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  s there a way of telling which I have from a query (rather than opening the case  


Look at the last line on the screenshot I posted


Doh!
 
elk1984

Senior Member

Joined: 11/07/2020
Location: United Kingdom
Posts: 227
Posted: 08:16pm 23 Oct 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  s there a way of telling which I have from a query (rather than opening the case)


Look at the last line on the screenshot I posted
 
     Page 4 of 8    
Print this page
© JAQ Software 2024