<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/py/mpstate.h, branch cross</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=cross</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=cross'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2016-07-20T21:37:30+00:00</updated>
<entry>
<title>py/gc: Implement GC running by allocation threshold.</title>
<updated>2016-07-20T21:37:30+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2016-07-20T21:37:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=93e353e3844f7116088a1a105ba588cade0e6783'/>
<id>urn:sha1:93e353e3844f7116088a1a105ba588cade0e6783</id>
<content type='text'>
Currently, MicroPython runs GC when it could not allocate a block of memory,
which happens when heap is exhausted. However, that policy can't work well
with "inifinity" heaps, e.g. backed by a virtual memory - there will be a
lot of swap thrashing long before VM will be exhausted. Instead, in such
cases "allocation threshold" policy is used: a GC is run after some number of
allocations have been made. Details vary, for example, number or total amount
of allocations can be used, threshold may be self-adjusting based on GC
outcome, etc.

This change implements a simple variant of such policy for MicroPython. Amount
of allocated memory so far is used for threshold, to make it useful to typical
finite-size, and small, heaps as used with MicroPython ports. And such GC policy
is indeed useful for such types of heaps too, as it allows to better control
fragmentation. For example, if a threshold is set to half size of heap, then
for an application which usually makes big number of small allocations, that
will (try to) keep half of heap memory in a nice defragmented state for an
occasional large allocation.

For an application which doesn't exhibit such behavior, there won't be any
visible effects, except for GC running more frequently, which however may
affect performance. To address this, the GC threshold is configurable, and
by default is off so far. It's configured with gc.threshold(amount_in_bytes)
call (can be queries without an argument).
</content>
</entry>
<entry>
<title>extmod/moduos_dupterm: Reserve buffer bytearray object for dupterm.</title>
<updated>2016-07-04T10:32:30+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2016-07-04T10:32:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=426112ce88bf3f6f86bf6900b74d7719d9991167'/>
<id>urn:sha1:426112ce88bf3f6f86bf6900b74d7719d9991167</id>
<content type='text'>
Allocating it for each read/write operation is a memory fragmentation
hazard.
</content>
</entry>
<entry>
<title>py: Implement a simple global interpreter lock.</title>
<updated>2016-06-28T10:28:50+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-05-26T10:42:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=4cec63a9dbed86c4332b9e7fcd56d092046193e4'/>
<id>urn:sha1:4cec63a9dbed86c4332b9e7fcd56d092046193e4</id>
<content type='text'>
This makes the VM/runtime thread safe, at the cost of not being able to
run code in parallel.
</content>
</entry>
<entry>
<title>py: Make interning of qstrs thread safe.</title>
<updated>2016-06-28T10:28:50+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-05-26T09:06:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=1f54ad2aed0dc8f2d868ccd89ccf639a475e8022'/>
<id>urn:sha1:1f54ad2aed0dc8f2d868ccd89ccf639a475e8022</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py/gc: Make memory manager and garbage collector thread safe.</title>
<updated>2016-06-28T10:28:49+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-04-25T15:28:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=c93d9caa8b8be81f7e6faf9f2ca2ad16d4942ab8'/>
<id>urn:sha1:c93d9caa8b8be81f7e6faf9f2ca2ad16d4942ab8</id>
<content type='text'>
By using a single, global mutex, all memory-related functions (alloc,
free, realloc, collect, etc) are made thread safe.  This means that only
one thread can be in such a function at any one time.
</content>
</entry>
<entry>
<title>py: Add basic _thread module, with ability to start a new thread.</title>
<updated>2016-06-28T10:28:48+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-04-22T22:52:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=27cc07721b3c3c2d0b9c8678c8a3ddc7fe96cd97'/>
<id>urn:sha1:27cc07721b3c3c2d0b9c8678c8a3ddc7fe96cd97</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py: Add MP_STATE_THREAD to hold state specific to a given thread.</title>
<updated>2016-06-28T10:09:31+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-04-22T22:44:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=330165a2cc9a0d4d5d00f13f851412c25d5f4ed2'/>
<id>urn:sha1:330165a2cc9a0d4d5d00f13f851412c25d5f4ed2</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py: Add MICROPY_DYNAMIC_COMPILER option to config compiler at runtime.</title>
<updated>2016-02-25T10:05:46+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-02-11T22:30:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=ea23520403777f9b026f49245d39f8be1ccdbdac'/>
<id>urn:sha1:ea23520403777f9b026f49245d39f8be1ccdbdac</id>
<content type='text'>
This new compile-time option allows to make the bytecode compiler
configurable at runtime by setting the fields in the mp_dynamic_compiler
structure.  By using this feature, the compiler can generate bytecode
that targets any MicroPython runtime/VM, regardless of the host and
target compile-time settings.

Options so far that fall under this dynamic setting are:
- maximum number of bits that a small int can hold;
- whether caching of lookups is used in the bytecode;
- whether to use unicode strings or not (lexer behaviour differs, and
  therefore generated string constants differ).
</content>
</entry>
<entry>
<title>py/mpstate.h: fs_user_mount is now standard, reusable uPy functionality.</title>
<updated>2016-02-14T22:02:03+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2016-02-14T22:02:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=72085a669babf83774716e21f6191bf2f84936a5'/>
<id>urn:sha1:72085a669babf83774716e21f6191bf2f84936a5</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py: Clean up instantiation of dupterm object.</title>
<updated>2016-01-01T12:22:57+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2016-01-01T12:19:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=00ee84e1e139416e1069a87965065a8c66c8afa4'/>
<id>urn:sha1:00ee84e1e139416e1069a87965065a8c66c8afa4</id>
<content type='text'>
To comply with already established scheme for extmod's.
</content>
</entry>
</feed>
