- Posts: 136
- Thank you received: 94
Development updates
2 weeks 3 days ago - 2 weeks 3 days ago #292
by Franck
Replied by Franck on topic Development updates
Welcome to the modern world !
Recent weeks have been eye opening for me. The famous line from blade runner comes to mind: "I've seen things you people wouldn't believe".
AI and particularly Opus 5.5 have shown incredible progress in the coding world. Entire game engines built autonomously, demos uploaded to embeded systems that work at first try. Truly unbelievable stuff.
I'm proud that I designed and implemented everything by hand in Micro-8 so far. Apart from a couple libraries, I wrote every bit of the ~20k lines of C++ code that makes Micro-8 OS. And the same goes for the Verilog HDL in the FPGA.
But I'm not John Carmack and I make a lot of mistakes, and that leads to bugs that I have a hard time to find and squash.
So a couple days ago I decided to get a Claude code license and ask it to do a report on my code base. A number of problems were reported and I asked Claude to start working on each bug, one at a time, with me validating at every step, and testing on the hardware.
The result is version 0.8.2 with a series of bugfixes that would have taken me weeks to find, done in a couple days. Welcome to the modern world.
I have many ideas of improvements to bring to the system, such as reducing flash usage, improving the VM speed with precomputed gotos (instead of the current giant switch case), and with the language too. I now expect new things to come quicker than initialy anticipated. Welcome to the modern world.
Recent weeks have been eye opening for me. The famous line from blade runner comes to mind: "I've seen things you people wouldn't believe".
AI and particularly Opus 5.5 have shown incredible progress in the coding world. Entire game engines built autonomously, demos uploaded to embeded systems that work at first try. Truly unbelievable stuff.
I'm proud that I designed and implemented everything by hand in Micro-8 so far. Apart from a couple libraries, I wrote every bit of the ~20k lines of C++ code that makes Micro-8 OS. And the same goes for the Verilog HDL in the FPGA.
But I'm not John Carmack and I make a lot of mistakes, and that leads to bugs that I have a hard time to find and squash.
So a couple days ago I decided to get a Claude code license and ask it to do a report on my code base. A number of problems were reported and I asked Claude to start working on each bug, one at a time, with me validating at every step, and testing on the hardware.
The result is version 0.8.2 with a series of bugfixes that would have taken me weeks to find, done in a couple days. Welcome to the modern world.
I have many ideas of improvements to bring to the system, such as reducing flash usage, improving the VM speed with precomputed gotos (instead of the current giant switch case), and with the language too. I now expect new things to come quicker than initialy anticipated. Welcome to the modern world.
Last edit: 2 weeks 3 days ago by Franck.
Please Log in or Create an account to join the conversation.
5 days 7 hours ago - 4 days 10 hours ago #304
by Franck
Replied by Franck on topic Development updates
Update 0.9.0 comming soon! So what's cool about it?
Massive size reduction of the OS image
We went from 123 KiB down to 103 KiB with this release. How come? The key here is Link-Time Optimization (LTO).
Ususally a compiler generates an object file for each compilation unit. Depending on the optimization settings it optimizes an object file for speed or memory. I was already on maximum space optimization settings. Then the linker links all objects into an executable.
The problem is, with standard compilation, redundancy across compilation units or code that might be called by another unit, but is not, stay there.
One of the reasons a compiler works that way is to enable incremental compilation. If you touch a compilation unit, no need to recompile the entire project, it only recomplies that particular compilation unit. And that's fair for huge code bases like Unreal Engine, but for Micro-8 OS, a complete rebuild takes less than 20 seconds or so. PCs are so powerful nowadays, and using SSD is so much faster that what mechanical drives used to be.
LTO is a special GCC feature that sees the big picture and gives the compiler the ability to optimize agressively across all compilation units with the only drawback of having to rebuild the entire project every time. It allows:
The internal SRAM usage also went down significantly.
New toolchain
I have been using GCC5.4 (the version that comes with Atmel Studio) since the beginning of the project. Claude told me I should move the the latest GCC16.1 AVR C++ version that supports C++ 17.0 among other things. Who am I to contradict Claude lol ! With that installed, the OS image size went even further down and the speed went up a little more!
Significant size reduction of the generated runtime binaries and massive runtime performance improvements
Up to 20% size reduction of the executable files.
Up to a massive 100% speedup of the runtime execution. Some examples:
You will notice the speech in HOOGY has a much higher pitch now. @ludojoey you may want to replace the voice with higher sampling rate one.
Some components (e.g. music) of MRCHANG were no longer working because they relied on a tick that was not synced so the code was patched in this release to support the newer VM speed.
General advice to all, try to make your project VM-speed independent. When possible, rely on either vsync (best) or ms.
Tons of bug fixes
With this release also comes a large number of bugfixes, mainly in the Lofi language/compiler. Claude built a harness to test pretty much every combination possible of the language features. The language should now work as defined, and will stay so for the 1.0.0 official release. New features of the language are planned for a later version. I want to focus on app development now.
A couple new features
A new mem command in the CLI prints the ISRAM untouched headroom. In the long run, if I see this stays high enough after editing/compiling/running large programs, it might be even possible to move the frame stack to ISRAM and gain some more performance.
The new _tileAddr built-in value returns the address of the tile touched by a sprite after a call to isSPrTile().
Manual
I will now work on an addendum file that can be printed by users and inserted into the various printed manual versions so that each manual is up to date.
Massive size reduction of the OS image
We went from 123 KiB down to 103 KiB with this release. How come? The key here is Link-Time Optimization (LTO).
Ususally a compiler generates an object file for each compilation unit. Depending on the optimization settings it optimizes an object file for speed or memory. I was already on maximum space optimization settings. Then the linker links all objects into an executable.
The problem is, with standard compilation, redundancy across compilation units or code that might be called by another unit, but is not, stay there.
One of the reasons a compiler works that way is to enable incremental compilation. If you touch a compilation unit, no need to recompile the entire project, it only recomplies that particular compilation unit. And that's fair for huge code bases like Unreal Engine, but for Micro-8 OS, a complete rebuild takes less than 20 seconds or so. PCs are so powerful nowadays, and using SSD is so much faster that what mechanical drives used to be.
LTO is a special GCC feature that sees the big picture and gives the compiler the ability to optimize agressively across all compilation units with the only drawback of having to rebuild the entire project every time. It allows:
- Cross-file inlining
- Cross-file dead code elimination
- Devirtualization (converting expensive virtual calls into fast function calls, or just inlining them whenever possible)
The internal SRAM usage also went down significantly.
New toolchain
I have been using GCC5.4 (the version that comes with Atmel Studio) since the beginning of the project. Claude told me I should move the the latest GCC16.1 AVR C++ version that supports C++ 17.0 among other things. Who am I to contradict Claude lol ! With that installed, the OS image size went even further down and the speed went up a little more!
Significant size reduction of the generated runtime binaries and massive runtime performance improvements
- By consolidating the bytecode (new compound instructions), the new runtime requires less instructions and makes less movements on the stack to produce results.
- With the memory reduction, the value stack used by the VM was moved from external SRAM to internal SRAM. That's something I tried to do earlier but was forced to abandon because the memory was too scarce originally. External memory has 2 waitstates (to allow the memory controller to do its things) while internal memory is accessed in a single cycle. So the ISRAM now acts like a cache memory for locals.
- The VM itself was optimized by factorizing some redundant operations and by moving the stack and frame pointers to register to avoid costly memory accesses at each instruction.
- Several API routines were optimized by Claude including graphics and math routines. The standard memory libraries routines were even rewritten in inline assembly !
- The compiler now performs some basic optimization such as constant folding. This is certainly an area of improvement for future versions.
Up to 20% size reduction of the executable files.
Up to a massive 100% speedup of the runtime execution. Some examples:
- demo/balls -> now take about 50% of the original frame time (measured with raster time)
- examples/perfs/realdiv -> from 422 ms down to 257 ms
- examples/perfs/maxips -> from 133K IPS to 230K IPS
- examples/graphics/trirot -> from 18ms down to 12ms
- examples/graphics/cube -> from 50ms down to 30ms
- examples/graphics/cubeopti -> from 24ms down to 15ms
You will notice the speech in HOOGY has a much higher pitch now. @ludojoey you may want to replace the voice with higher sampling rate one.
Some components (e.g. music) of MRCHANG were no longer working because they relied on a tick that was not synced so the code was patched in this release to support the newer VM speed.
General advice to all, try to make your project VM-speed independent. When possible, rely on either vsync (best) or ms.
Tons of bug fixes
With this release also comes a large number of bugfixes, mainly in the Lofi language/compiler. Claude built a harness to test pretty much every combination possible of the language features. The language should now work as defined, and will stay so for the 1.0.0 official release. New features of the language are planned for a later version. I want to focus on app development now.
A couple new features
A new mem command in the CLI prints the ISRAM untouched headroom. In the long run, if I see this stays high enough after editing/compiling/running large programs, it might be even possible to move the frame stack to ISRAM and gain some more performance.
The new _tileAddr built-in value returns the address of the tile touched by a sprite after a call to isSPrTile().
Manual
I will now work on an addendum file that can be printed by users and inserted into the various printed manual versions so that each manual is up to date.
Last edit: 4 days 10 hours ago by Franck.
Please Log in or Create an account to join the conversation.
4 days 12 hours ago #305
by ludojoey
Replied by ludojoey on topic Development updates
Thanks for all this really interesting information!
I can't wait to try it all out.
As for the voice in HOOGY, I'll look into it, but the original voice was actually higher-pitched anyway.
I can't wait to try it all out.
As for the voice in HOOGY, I'll look into it, but the original voice was actually higher-pitched anyway.
Please Log in or Create an account to join the conversation.
4 days 7 hours ago #307
by ludojoey
Replied by ludojoey on topic Development updates
I’ve just installed the new version, and it’s definitely much faster!
Thanks for the little fixes in my games. I’ve updated my GitHub repositories.
It looks like previous versions sometimes failed to detect undefined variables, is that right?
Great work! Thanks again!
Thanks for the little fixes in my games. I’ve updated my GitHub repositories.
It looks like previous versions sometimes failed to detect undefined variables, is that right?
Great work! Thanks again!
Please Log in or Create an account to join the conversation.
4 days 6 hours ago #308
by Franck
Replied by Franck on topic Development updates
Yes absolutely, you are correct. I will post the release notes asap.
The following user(s) said Thank You: ludojoey
Please Log in or Create an account to join the conversation.
Time to create page: 0.197 seconds