Open Mr-Meow-ZA opened 1 year ago
Another report of code size regression. Related: https://github.com/microsoft/pxt-microbit/issues/4808
@Mr-Meow-ZA Can I assume this is a microbit project? If so:
Can you share your project?
@eanders-ms Thanks for the reply and the link to the related post.
microbit V2
I will try out the beta, thanks for that.
I can share some of the project. It's still in early development so the examples I'll send are just for testing.
We made a multipurpose android app that links to the microbit so I've been testing it with many different uses. I've changed the way the MakeCode interacts with the data sent from app, which has improved it a lot but I need to learn more about this to avoid future issues.
I am also using hall encoders on TT motors, in order to do more precise tracking of the smart car's motion. Test code works well, although I need to improve this further too, but I'm now needing to learn more about the advanced side of MakeCode.
Some of the projects I have managed to get quite big, but others hit the size wall. I am going to try reproduce some of those now. The main issues come when adding Neopixel lights, music sound, etc. I also noticed in earlier version of talking to app that data strings, parsing values, etc was a problem, but I've fixed that.
The below all use File 1 as an example.
I'll remember to save projects in future when I encounter the issue again as these examples I reproduced now quick do not really show it that well.
You may get some insight using a new url parameter available in beta that enables calculation of subsystem sizes in the hex: ?compiler=size
, e.g.: https://makecode.microbit.org/beta?compiler=size
How to see the output:
built
folder.mbcodal-binary.asm
. This is the assembler source for the v2 hex.; generated code sizes (bytes): 6908 (incl. 5008 user, 1274 helpers, 306 vtables, 320 lits); src size 0
...
;
; Code size:
;
; 566 helper: bind [_pxt_helper_bind]
; by helper: get [_pxt_helper_get]
; 436 radio/radio.ts(63,5): radio.handleDataReceived [radio_handleDataReceived__P3115]
; by radio/radio.ts(57,5): radio.init [radio_init__P3114]
; 338 _code_helper__conv_22 [_code_helper__conv_22]
; by many, including main.ts(24,15): inline
; 324 core/game.ts(780,5): game.plot [game_plot__P2999]
...
@eanders-ms thank you very much! That is a very useful trick. I just tried it now and it worked great, I can also use this to estimate sizes by comparison. Going to play with it this week :)
@Mr-Meow-ZA We made some improvements to code size, and I'm curious if it helps you here. The changes aren't public yet, but can you test your project with this private build and let us know if it works? https://microbit.staging.pxt.io/app/90d23a3465264bc5f2cb314fce5d4be956dd7b12-3596625c81#
@eanders-ms thanks for letting me know. I will check it out this week. Sounds promising :)
@Mr-Meow-ZA these changes are released now and available at https://makecode.microbit.org. No need to test in the special build I linked.
@eanders-ms that is fantastic, thanks again. It is definitely much better now
Hi there, I have often hit a hurdle where my code is too large and I get the warning saying the "program is too big by X bytes!" But as there is no way of knowing which blocks are using up the most space it is very difficult to optimize the code or to know what to remove and what to leave. If there was a way to determine or even estimate memory usage by blocks then it would make doing larger projects far easier!