Updated: softkid, yes, implementing the performance-critical part of my product in assembly is one of the things I'm doing. But it's not completely obvious what the best assembly is. So one of my tasks this week is to experiment with different alternatives in assembly code, and understand the performance of each that I get.
One problem is that I haven't done assembly in a long time, although I used to do a lot. Another is that I haven't ever programmed the assembly for this instruction set architecture before. I've done well at learning it so far, but of course I don't know all the clever tricks yet. I used to write some really odd 68000 assembly code, stuff that no one could figure out just by reading it, but that was significantly faster than the best I could ever get in C.
There are some tricks to what I'm doing that turn out to speed it up quite a bit, that I was unaware of when I wrote the proof of concept demo. I had known that there were some well-known optimizations, but didn't look into them because I didn't realize they would be necessary even for a proof of concept. I had no idea that the straightforward, obvious way to implement this would be so slow. But I am aware of some of the optimizations now, and am researching others.
I'm working on a new implementation in C that should be a lot faster even that what I had in my first attempt at assembly code. When I get that working well, I will have another go at assembly and probably should be able to improve a little on the C.
Again, I'm sorry to be so oblique about what my product is. But it's something I think you will all be happy is available. It won't be expensive, and maybe some of you will want to get one. Maybe I can even ship it in time for Christmas.
My client has decided to fund continued development of the project I'm working on for him. As I previously reported he was testing my proof of concept demo before deciding whether to go further, but the performance was unsatisfactory, not fast enough to make it a marketable product..
I spent several days explaining to my client how I intended to speed it up, but some of those ways will be quite difficult and would take some time, and things are so tight financially that I could not afford to just implement those changes and prove it to him by showing him working code. He based his decision on his faith that my plans would work out.
Ordinarily I enjoy doing optimization. I think it is the best part of programming. I have some tricks for optimization that some people think are quite twisted, but have worked well in the past.
In this coming week I face one of the most significant challenges of my entire career. I have to make my code go so much faster than it does now that I really honestly don't know if I can succeed. There are some tricks I could use if I were running on a desktop PC but I am programming an embedded device with very little RAM or ROM.
This week will get funded, but whether funding for the product continues to bring it to market depends on the results I am able to achieve.
It would be fun if there weren't so much riding on it.
Sometimes I am able to forget about the peril we are in and just enjoy coding. The whole experience has been very hard on my poor wife, who asks how I can be in such good spirits during a time of such turmoil. I tell her that is is like programming with the Sword of Damocles hanging over my head, and my only hope for survival is to write good code. But I cannot write good code while I am frightened, so I do whatever is necessary to put it out of my mind.