Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monotonic_ns jumps #9953

Open
dheera opened this issue Jan 12, 2025 · 3 comments
Open

monotonic_ns jumps #9953

dheera opened this issue Jan 12, 2025 · 3 comments
Labels
Milestone

Comments

@dheera
Copy link

dheera commented Jan 12, 2025

CircuitPython version

6.0.0

Code/REPL

import time
for i in range(1000000000):
    print(time.monotonic_ns())
    time.sleep(0.001)

Behavior

1431848724366
1431849700929
1431850677491
1431851654054
1431852630616
1431853607179
1431854583741
1431855560304
1431856536866
1431857513429
1431858520509
1431859466554 <--
1432001098634 <-- wtf?
1432002044679
1432003021241
1432003997804
1432004974366
1432005981447
1432006927491
1432007904054
1432008911134
1432009857179
1432010833741
1432011810304
1432012786866

Description

It seems that the nanoseconds part is counting slower than it should be and then plays catch up at the next whole second

Additional information

No response

@dheera dheera added the bug label Jan 12, 2025
@dhalbert dhalbert added this to the Support milestone Jan 12, 2025
@dhalbert
Copy link
Collaborator

CircuitPython is not a real-time system. Some interrupt or garbage-collection could have occurred that caused a delay. It could also be an old bug that was fixed. You said you are using 6.0.0, which is from 2020. Also please report what board you are using.

@dheera
Copy link
Author

dheera commented Jan 12, 2025

Hi,
This is a Feather S2.
It appears to happen every second, the ~850000000 to ~999999999 are missing. It's extremely regular and there isn't a noticeable execution delay so doesn't appear to be a garbage collection phenomenon. On the surface it appears to cover ~000000000 to ~850000000 over the course of 1 second, i.e. it is not actually counting nanoseconds.

I realize it isn't a realtime system but my understanding is that time.time() fetches this from an RTC.

@dhalbert
Copy link
Collaborator

Could you try 9.2.2 instead of 6.0.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants