Oracle instances on Unix/Linux servers have been composed historically by separated server processes to allow the database to be multi-user, in opposite with Windows that has always been multithread (Oracle 7 on MS-DOS was a single-user process, but this is prehistory…). The background processes number has increased to support all the new features of Oracle, up to this new Oracle 12c release. On a simple database installation you’ll be surprised to have this output from a ps command (38 processes):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# ps -eaf | grep CLASSIC | grep -v grep oracle 3582 1 0 21:59 ? 00:00:00 ora_pmon_CLASSIC oracle 3584 1 0 21:59 ? 00:00:00 ora_psp0_CLASSIC oracle 3590 1 4 21:59 ? 00:00:51 ora_vktm_CLASSIC oracle 3596 1 0 21:59 ? 00:00:00 ora_gen0_CLASSIC oracle 3599 1 0 21:59 ? 00:00:00 ora_mman_CLASSIC oracle 3608 1 0 21:59 ? 00:00:00 ora_diag_CLASSIC oracle 3612 1 0 21:59 ? 00:00:00 ora_dbrm_CLASSIC oracle 3616 1 0 21:59 ? 00:00:00 ora_dia0_CLASSIC oracle 3620 1 0 21:59 ? 00:00:00 ora_dbw0_CLASSIC oracle 3624 1 0 21:59 ? 00:00:04 ora_lgwr_CLASSIC oracle 3628 1 0 21:59 ? 00:00:00 ora_ckpt_CLASSIC oracle 3632 1 0 21:59 ? 00:00:00 ora_smon_CLASSIC oracle 3636 1 0 21:59 ? 00:00:00 ora_reco_CLASSIC oracle 3640 1 0 21:59 ? 00:00:00 ora_lreg_CLASSIC oracle 3644 1 0 21:59 ? 00:00:00 ora_rbal_CLASSIC oracle 3648 1 0 21:59 ? 00:00:00 ora_asmb_CLASSIC oracle 3652 1 0 21:59 ? 00:00:01 ora_mmon_CLASSIC oracle 3659 1 0 21:59 ? 00:00:00 ora_mmnl_CLASSIC oracle 3664 1 0 21:59 ? 00:00:00 ora_d000_CLASSIC oracle 3667 1 0 21:59 ? 00:00:00 ora_s000_CLASSIC oracle 3672 1 0 21:59 ? 00:00:00 ora_mark_CLASSIC oracle 3707 1 0 21:59 ? 00:00:01 ora_o000_CLASSIC oracle 3717 1 0 21:59 ? 00:00:01 ora_o001_CLASSIC oracle 3725 1 0 21:59 ? 00:00:00 ora_tmon_CLASSIC oracle 3729 1 0 21:59 ? 00:00:00 ora_tt00_CLASSIC oracle 3736 1 0 21:59 ? 00:00:00 ora_smco_CLASSIC oracle 3738 1 0 22:00 ? 00:00:00 ora_w000_CLASSIC oracle 3749 1 0 22:00 ? 00:00:00 ora_fbda_CLASSIC oracle 3751 1 0 22:00 ? 00:00:00 ora_aqpc_CLASSIC oracle 3757 1 0 22:00 ? 00:00:00 ora_qm02_CLASSIC oracle 3759 1 0 22:00 ? 00:00:00 ora_p000_CLASSIC oracle 3763 1 0 22:00 ? 00:00:00 ora_p001_CLASSIC oracle 3765 1 0 22:00 ? 00:00:00 ora_q002_CLASSIC oracle 3767 1 0 22:00 ? 00:00:00 ora_p002_CLASSIC oracle 3769 1 0 22:00 ? 00:00:00 ora_q003_CLASSIC oracle 3771 1 0 22:00 ? 00:00:00 ora_p003_CLASSIC oracle 3774 1 0 22:00 ? 00:00:00 ora_cjq0_CLASSIC oracle 3801 1 0 22:00 ? 00:00:02 ora_vkrm_CLASSIC |
If you have consolidated many databases without the pluggable database feature, you’ll end up to have several hundreds of processes even without users connected. But Oracle 12c now introduce the possibility to start an instance using multithreading instead of the traditional processes. This could lead to some optimizations due to the shared process memory, and reduced context switches overhead, I presume (need to test it).
Enabling the Multithreaded Execution
By default this feature is not enabled, so you have to set it explicitly:
1 2 3 4 5 |
SQL> alter system set threaded_execution=true scope=spfile; System altered. SQL> |
And in parallel, you’ll need to add this line to the listener.ora:
1 |
DEDICATED_THROUGH_BROKER_listener=on |
After a restart, the instance will show only a bunch of processes:
1 2 3 4 5 6 7 8 |
# ps -eaf | grep CLASSIC | grep -v grep oracle 4792 1 0 22:25 ? 00:00:00 ora_pmon_CLASSIC oracle 4794 1 0 22:25 ? 00:00:00 ora_psp0_CLASSIC oracle 4800 1 2 22:25 ? 00:00:01 ora_vktm_CLASSIC oracle 4804 1 1 22:25 ? 00:00:00 ora_u004_CLASSIC oracle 4810 1 7 22:25 ? 00:00:03 ora_u005_CLASSIC oracle 4818 1 0 22:25 ? 00:00:00 ora_dbw0_CLASSIC oracle 4884 1 0 23:25 ? 00:00:01 oracleCLASSIC (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq))) |
The remaining processes
So we have the Process Monitor (pmon), the Process Spawner (psp0), the Virtual Keeper of Time (vktm), the Database Writer (dbw0) and two new multithreaded processes (u004) and (u005). “U” can stand for User or Unified?
Where can I find the information on the other processes?
They still exist in the v$process view, thus leading to some confusion when talking about Oracle Processes with your sysadmins… The new EXECUTION_TYPE column show if the Oracle Process is executed as a thread or as an OS process, and the SPID let us know which process actually executes it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
PID SPID PNAME EXECUTION_ ----- --------- ----- ---------- 2 4792 PMON PROCESS 3 4794 PSP0 PROCESS 4 4800 VKTM PROCESS 5 4804 GEN0 THREAD 6 4804 SCMN THREAD 18 4804 LREG THREAD 19 4804 RBAL THREAD 20 4804 ASMB THREAD 11 4804 DBRM THREAD 14 4804 LGWR THREAD 15 4804 CKPT THREAD 16 4804 SMON THREAD 7 4804 MMAN THREAD 17 4810 RECO THREAD 12 4810 DIA0 THREAD 10 4810 SCMN THREAD 9 4810 DIAG THREAD 25 4810 N000 THREAD 50 4810 Q002 THREAD 49 4810 W004 THREAD 21 4810 MMON THREAD 22 4810 MMNL THREAD 23 4810 D000 THREAD 24 4810 S000 THREAD 51 4810 Q003 THREAD 26 4810 MARK THREAD 27 4810 W001 THREAD 28 4810 THREAD 29 4810 THREAD 30 4810 TMON THREAD 31 4810 TT00 THREAD 32 4810 SMCO THREAD 33 4810 FBDA THREAD 34 4810 W000 THREAD 35 4810 AQPC THREAD 36 4810 CJQ0 THREAD 37 4810 P000 THREAD 38 4810 P001 THREAD 39 4810 P002 THREAD 40 4810 P003 THREAD 41 4810 VKRM THREAD 42 4810 THREAD 43 4810 O000 THREAD 45 4810 W002 THREAD 46 4810 QM02 THREAD 47 4810 W003 THREAD 13 4818 DBW0 PROCESS 8 4884 PROCESS 1 NONE |
What about the User processes?
Well, I’ve spawned 200 user processes with sqlplus, and got 200 threads:
1 2 3 4 5 6 7 8 9 10 |
SQL> select BACKGROUND, EXECUTION_TYPE, count(*) 2> from v$process group by background, EXECUTION_TYPE; B EXECUTION_ COUNT(*) - ---------- ---------- 1 PROCESS 4 1 THREAD 34 PROCESS 1 NONE 1 THREAD 200 |
On the OS side, I’ve registered an additional process to distribute the load of the new user processes. Damn, I start to being confusional using the term “process” o_O
1 2 3 4 5 6 7 8 9 10 |
[oracle@luc12c01 ~]$ ps -eaf | grep CLASSIC | grep -v grep oracle 4792 1 0 22:25 ? 00:00:01 ora_pmon_CLASSIC oracle 4794 1 0 22:25 ? 00:00:01 ora_psp0_CLASSIC oracle 4800 1 2 22:25 ? 00:03:28 ora_vktm_CLASSIC oracle 4804 1 0 22:25 ? 00:00:08 ora_u004_CLASSIC oracle 4810 1 0 22:25 ? 00:01:09 ora_u005_CLASSIC oracle 4818 1 0 22:25 ? 00:00:00 ora_dbw0_CLASSIC oracle 4884 1 0 22:25 ? 00:00:01 oracleCLASSIC (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq))) oracle 8083 1 1 23:50 ? 00:00:03 ora_u010_CLASSIC |
On the session side however, all the user processes are DEDICATED.
1 2 3 4 5 |
SQL> select server, count(*) from v$session group by server; SERVER COUNT(*) --------- ---------- DEDICATED 232 |
A huge side effect
By using the multithreaded execution, the operating system authentication doesn’t work.
1 2 3 4 5 6 7 8 9 10 |
[oracle@luc12c01 ~]$ sqlplus / as sysdba SQL*Plus: Release 12.1.0.1.0 Production on Fri May 10 01:14:17 2013 Copyright (c) 1982, 2013, Oracle. All rights reserved. ERROR: ORA-01017: invalid username/password; logon denied Enter user-name: |
Unless Oracle will review it’s authentication mechanism in a future patchset, you’ll need to rely on the password file and use the password to connect to the instance as sysdba, even locally.
What about performance?
In theory, threads should be faster and with a lower footprint:
The main benefit of threads (as compared to multiple processes) is that the context switches are much cheaper than those required to change current processes. Sun reports that a fork() takes 30 times as long as an unbound thread creation and 5 times as long as a boundthread creation.
http://www.princeton.edu/~unix/Solaris/troubleshoot/process.html
and
In some operating systems running on some hardware, switching between threads belonging to the same process is much faster than switching to a thread from different process (because it requires more complicated process context switch).
http://en.wikipedia.org/wiki/Thread_switching_latency
In practice, I’ll do some tests and let you know! 🙂
What about the good old OS kill command to terminate processes?
Good question! Currently I have not found any references to an orakill command (that exists on Windows). Hope it will arrive soon!
Cheers
—
Ludo