1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-25 01:42:45 +02:00
gnupg/tests/gpgscm
Justus Winter 83c184a66b gpgscm: Avoid cell allocation overhead.
* tests/gpgscm/scheme-private.h (struct scheme): New fields
'inhibit_gc', 'reserved_cells', and 'reserved_lineno'.
* tests/gpgscm/scheme.c (GC_ENABLED): New macro.
(USE_GC_LOCKING): Likewise.
(gc_reservations): Likewise.
(gc_reservation_failure): New function.
(_gc_disable): Likewise.
(gc_disable): New macro.
(gc_enable): Likewise.
(gc_enabled): Likewise.
(gc_consume): Likewise.
(get_cell_x): Consume reserved cell if garbage collection is disabled.
(_get_cell): Assert that gc is enabled.
(get_cell): Only record cell in the list of recently allocated cells
if gc is enabled.
(get_vector_object): Likewise.
(gc): Assert that gc is enabled.
(s_return): Add comment, adjust call to '_s_return'.
(s_return_enable_gc): New macro.
(_s_return): Add flag 'enable_gc' and re-enable gc if set.
(oblist_add_by_name): Use the new facilities to protect the
allocations.
(new_frame_in_env): Likewise.
(new_slot_spec_in_env): Likewise.
(s_save): Likewise.
(opexe_0): Likewise.
(opexe_1): Likewise.
(opexe_2): Likewise.
(opexe_5): Likewise.
(opexe_6): Likewise.
(scheme_init_custom_alloc): Initialize the new fields.
--

Every time a cell is allocated, the interpreter may run out of free
cells and do a garbage collection.  This is problematic because it
might garbage collect objects that have been allocated, but are not
yet made available to the interpreter.

Previously, we would plug such newly allocated cells into the list of
newly allocated objects rooted at car(sc->sink), but that requires
allocating yet another cell increasing pressure on the memory
management system.

A faster alternative is to preallocate the cells needed for an
operation and make sure the garbage collection is not run until all
allocated objects are plugged in.  This can be done with gc_disable
and gc_enable.

This optimization can be applied incrementally.  This commit picks all
low-hanging fruits.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-14 16:11:15 +01:00
..
ffi-private.h Change all http://www.gnu.org in license notices to https:// 2016-11-05 12:02:19 +01:00
ffi.c gpgscm: Expose seek and associated constants. 2016-11-08 16:02:55 +01:00
ffi.h Change all http://www.gnu.org in license notices to https:// 2016-11-05 12:02:19 +01:00
ffi.scm gpgscm: Implement 'atexit'. 2016-11-04 12:42:00 +01:00
init.scm tests: Refine exception handling. 2016-09-19 18:49:17 +02:00
lib.scm gpgscm: Expose seek and associated constants. 2016-11-08 16:02:55 +01:00
LICENSE.TinySCHEME Add license notices for TinySCHEME. 2016-06-17 18:53:45 +02:00
main.c Change all http://www.gnu.org in license notices to https:// 2016-11-05 12:02:19 +01:00
Makefile.am Change all http://www.gnu.org in license notices to https:// 2016-11-05 12:02:19 +01:00
Manual.txt Fix more spelling 2016-09-17 16:00:37 +09:00
opdefines.h tests/gpgscm: Verbatim import of latest TinySCHEME. 2016-06-17 11:36:27 +02:00
private.h Change all http://www.gnu.org in license notices to https:// 2016-11-05 12:02:19 +01:00
repl.scm tests: Refine the repl function. 2016-09-19 18:49:17 +02:00
scheme-config.h Change all http://www.gnu.org in license notices to https:// 2016-11-05 12:02:19 +01:00
scheme-private.h gpgscm: Avoid cell allocation overhead. 2016-11-14 16:11:15 +01:00
scheme.c gpgscm: Avoid cell allocation overhead. 2016-11-14 16:11:15 +01:00
scheme.h gpgscm: Reduce opcode dispatch overhead. 2016-11-10 14:57:07 +01:00
t-child.c Change all http://www.gnu.org in license notices to https:// 2016-11-05 12:02:19 +01:00
t-child.scm gpgscm: Improve test of low-level functions. 2016-10-07 16:25:55 +02:00
tests.scm tests: Move environment creation and teardown into each test. 2016-11-07 16:36:36 +01:00