Skip to content

Commit

Permalink
bricks: MICROPY_GC_HOOK_LOOP improvements
Browse files Browse the repository at this point in the history
This pulls in a fix in the micropython submodule to also call
MICROPY_GC_HOOK_LOOP in gc_alloc() and gc_info(). These can be long
running operations and were interfering with motor control in certain
cases.

Also, we now only call the contiki event loop every 16 loop iterations
to improve performance, particularly during alloc.

Fixes: pybricks/support#977
  • Loading branch information
dlech committed Mar 15, 2023
1 parent 8423448 commit 5e31948
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

## [Unreleased]

### Fixed
- Fixed allocator interfering with motor control when memory usage is high ([support#956]).

[support#956]: https://github.com/pybricks/support/issues/977

## [3.3.0b2] - 2023-03-08

### Added
Expand Down
2 changes: 1 addition & 1 deletion bricks/_common_stm32/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static inline mp_uint_t disable_irq(void) {
pbio_do_one_event(); \
} while (0);

#define MICROPY_GC_HOOK_LOOP MICROPY_VM_HOOK_LOOP
#define MICROPY_GC_HOOK_LOOP(i) do { if ((i & 0xf) == 0) MICROPY_VM_HOOK_LOOP } while (0)

#define MICROPY_EVENT_POLL_HOOK \
do { \
Expand Down
2 changes: 1 addition & 1 deletion bricks/ev3rt/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static inline mp_uint_t disable_irq(void) {
pbio_do_one_event(); \
} while (0);

#define MICROPY_GC_HOOK_LOOP MICROPY_VM_HOOK_LOOP
#define MICROPY_GC_HOOK_LOOP(i) do { if ((i & 0xf) == 0) MICROPY_VM_HOOK_LOOP } while (0)

#define MICROPY_EVENT_POLL_HOOK \
do { \
Expand Down
2 changes: 1 addition & 1 deletion bricks/virtualhub/mpconfigvariant.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
pb_virtualhub_poll(); \
} while (0);

#define MICROPY_GC_HOOK_LOOP MICROPY_VM_HOOK_LOOP
#define MICROPY_GC_HOOK_LOOP(i) do { if ((i & 0xf) == 0) MICROPY_VM_HOOK_LOOP } while (0)

#define MICROPY_EVENT_POLL_HOOK do { \
extern void pb_virtualhub_event_poll(void); \
Expand Down
2 changes: 1 addition & 1 deletion micropython
Submodule micropython updated 2 files
+6 −5 py/gc.c
+2 −1 py/mpconfig.h

0 comments on commit 5e31948

Please sign in to comment.