当前位置:网站首页>Chapter 18 using work queue manager (1)
Chapter 18 using work queue manager (1)
2022-07-05 08:28:00 【yaoxin521123】
List of articles
Chapter 18 Use the work queue manager ( One )
Work queue manager is a function of , Enables you to improve performance by programmatically allocating work to multiple concurrent processes . Before introducing the work queue manager , May have been used JOB Command starts multiple processes in the application and uses custom code to manage these processes ( And any resulting failure ). Work queue managers provide an efficient and direct API, Enable to uninstall process management .
The code uses the work queue manager internally in multiple places . You can use it for your own needs , As described in the following section .
background
The latest innovations in computer hardware development tend to be high-performance 、 Multiprocessor or multicore architecture . meanwhile , The speed of memory and network devices has only slowly increased . Work queue managers have been developed to respond to these trends and according to the following principles :
- Hardware resources , Include CPU and I/O、 Memory and network devices , It's all fixed .
- Hardware resources must be used as efficiently as possible , To maximize the speed of their business tasks .
- For maximum efficiency , The work queue manager must improve during execution ObjectScript Code may appear CPU The problem of underutilization .
- solve CPU Underutilized methods include queuing and prioritization .
Although the whole data platform aims to make the most of the hardware resources in the system , However, the work queue manager function of the platform is specifically designed to take advantage of the additional... Available in modern hardware configurations CPU resources . Work queue managers have two key uses :
- Provide a framework , Enables you to break down large programming tasks into smaller blocks , To execute in multiple concurrent processes . By using multiple at once CPU, Work queue managers significantly reduce the time required to process large workloads .
- Through the management system, the task is active at one time JOB To control the total on the system CPU load .
ObjectScript CPU utilization
Usually ,ObjectScript The code runs in a single process and uses only one processor core . For transactional database applications that handle relatively few instructions and global references between transactions , This method works well . in fact , A key feature of the data platform is the large-scale scalability of the transaction workload . The platform optimizes the processing of a large number of relatively small work units requested by a large number of users at one time .
Some newer types of workloads ( for example , Analyze the workload ) And The workloads initially built for optimization are different . for example , Newer workloads may involve processing a that requires millions of rows to perform various operations SQL Inquire about . To speed up the processing of such workloads , Developed a work queue manager , It breaks down the overall workload into smaller blocks , Process these blocks in parallel , And relay the results of each block back to the parent process , Then the parent process can relay the results back to you . let me put it another way , Work queue manager is a kind of similar to Queues The mechanism of , It enables developers who build their applications in to break down large tasks into smaller tasks for parallel processing .
Functions of work queue manager
Work queue managers include several key features :
- Low latency and overhead
- Extensibility
- Cooperation with operating system
- flexibility
- High level of control and reporting
Low latency and overhead
Work queue managers are designed for low latency and low overhead . for example , Consider a procedural task , System needs 10 Minutes to process in order . If the system has 10 Kernel , Then it will be more efficient to split the tasks and process one tenth of the work in parallel on each kernel . actually , If you split tasks 、 Queue up for each task 、 The overhead involved in starting work jobs and collecting notifications of the completion of each task does not require any additional time , Then you can get the result 10 How fast . Work queue managers are designed to overhead tasks resulting in low latency .
Extensibility
To maximize performance , The work queue manager is able to use all... On the system CPU Resources to handle a single task . actually , The work queue manager limits the number of cores that a given type of task can use , To ensure that all workloads on the system can be effectively handled .
Cooperation with operating system
Use traditional for large transactional database applications ObjectScript Code , The operating system may spend a lot of resources switching between programming tasks , This is sometimes called context switching . Because the work queue manager adopts the queuing mechanism on each kernel , Therefore, the need for context switching is greatly reduced . Only when the number of active jobs managed by the work queue manager exceeds the number of available cores , Only the operating system needs context switching . such , Queuing usually improves performance .
flexibility
A unit of work is a class method or subroutine that takes a set of parameters and meets the requirements described in the unit of work . Any logic that can be represented in these constraints can be handled by the work queue manager , So as to provide great flexibility .
High level of control and reporting
The work queue manager provides access to CPU Advanced control of resource usage . for example , You can create job Categories and define the staff assigned to these categories job The number of . Besides , The work queue manager provides workload metrics , So that the load on the system can be monitored in real time .
About work units
The work queue manager processes units of work ( Also known as work items ) To make a difference , These work units meet the following requirements ObjectScript Class method or subroutine :
- Class methods or subroutines can be handled independently . for example , A unit of work cannot depend on the output of different units of work . Because work units can be processed in any order , Therefore, independence is needed . however , if necessary , You can use callbacks to perform work in sequence .
- The size of a class method or subroutine is about thousands of lines ObjectScript Code . This requirement ensures that the overhead of the framework is not an important factor .
Besides , It's best to use a lot ( for example ,100 individual ) Smaller units of work , Instead of using a few very large units of work ( for example ,4 individual ). Allocating work in this way allows the system to do more CPU Expand when the kernel is available .
- The code returns a
%StatusValue to indicate success or failure , In order toWaitForComplete()Method can return a%StatusValue to indicate overall success or failure . perhaps , Work units can throw exceptions , The exception is caught 、 Convert to%StatusValue and return in the main process . - If the code changes the same global to a different unit of work , Then a locking strategy must be adopted to ensure a
work JOBIn another work The global cannot be changed while it is being read . - This code does not include
news,kills,unlocks, Because these will interfere with the framework . - If the code contains process private global variables for storing data , Then these process private global variables will not be accessed from the main process or any other block . This requirement is necessary , Because multiple jobs process each block .
- Any logic called as part of a class method or subroutine is cleaned up correctly , So that there are no variables in the partition 、 lock 、 Process specific global variables or other artifacts . This requirement is important , Because then the same process will be used to deal with completely independent work items .
To use the work queue manager , Some procedural work must be divided into work units .
About Worker Jobs
Worker jobs It is the process of completing the unit of work for the work queue manager . By using %SYSTEM.Process class , It can be viewed like other processes 、 Manage and monitor jobs . If you need to know whether a given process is a work job , You can call $system.WorkMgr.IsWorkerJob()
The work queue manager uses the controller process to guide the work job, The controller process is a dedicated process that performs the following operations :
- start-up worker jobs
- management worker jobs The number of
- Detect and report suspended worker jobs
- Record workload metrics
- Detect inactive work queues
- Delete work queue
worker jobs Can be in any of the following states :
- Waiting to be attached to the work queue
- Waiting for work unit . Before release ,worker jobs Can only be in this state for a very short time .
- Activate . Only when it performs the forwarding process while executing a unit of work ,worker jobs Is active .
- Blocked by a lock or event while processing a unit of work . Blocked worker jobs Not active . If worker jobs Blocked and there is extra job, Work queue managers can activate inactive woker Or start a new woker. When worker jobs When it is no longer blocked , Activities worker jobs The number of may exceed the activities specified for the work queue worker jobs Maximum number of . If this happens , The controller process will eliminate the next unit of work worker jobs. therefore , When worker jobs The number of activities for exceeds the specified for the given work queue worker jobs The maximum number of , There may be a short period of time .
- Disabled and can be quickly activated
That is not used worker jobs It can still be used by other work queue manager queues for a short time . The timeout period may change , And deliberately unrecorded . After the timeout period expires ,worker Removed .
If worker jobs Actively processing work items of deleted or cleared queues , The system will wait for a very short time , Then send out EXTERNAL INTERRUPT error . If worker jobs Continue processing after the error , The system will wait DeleteTimeout The number of seconds specified in the property , Then forcibly terminate worker And start a new worker To deal with work units .
Super server starts worker jobs, This means that they run under the name of the operating system user used by the super server process . This user name may be different from the currently logged in operating system user .
边栏推荐
- Live555 RTSP audio and video streaming summary (II) modify RTSP server streaming URL address
- Brief discussion on Buck buck circuit
- Explication de la procédure stockée pour SQL Server
- Imx6ull bare metal development learning 2- use C language to light LED indicator
- NTC thermistor application - temperature measurement
- Solutions to compilation warnings in Quartus II
- Soem EtherCAT source code analysis I (data type definition)
- Go dependency injection -- Google open source library wire
- Several implementation schemes of anti reverse connection protection of positive and negative poles of power supply!
- Imx6ull bare metal development learning 1-assembly lit LED
猜你喜欢

STM32 --- NVIC interrupt

Hardware and software solution of FPGA key chattering elimination

Summary of SIM card circuit knowledge

实例010:给人看的时间

Compilation warning solution sorting in Quartus II

Example 010: time to show

Stablq of linked list

Ble encryption details

Carrier period, electrical speed, carrier period variation
![[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication](/img/08/7f28008a4aa999650998ba8dee5d8e.jpg)
[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
随机推荐
每日一题——输入一个日期,输出它是该年的第几天
实例004:这天第几天 输入某年某月某日,判断这一天是这一年的第几天?
Synchronization of QT multithreading
Five design details of linear regulator
Infected Tree(树形dp)
Array integration initialization (C language)
如何写Cover Letter?
FIO测试硬盘性能参数和实例详细总结(附源码)
Various types of questions judged by prime numbers within 100 (C language)
Imx6ull bare metal development learning 1-assembly lit LED
STM32 virtualization environment of QEMU
Summary of SIM card circuit knowledge
Example 002: the bonus paid by the "individual income tax calculation" enterprise is based on the profit commission. When the profit (I) is less than or equal to 100000 yuan, the bonus can be increase
实例006:斐波那契数列
每日一题——替换空格
剑指 Offer 06. 从尾到头打印链表
STM32 --- serial port communication
How to write cover letter?
[trio basic from introduction to mastery tutorial XIV] trio realizes unit axis multi-color code capture
Sql Server的存储过程详解