Skip to content

Commit

Permalink
Merge pull request #1611 from AntelopeIO/read_only_threads_128
Browse files Browse the repository at this point in the history
Increase maximum supported number of read-only threads to 128
  • Loading branch information
linh2931 authored Sep 8, 2023
2 parents 185a135 + 920f325 commit b73c28d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
10 changes: 7 additions & 3 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,13 @@ class producer_plugin_impl : public std::enable_shared_from_this<producer_plugin
};

uint32_t _ro_thread_pool_size{0};
// Due to uncertainty to get total virtual memory size on a 5-level paging system for eos-vm-oc and
// possible memory exhuastion for large number of contract usage for non-eos-vm-oc, set a hard limit
static constexpr uint32_t _ro_max_threads_allowed{8};
// In EOS VM OC tierup, 10 pages (11 slices) virtual memory is reserved for
// each read-only thread and 528 pages (529 slices) for the main-thread memory.
// With maximum 128 read-only threads, virtual memory required by OC is
// 15TB (OC's main thread uses 4TB VM (by 529 slices) and the read-only
// threads use 11TB (128 * 11 * 8GB)). It is about 11.7% of total VM space
// in a 64-bit Linux machine (about 128TB).
static constexpr uint32_t _ro_max_threads_allowed{128};
named_thread_pool<struct read> _ro_thread_pool;
fc::microseconds _ro_write_window_time_us{200000};
fc::microseconds _ro_read_window_time_us{60000};
Expand Down
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ add_test(NAME compute_transaction_test COMMAND tests/compute_transaction_test.py
set_property(TEST compute_transaction_test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME read-only-trx-basic-test COMMAND tests/read_only_trx_test.py -v -p 2 -n 3 --read-only-threads 0 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST read-only-trx-basic-test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME read-only-trx-parallel-test COMMAND tests/read_only_trx_test.py -v -p 2 -n 3 --read-only-threads 6 --num-test-runs 3 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME read-only-trx-parallel-test COMMAND tests/read_only_trx_test.py -v -p 2 -n 3 --read-only-threads 128 --num-test-runs 3 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST read-only-trx-parallel-test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME read-only-trx-parallel-eos-vm-oc-test COMMAND tests/read_only_trx_test.py -v -p 2 -n 3 --eos-vm-oc-enable all --read-only-threads 6 --num-test-runs 3 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME read-only-trx-parallel-eos-vm-oc-test COMMAND tests/read_only_trx_test.py -v -p 2 -n 3 --eos-vm-oc-enable all --read-only-threads 128 --num-test-runs 3 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST read-only-trx-parallel-eos-vm-oc-test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME read-only-trx-parallel-no-oc-test COMMAND tests/read_only_trx_test.py -v -p 2 -n 3 --eos-vm-oc-enable none --read-only-threads 6 --num-test-runs 2 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST read-only-trx-parallel-no-oc-test PROPERTY LABELS nonparallelizable_tests)
Expand Down
12 changes: 7 additions & 5 deletions tests/read_only_trx_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,14 @@ def verifyOcVirtualMemory():
pageSize = os.sysconf("SC_PAGESIZE")
actualVmSize = vmPages * pageSize

# When OC tierup is enabled, virtual memory used by IC is around
# In OC tierup a memory slice is 8GB;
# The main thread uses 529 slices; each read-only thread uses 11 slices.
# Total virtual memory is around:
# 529 slices * 8GB (for main thread) + numReadOnlyThreads * 11 slices * 8GB
# This test verifies virtual memory taken by one read-only thread
# is not in the order of 1TB.
otherGB = 1000 # add 1TB for virtual memory used by others
expectedVmSize = ((529 * 8) + (args.read_only_threads * 88) + otherGB) * 1024 * 1024 * 1024
# This test verifies virtual memory does not grow by the number
# of read-only thread in the order of TB.
memoryByOthersGB = 1000 # add 1TB for virtual memory used by others
expectedVmSize = ((529 * 8) + (args.read_only_threads * 88) + memoryByOthersGB) * 1024 * 1024 * 1024
Utils.Print(f"pid: {apiNode.pid}, actualVmSize: {actualVmSize}, expectedVmSize: {expectedVmSize}")
assert(actualVmSize < expectedVmSize)
except FileNotFoundError:
Expand Down

0 comments on commit b73c28d

Please sign in to comment.