Skip to content

Commit

Permalink
Enable GC For Repeated Runs (#277)
Browse files Browse the repository at this point in the history
* Enable GC For Repeated Runs

In looking into why the pypy profiling was behaving erratically on GH
I observed that memory usage for the Ion Text tests in pure-python
mode was quite high: roughly 3gb for less than 500 iterations.

pypy uses the pure-python implementation.

In looking at the code I observed that setup_with_gc was not actually
being setup _with_ gc. Enabling it in these places makes a substantial
difference in memory use on my laptop.

Also makes trivial comment change intended to trigger
regression profiling check.
  • Loading branch information
rmarrowstone committed Jul 20, 2023
1 parent 1286877 commit a48586a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion amazon/ion/simpleion.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from .writer_binary import binary_writer


# Using C extension as default, and original python implementation if C extension doesn't exist.
# Using C extension as default, and pure python implementation if C extension doesn't exist.
c_ext = True
try:
import amazon.ion.ionc as ionc
Expand Down
8 changes: 4 additions & 4 deletions amazon/ionbenchmark/ion_benchmark_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def read_micro_benchmark(iterations, warmups, c_extension, file, memory_profilin
iterator=False):
file_size = Path(file).stat().st_size / BYTES_TO_MB

setup_with_gc = generate_setup(format_option=format_option, gc=False, memory_profiling=memory_profiling)
setup_with_gc = generate_setup(format_option=format_option, gc=True, memory_profiling=memory_profiling)

test_code = generate_read_test_code(file, memory_profiling=memory_profiling,
format_option=format_option, io_type=io_type, binary=binary)
Expand All @@ -310,7 +310,7 @@ def read_micro_benchmark_simpleion(iterations, warmups, c_extension, file, memor
io_type, iterator=False):
file_size = Path(file).stat().st_size / BYTES_TO_MB

setup_with_gc = generate_setup(format_option=format_option, c_extension=c_extension, gc=False,
setup_with_gc = generate_setup(format_option=format_option, c_extension=c_extension, gc=True,
memory_profiling=memory_profiling)

test_code = generate_read_test_code(file, format_option=format_option, emit_bare_values=False,
Expand Down Expand Up @@ -380,7 +380,7 @@ def write_micro_benchmark_simpleion(iterations, warmups, c_extension, file, bina
obj = ion.load(fp, parse_eagerly=True, single_value=False)

# GC refers to reference cycles, not reference count
setup_with_gc = generate_setup(format_option=format_option, gc=False, c_extension=c_extension,
setup_with_gc = generate_setup(format_option=format_option, gc=True, c_extension=c_extension,
memory_profiling=memory_profiling)

test_func = generate_write_test_code(obj, memory_profiling=memory_profiling, binary=binary,
Expand All @@ -400,7 +400,7 @@ def write_micro_benchmark(iterations, warmups, c_extension, file, binary, memory
file_size = Path(file).stat().st_size / BYTES_TO_MB
obj = generate_json_and_cbor_obj_for_write(file, format_option, binary=binary)
# GC refers to reference cycles, not reference count
setup_with_gc = generate_setup(format_option=format_option, gc=False, memory_profiling=memory_profiling)
setup_with_gc = generate_setup(format_option=format_option, gc=True, memory_profiling=memory_profiling)

test_func = generate_write_test_code(obj, memory_profiling=memory_profiling, format_option=format_option,
io_type=io_type, binary=binary)
Expand Down

0 comments on commit a48586a

Please sign in to comment.