Skip to content

Commit

Permalink
[docs] Update config docs
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaZotov committed Apr 14, 2023
1 parent 3f11c0b commit 2ab27f4
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion config/sc-machine.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[sc-memory]
max_loaded_segments = 1000
max_threads = 32
events_processors = 1
max_events_and_agents_threads = 32

save_period = 3600
update_period = 1800
Expand Down
3 changes: 3 additions & 0 deletions docs/other/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
[sc-memory]
# Maximum number of segments. By default: 65536
max_loaded_segments = 1000
# Maximum number of threads that can be used to access to sc-memory
max_threads = 32
# Maximum number of threads that can be used in events and agents handler
max_events_and_agents_threads = 32

# Period (in seconds) to save sc-memory stat
save_period = 3600
Expand Down
4 changes: 2 additions & 2 deletions sc-memory/sc-core/sc-store/sc_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ void sc_event_unlock(sc_event * evt)
}

// --------
sc_bool sc_events_initialize_ext(sc_int32 const events_processors)
sc_bool sc_events_initialize_ext(sc_int32 const max_events_and_agents_threads)
{
event_queue = sc_event_queue_new_ext(events_processors);
event_queue = sc_event_queue_new_ext(max_events_and_agents_threads);
return SC_TRUE;
}

Expand Down
2 changes: 1 addition & 1 deletion sc-memory/sc-core/sc-store/sc_event/sc_event_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct _sc_event
};

//! Function to initialize sc-events module with user processors number
sc_bool sc_events_initialize_ext(sc_int32 events_processors);
sc_bool sc_events_initialize_ext(sc_int32 max_events_and_agents_threads);

//! Function to initialize sc-events module
sc_bool sc_events_initialize();
Expand Down
9 changes: 5 additions & 4 deletions sc-memory/sc-core/sc-store/sc_event/sc_event_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,20 @@ void sc_event_pool_worker(gpointer data, gpointer user_data)
sc_event_pool_worker_data_destroy(work_data);
}

sc_event_queue * sc_event_queue_new_ext(sc_int32 events_processors)
sc_event_queue * sc_event_queue_new_ext(sc_int32 max_events_and_agents_threads)
{
sc_event_queue * queue = sc_mem_new(sc_event_queue, 1);
queue->running = SC_TRUE;
g_mutex_init(&queue->mutex);

events_processors = sc_max(1, sc_min(events_processors, (sc_int32)g_get_num_processors()));
max_events_and_agents_threads = sc_max(1, sc_min(max_events_and_agents_threads, (sc_int32)g_get_num_processors()));
{
sc_message("Sc-events configuration:");
sc_message("\tprocessors: %d", events_processors);
sc_message("\tprocessors: %d", max_events_and_agents_threads);
}

queue->thread_pool = g_thread_pool_new(sc_event_pool_worker, null_ptr, events_processors, SC_FALSE, null_ptr);
queue->thread_pool =
g_thread_pool_new(sc_event_pool_worker, null_ptr, max_events_and_agents_threads, SC_FALSE, null_ptr);

return queue;
}
Expand Down
2 changes: 1 addition & 1 deletion sc-memory/sc-core/sc-store/sc_event/sc_event_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct _sc_event_queue
typedef struct _sc_event_queue sc_event_queue;

//! Create new sc-event queue with user processors number
sc_event_queue * sc_event_queue_new_ext(sc_int32 events_processors);
sc_event_queue * sc_event_queue_new_ext(sc_int32 max_events_and_agents_threads);

//! Create new sc-event queue
sc_event_queue * sc_event_queue_new();
Expand Down
2 changes: 1 addition & 1 deletion sc-memory/sc-core/sc_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ sc_memory_context * sc_memory_initialize(const sc_memory_params * params)
goto error;
sc_memory_context_free(helper_ctx);

if (sc_events_initialize_ext(params->events_processors) == SC_FALSE)
if (sc_events_initialize_ext(params->max_events_and_agents_threads) == SC_FALSE)
{
sc_error("Error while initialize events module");
goto error;
Expand Down
2 changes: 1 addition & 1 deletion sc-memory/sc-core/sc_memory_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void sc_memory_params_clear(sc_memory_params * params)

params->max_loaded_segments = DEFAULT_MAX_LOADED_SEGMENTS;
params->max_threads = DEFAULT_MAX_THREADS;
params->events_processors = DEFAULT_EVENTS_PROCESSORS;
params->max_events_and_agents_threads = DEFAULT_EVENTS_PROCESSORS;

params->init_memory_generated_structure = (sc_char const *)null_ptr;
params->init_memory_generated_upload = SC_FALSE;
Expand Down
2 changes: 1 addition & 1 deletion sc-memory/sc-core/sc_memory_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ typedef struct _sc_memory_params

sc_uint32 max_loaded_segments;
sc_uint8 max_threads;
sc_int32 events_processors;
sc_int32 max_events_and_agents_threads;

const sc_char * init_memory_generated_structure;
sc_bool init_memory_generated_upload;
Expand Down
4 changes: 2 additions & 2 deletions sc-memory/tests/sc-memory/_test/sc_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ScMemoryTest : public testing::Test
params.repo_path = "repo";
params.log_level = "Debug";

params.events_processors = 1;
params.max_events_and_agents_threads = 1;

ScMemory::LogMute();
ScMemory::Initialize(params);
Expand Down Expand Up @@ -67,7 +67,7 @@ class ScMemoryTestWithInitMemoryGeneratedStructure : public ScMemoryTest
params.repo_path = "repo";
params.log_level = "Debug";

params.events_processors = 1;
params.max_events_and_agents_threads = 1;

params.init_memory_generated_upload = SC_TRUE;
params.init_memory_generated_structure = "result_structure";
Expand Down
3 changes: 2 additions & 1 deletion sc-tools/sc-config-utils/sc_memory_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ class ScMemoryConfig

m_memoryParams.max_loaded_segments = GetIntByKey("max_loaded_segments", DEFAULT_MAX_LOADED_SEGMENTS);
m_memoryParams.max_threads = GetIntByKey("max_threads", DEFAULT_MAX_THREADS);
m_memoryParams.events_processors = GetIntByKey("events_processors", DEFAULT_EVENTS_PROCESSORS);
m_memoryParams.max_events_and_agents_threads =
GetIntByKey("max_events_and_agents_threads", DEFAULT_EVENTS_PROCESSORS);

m_memoryParams.save_period = GetIntByKey("save_period", DEFAULT_SAVE_PERIOD);
m_memoryParams.update_period = GetIntByKey("update_period", DEFAULT_UPDATE_PERIOD);
Expand Down

0 comments on commit 2ab27f4

Please sign in to comment.