|
1 | 1 | from multiprocessing import Queue, Process
|
2 | 2 |
|
3 | 3 | import pytest
|
4 |
| -from arcticdb.util.test import sample_dataframe |
| 4 | +from arcticdb import LibraryOptions |
| 5 | +from arcticdb.encoding_version import EncodingVersion |
| 6 | +from arcticdb.util.test import sample_dataframe, config_context_multi |
5 | 7 | from arcticdb_ext.storage import KeyType
|
| 8 | +import arcticdb_ext.cpp_async as adb_async |
6 | 9 |
|
7 | 10 |
|
8 | 11 | def test_symbol_sizes(basic_store):
|
@@ -105,6 +108,79 @@ def test_scan_object_sizes(arctic_client, lib_name):
|
105 | 108 | assert 500 < res[KeyType.VERSION_REF][1] < 1500
|
106 | 109 |
|
107 | 110 |
|
| 111 | +@pytest.mark.parametrize("storage, encoding_version_, num_io_threads, num_cpu_threads", [ |
| 112 | + ("s3", EncodingVersion.V1, 1, 1), |
| 113 | + ("s3", EncodingVersion.V1, 10, 1), |
| 114 | + ("s3", EncodingVersion.V1, 1, 10), |
| 115 | +]) |
| 116 | +def test_scan_object_sizes_threading(request, storage, encoding_version_, lib_name, num_io_threads, num_cpu_threads): |
| 117 | + """Some stress testing for scan_object_sizes, particularly against deadlocks. Use a small segment size so that |
| 118 | + there is some work to be done in parallel.""" |
| 119 | + storage_fixture = request.getfixturevalue(storage + "_storage") |
| 120 | + arctic_client = storage_fixture.create_arctic(encoding_version=encoding_version_) |
| 121 | + try: |
| 122 | + with config_context_multi({"VersionStore.NumIOThreads": num_io_threads, "VersionStore.NumCPUThreads": num_cpu_threads}): |
| 123 | + adb_async.reinit_task_scheduler() |
| 124 | + if num_io_threads: |
| 125 | + assert adb_async.io_thread_count() == num_io_threads |
| 126 | + if num_cpu_threads: |
| 127 | + assert adb_async.cpu_thread_count() == num_cpu_threads |
| 128 | + |
| 129 | + lib = arctic_client.create_library(lib_name, library_options=LibraryOptions(rows_per_segment=5)) |
| 130 | + basic_store = lib._nvs |
| 131 | + |
| 132 | + df = sample_dataframe(100) |
| 133 | + basic_store.write("sym", df) |
| 134 | + basic_store.write("sym", df) |
| 135 | + |
| 136 | + sizes = basic_store.version_store.scan_object_sizes() |
| 137 | + |
| 138 | + res = dict() |
| 139 | + for s in sizes: |
| 140 | + res[s.key_type] = (s.count, s.compressed_size_bytes) |
| 141 | + |
| 142 | + assert KeyType.VERSION in res |
| 143 | + assert KeyType.TABLE_INDEX in res |
| 144 | + assert KeyType.TABLE_DATA in res |
| 145 | + assert KeyType.VERSION_REF in res |
| 146 | + finally: |
| 147 | + adb_async.reinit_task_scheduler() |
| 148 | + |
| 149 | + |
| 150 | +@pytest.mark.parametrize("storage, encoding_version_, num_io_threads, num_cpu_threads", [ |
| 151 | + ("s3", EncodingVersion.V1, 1, 1), |
| 152 | + ("s3", EncodingVersion.V1, 10, 1), |
| 153 | + ("s3", EncodingVersion.V1, 1, 10), |
| 154 | +]) |
| 155 | +def test_scan_object_sizes_by_stream_threading(request, storage, encoding_version_, lib_name, num_io_threads, num_cpu_threads): |
| 156 | + """Some stress testing for scan_object_sizes, particularly against deadlocks. Use a small segment size so that |
| 157 | + there is some work to be done in parallel.""" |
| 158 | + storage_fixture = request.getfixturevalue(storage + "_storage") |
| 159 | + arctic_client = storage_fixture.create_arctic(encoding_version=encoding_version_) |
| 160 | + try: |
| 161 | + with config_context_multi({"VersionStore.NumIOThreads": num_io_threads, "VersionStore.NumCPUThreads": num_cpu_threads}): |
| 162 | + adb_async.reinit_task_scheduler() |
| 163 | + if num_io_threads: |
| 164 | + assert adb_async.io_thread_count() == num_io_threads |
| 165 | + if num_cpu_threads: |
| 166 | + assert adb_async.cpu_thread_count() == num_cpu_threads |
| 167 | + |
| 168 | + lib = arctic_client.create_library(lib_name, library_options=LibraryOptions(rows_per_segment=5)) |
| 169 | + basic_store = lib._nvs |
| 170 | + |
| 171 | + df = sample_dataframe(100) |
| 172 | + basic_store.write("sym", df) |
| 173 | + basic_store.write("sym", df) |
| 174 | + |
| 175 | + sizes = basic_store.version_store.scan_object_sizes_by_stream() |
| 176 | + |
| 177 | + assert sizes["sym"][KeyType.VERSION].compressed_size < 2000 |
| 178 | + assert sizes["sym"][KeyType.TABLE_INDEX].compressed_size < 5000 |
| 179 | + assert sizes["sym"][KeyType.TABLE_DATA].compressed_size < 50_000 |
| 180 | + finally: |
| 181 | + adb_async.reinit_task_scheduler() |
| 182 | + |
| 183 | + |
108 | 184 | @pytest.fixture
|
109 | 185 | def reader_store(basic_store):
|
110 | 186 | return basic_store
|
@@ -141,7 +217,7 @@ def test_symbol_sizes_concurrent(reader_store, writer_store):
|
141 | 217 | try:
|
142 | 218 | reader.start()
|
143 | 219 | writer.start()
|
144 |
| - reader.join(1) |
| 220 | + reader.join(2) |
145 | 221 | writer.join(0.001)
|
146 | 222 | finally:
|
147 | 223 | writer.terminate()
|
|
0 commit comments