Teensy 4.0 & 4.1

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
User avatar
RobH
Posts: 91
Joined: Fri Mar 23, 2018 3:37 pm
Location: Netherlands
Contact:

Re: Teensy 4.0 & 4.1

Post by RobH » Mon Jun 21, 2021 9:13 am

Since my recent figures were all collected with firmware built locally on my PC I cannot exclude that that could be a cause of the performance differences, even though I use a build-script for consistency.
So I decided to redo the tests with 'standard' firmware from the Download section of this site and a PyBoard 1.1.
Most tested versions (1.16-2, 1.16, 1.15, 1.14, 1.13) give around 1750 pystones/second.
Some 'unstable' versions (1.15-222 and -229) give a few percent more: around 1800.
So I have no firm point to raise an issue...

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Teensy 4.0 & 4.1

Post by Roberthh » Mon Jun 21, 2021 9:18 am

Would you mind to post the script used for testing. Then I can repeat the test here.

User avatar
RobH
Posts: 91
Joined: Fri Mar 23, 2018 3:37 pm
Location: Netherlands
Contact:

Re: Teensy 4.0 & 4.1

Post by RobH » Mon Jun 21, 2021 12:57 pm

I have no script for testing: I simply run pystone_lowmem.py on the target after loading a firmware version.
I do have a Python script to build firmware for several ports, is that of interest to you?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Teensy 4.0 & 4.1

Post by Roberthh » Mon Jun 21, 2021 3:23 pm

The first run showed numbers in the range of 1200, further builds moved to ~2500. But nothing in the range t 4000.

User avatar
RobH
Posts: 91
Joined: Fri Mar 23, 2018 3:37 pm
Location: Netherlands
Contact:

Re: Teensy 4.0 & 4.1

Post by RobH » Mon Jun 21, 2021 5:53 pm

Just to be sure about my results I reran pystone_lowmem on a Teensy 4.0 with MP firmware 1.15-216. Below a screenshot of my terminal program:
Image
You may notice that I us 5000 for the number of loops.
Attachments
Screenshot from 2021-06-21 19-44-00.png
Screenshot from 2021-06-21 19-44-00.png (18.23 KiB) Viewed 8881 times

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Teensy 4.0 & 4.1

Post by Roberthh » Mon Jun 21, 2021 6:36 pm

No major change. i have built v1.15-216. Pystone values ~2800.
V1.16-3, Values at ~2300.
Plain Makefile. Double precision float. With single precision float the numbers for V1.16.3 are ~2800.

User avatar
RobH
Posts: 91
Joined: Fri Mar 23, 2018 3:37 pm
Location: Netherlands
Contact:

Re: Teensy 4.0 & 4.1

Post by RobH » Mon Jun 21, 2021 7:32 pm

Just rebuilt a few earlier versions (1.15-221/220/215/211): all result in around 2625 pystones/second.
But versions which I built 3 days ago (1.1-216/184) perform at around 4250.
I noticed a difference in filesize too: today all 728.9 KB, those of June 18: 708.8 kB.
I did not see updates of the tools in these 3 days, nor in my config. Maybe in Makefile(s)?
Looking at the difference in performance it would be worthwhile to find the cause.
BTW Essential for the figures is an accurate timer, could that be the culprit?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Teensy 4.0 & 4.1

Post by Roberthh » Mon Jun 21, 2021 8:23 pm

The timing should be fine. In my tests it said it lasted 2.1 seconds, and that matches the observation. At a figure of 4200 it was 1.1 second, and that's a noticeably difference.
I was considering whether the fast speed was a lucky memory layout which makes best use of the cache. The difference between code executed from cache and non-cache is a factor of ~3. So it can make a huge difference. Cache is enabled, but it is not really large.
Running the same test with my PR for SPI support brings the figure down to ~1300, even if SPI is not used. The SPI image is even larger.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Teensy 4.0 & 4.1

Post by Roberthh » Tue Jun 22, 2021 7:55 pm

@RobH The speed drop comes with commit bbdc98f72, from version 1.15-182 to v1.15-183, causing the pystone numbers to drop from ~5500 to 2300. But that commit "just" add most of the Python features. Nothing that is really needed for the pystone test. It increases the code size quite a bit from 195552 to 275520 bytes.
Very strange!

Edit: About the timer. When I lazily run from the linux terminal

time mpremote run pystone_lowmem.py

The runtime shown by time is about the same as reported by the code. Just ~100ms difference, which is fine for code loading and compiling.

User avatar
RobH
Posts: 91
Joined: Fri Mar 23, 2018 3:37 pm
Location: Netherlands
Contact:

Re: Teensy 4.0 & 4.1

Post by RobH » Wed Jun 23, 2021 9:57 am

@Roberthh Good that you found a significant speed drop from version 1.15-182 to v1.15-183.
Still some (but not all) later versions like my 1.15-216 perform at 4248 pystones/second as my entry of June 21 shows. There must be an explanation for the differences.....

Post Reply