Basic V Performance
Pages: 1 2
John Sandgrounder (1650) 574 posts |
On a Pi with the current official build, setting Basic$Crunch True, causes the program to be crunched on load. In my case giving considerable size reduction (35%) and noticable performance benefit as a result. BUT using CHAIN to restart the program (with or without any code differnces), causes the program to be loaded without being crunched. (thus losing the benefits). In fact, using CHAIN under any circumstances seems to cause the chained progam not be to crunched, even though the original (chaining) program was auto-crunched. |
Steve Drain (222) 1620 posts |
Yes, that is what is to be expected. Only when the program is run with ‘BASIC -quit’ is it auto-crunched. That is the default when double-clicking a BASIC file or using BASIC’s own CHAIN statement is quite seperate and pretty well obsolete these days IMHO. For what reason are you using it? There might be an alternative. |
John Sandgrounder (1650) 574 posts |
The primary data of most of my programs is held in memory at, say, LOMEM address &20000. This gives me the simple option to change the program on the fly without losing any of the primary data. When told, the program simply CHAINs a new version of itself without losing any essential data and without needing disc accesses. The data just sits in memory all the time. For example, an HTTP server can be upgraded on the fly without losing the port binding or any incoming TCP data. |
Steve Drain (222) 1620 posts |
Not really, but the Reference Manual history appendix ends at 1.05. I have given 1.04 for the Guide because other documents I have with an almost identical set of changes to those in the appendix do specify that version. Fallible memory also tells me that 1.03 was never in a commercial Archimedes. ;-) |
Steve Drain (222) 1620 posts |
An interesting problem. A dynamic area for the data comes to mind or perhaps a temporary file in RAMFS. In either case you would use 1 Edit: I can think of ways to avoid this. |
John Sandgrounder (1650) 574 posts |
I am going to suggest that auto-crunch was disabled deliberately because there are just too many bugs in it! It just does not do the job! And to use it every single branch of a progam would have to be re-tested This post was edited 6 hours later to withdraw the comment. See below. |
Rick Murray (539) 13840 posts |
Such as? It doesn’t alter the program much. Edit: Empty lines crossed out, needs CRUNCH 31 to remove those too…
It shouldn’t mess with your program’s flow…
Indeed, though to my mind there would need to be some sort of guard data and/or sanity checking to prevent from either the data format changing in a live setup (or a one-off “update” phase) but most importantly to try to mitigate the risk where the data itself is bad. Imagine the fun that could occur if the server restarts (maybe in an error catch that CHAINs itself) which accesses the bad data which causes the thing to crash which restarts it so it can access the bad data which…you see where this is going? ;-)
Piece of cake. You don’t need a system variable. Dynamic Areas can be named. So when the program starts it should enumerate all dynamic areas and if it finds one with such and such a name, then use it. Otherwise, create a new Dynamic Area and start from the beginning. Mmmm… What happens if two instances of the server run in two TaskWindows…? ;-) |
John Sandgrounder (1650) 574 posts |
I probably should have re-phrased my point – It produces crunched code with too many bugs in it. There may only be one bug in CRUNCH which manifests itself lots of times. Either way, it is not reliable with existing code. |
Steve Drain (222) 1620 posts |
Now, that is really interesting. I have been running Basic$Crunched programs for a very long time and never found a bug to ascribe to it. I would love to have the details. |
Steve Drain (222) 1620 posts |
Well, that is what I had in mind, but I did not want to elaborate and confuse the issue. ;-) |
Steve Drain (222) 1620 posts |
Just for clarity’s sake, it does not do empty lines; those might be the target of GOTO etc. |
Rick Murray (539) 13840 posts |
Ah, you’re right. There’s five entries there. ;-)
|
Steve Pampling (1551) 8170 posts |
It just does not do the job! I was expecting that response a little sooner, I presume you were busy :) |
Martin Avison (27) 1494 posts |
Like Steve D, I have run with Basic$Crunch set for many many years, and never had a problem caused by it. And I run and develop some significantly large programs! It does cause me problems when the Set goes missing (eg after replacing Boot) and things run out of space! |
John Sandgrounder (1650) 574 posts |
Yes, I had noted Steve’s point. I will have another look to see if the many errors produced can all be attributed to the same statement type in my uncrunched code. |
John Sandgrounder (1650) 574 posts |
OK – that did not take long. I was too hasty blaming CRUNCH for the errors. Because I can not use CHAIN to auto-crunch my programs, I saved and edited a crunched version of the programs. It is !Edit which destroys the crunched programs. I can not find any errors with CRUNCH (auto or manual). |
John Sandgrounder (1650) 574 posts |
I have found a way to achieve the chaining of one program to another without using CHAIN. OSCLI (“Run !RunImage”) seems to behave the same as CHAIN “!RunImage”, but allows the new program to be auto-crunched. |
Steve Drain (222) 1620 posts |
As I quoted yesterday: Note that CRUNCH %10 may make a program uneditable.
That is aliased to |
Chris Johnson (125) 825 posts |
Most of the apps I make public are compiled C. However, I do have two Basic apps which are ‘helper’ apps for some of my graph plotting apps. They are in Basic because they use EVAL to allow user entered functions to be evaluated ‘on the fly’. I received a report that one of them would not run in the wimp slot I had set in the !Run file, although the slot was fine on all my machines. To cut the story short, this thread triggered me in to trawling through the various obey files run during my own boot process. There it was – on all my machines BASIC$Crunch was being set during boot. Is it a polite thing to do, to actually ensure the sys$var is set in the !Run file of an application that is available to others? |
Steve Drain (222) 1620 posts |
+1 Adding " for BASIC". There is no optimising compiler to help. |
Steve Drain (222) 1620 posts |
It is a question that has much concerned me, but I ended up making Basalt do it anyway. I think it is an intervention that has no downsides 1, unless you want to save a program already in memory as John did. ;-) I would much prefer an official change to BASIC. 1 famous last words |
Steve Pampling (1551) 8170 posts |
Unset <Basic$Crunch> ? |
John Sandgrounder (1650) 574 posts |
@DavidS, Thank you. I am already working on my HTTP Server program from the polling loop out. To everyone else, Also Thank You. Your suggestions are making big improvements. CPU Load is now showing 0.0% for a lot of the time that was continuous heavy load aound 50%. (And Auto crunch is working well) |
Pages: 1 2