Create per-thread task and memory context for zonemgr
Previously, the zonemgr created 1 task per 100 zones and 1 memory context per 1000 zones (with minimum 10 tasks and 2 memory contexts) to reduce the contention between threads. Instead of reducing the contention by having many resources, create a per-nm_thread memory context, loadtask and zonetask and spread the zones between just per-thread resources. Note: this commit alone does decrease performance when loading the zone by couple seconds (in case of 1M zone) and thus there's more work in this whole MR fixing the performance.
This commit is contained in:
@@ -84,45 +84,7 @@ void *
|
||||
isc_pool_get(isc_pool_t *pool);
|
||||
/*%<
|
||||
* Returns a pointer to an object from the pool. Currently the object
|
||||
* is chosen from the pool at random. (This may be changed in the future
|
||||
* to something that guaratees balance.)
|
||||
*/
|
||||
|
||||
int
|
||||
isc_pool_count(isc_pool_t *pool);
|
||||
/*%<
|
||||
* Returns the number of objcts in the pool 'pool'.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_pool_expand(isc_pool_t **sourcep, unsigned int count, isc_pool_t **targetp);
|
||||
|
||||
/*%<
|
||||
* If 'size' is larger than the number of objects in the pool pointed to by
|
||||
* 'sourcep', then a new pool of size 'count' is allocated, the existing
|
||||
* objects are copied into it, additional ones created to bring the
|
||||
* total number up to 'count', and the resulting pool is attached to
|
||||
* 'targetp'.
|
||||
*
|
||||
* If 'count' is less than or equal to the number of objects in 'source', then
|
||||
* 'sourcep' is attached to 'targetp' without any other action being taken.
|
||||
*
|
||||
* In either case, 'sourcep' is detached.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
* \li 'sourcep' is not NULL and '*source' is not NULL
|
||||
* \li 'targetp' is not NULL and '*source' is NULL
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
* \li On success, '*targetp' points to a valid task pool.
|
||||
* \li On success, '*sourcep' points to NULL.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* \li #ISC_R_SUCCESS
|
||||
* \li #ISC_R_NOMEMORY
|
||||
* is chosen from the pool at random.
|
||||
*/
|
||||
|
||||
void
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/taskpool.h
|
||||
* \brief A task pool is a mechanism for sharing a small number of tasks
|
||||
* among a large number of objects such that each object is
|
||||
* assigned a unique task, but each task may be shared by several
|
||||
* objects.
|
||||
*
|
||||
* Task pools are used to let objects that can exist in large
|
||||
* numbers (e.g., zones) use tasks for synchronization without
|
||||
* the memory overhead and unfair scheduling competition that
|
||||
* could result from creating a separate task for each object.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports.
|
||||
***/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/task.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*****
|
||||
***** Types.
|
||||
*****/
|
||||
|
||||
typedef struct isc_taskpool isc_taskpool_t;
|
||||
|
||||
/*****
|
||||
***** Functions.
|
||||
*****/
|
||||
|
||||
isc_result_t
|
||||
isc_taskpool_create(isc_taskmgr_t *tmgr, isc_mem_t *mctx, unsigned int ntasks,
|
||||
unsigned int quantum, bool priv, isc_taskpool_t **poolp);
|
||||
/*%<
|
||||
* Create a task pool of "ntasks" tasks, each with quantum
|
||||
* "quantum".
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'tmgr' is a valid task manager.
|
||||
*
|
||||
*\li 'mctx' is a valid memory context.
|
||||
*
|
||||
*\li poolp != NULL && *poolp == NULL
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li On success, '*taskp' points to the new task pool.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_NOMEMORY
|
||||
*\li #ISC_R_UNEXPECTED
|
||||
*/
|
||||
|
||||
void
|
||||
isc_taskpool_gettask(isc_taskpool_t *pool, isc_task_t **targetp);
|
||||
/*%<
|
||||
* Attach to a task from the pool. Currently the next task is chosen
|
||||
* from the pool at random. (This may be changed in the future to
|
||||
* something that guaratees balance.)
|
||||
*/
|
||||
|
||||
int
|
||||
isc_taskpool_size(isc_taskpool_t *pool);
|
||||
/*%<
|
||||
* Returns the number of tasks in the task pool 'pool'.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_taskpool_expand(isc_taskpool_t **sourcep, unsigned int size, bool priv,
|
||||
isc_taskpool_t **targetp);
|
||||
|
||||
/*%<
|
||||
* If 'size' is larger than the number of tasks in the pool pointed to by
|
||||
* 'sourcep', then a new taskpool of size 'size' is allocated, the existing
|
||||
* tasks from are moved into it, additional tasks are created to bring the
|
||||
* total number up to 'size', and the resulting pool is attached to
|
||||
* 'targetp'.
|
||||
*
|
||||
* If 'size' is less than or equal to the tasks in pool 'source', then
|
||||
* 'sourcep' is attached to 'targetp' without any other action being taken.
|
||||
*
|
||||
* In either case, 'sourcep' is detached.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
* \li 'sourcep' is not NULL and '*source' is not NULL
|
||||
* \li 'targetp' is not NULL and '*source' is NULL
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
* \li On success, '*targetp' points to a valid task pool.
|
||||
* \li On success, '*sourcep' points to NULL.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* \li #ISC_R_SUCCESS
|
||||
* \li #ISC_R_NOMEMORY
|
||||
*/
|
||||
|
||||
void
|
||||
isc_taskpool_destroy(isc_taskpool_t **poolp);
|
||||
/*%<
|
||||
* Destroy a task pool. The tasks in the pool are detached but not
|
||||
* shut down.
|
||||
*
|
||||
* Requires:
|
||||
* \li '*poolp' is a valid task pool.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
Reference in New Issue
Block a user