README.parallel_features 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. Firebird engine parallel features in v5.
  2. ----------------------------------------
  3. Author: Vladyslav Khorsun <hvlad at users sourceforge net>
  4. The Firebird engine can now execute some tasks using multiple threads in
  5. parallel. Currently parallel execution is implemented for the sweep and the
  6. index creation tasks. Parallel execution is supported for both auto- and manual
  7. sweep.
  8. To handle same task by multiple threads engine runs additional worker threads
  9. and creates internal worker attachments. By default, parallel execution is not
  10. enabled. There are two ways to enable parallelism in user attachment:
  11. - set number of parallel workers in DPB using new tag isc_dpb_parallel_workers,
  12. - set default number of parallel workers using new setting ParallelWorkers in
  13. firebird.conf.
  14. For gfix utility there is new command-line switch -parallel that allows to
  15. set number of parallel workers for the "sweep" and "icu" tasks. For example:
  16. gfix -sweep -parallel 4 <database>
  17. will run sweep on given database and ask engine to use 4 workers. gfix uses DPB
  18. tag isc_dpb_parallel_workers when attaches to <database>, if switch -parallel
  19. is present.
  20. New firebird.conf setting ParallelWorkers set default number of parallel
  21. workers that can be used by any user attachment running parallelizable task.
  22. Default value is 1 and means no use of additional parallel workers. Value in
  23. DPB have higher priority than setting in firebird.conf.
  24. To control number of additional workers that can be created by the engine
  25. there are two new settings in firebird.conf:
  26. - ParallelWorkers - set default number of parallel workers that used by user
  27. attachments.
  28. Could be overriden by attachment using tag isc_dpb_parallel_workers in DPB.
  29. - MaxParallelWorkers - limit number of simultaneously used workers for the
  30. given database and Firebird process.
  31. Internal worker attachments are created and managed by the engine itself.
  32. Engine maintains per-database pools of worker attachments. Number of items in
  33. each of such pool is limited by value of MaxParallelWorkers setting. The pools
  34. are created by each Firebird process independently.
  35. In Super Server architecture worker attachments are implemented as light-
  36. weight system attachments, while in Classic and Super Classic its looks like
  37. usual user attachments. All worker attachments are embedded into creating
  38. server process. Thus in Classic architectures there is no additional server
  39. processes. Worker attachments are present in monitoring tables. Idle worker
  40. attachment is destroyed after 60 seconds of inactivity. Also, in Classic
  41. architectures worker attachments are destroyed immediately after last user
  42. connection detached from database.
  43. Examples:
  44. Set in firebird.conf ParallelWorkers = 4, MaxParallelWorkers = 8 and restart
  45. Firebird server.
  46. a) Connect to test database not using isc_dpb_parallel_workers in DPB and
  47. execute "CREATE INDEX ..." SQL statement. On commit the index will be actually
  48. created and engine will use 3 additional worker attachments. In total, 4
  49. attachments in 4 threads will work on index creation.
  50. b) Ensure auto-sweep is enabled for test database. When auto-sweep will run on
  51. that database, it also will use 3 additional workers (and run within 4 threads).
  52. c) more than one single task at time could be parallelized: make 2 attachments
  53. and execute "CREATE INDEX ..." in each of them (of course indices to be built
  54. should be different). Each index will be created using 4 attachments (1 user
  55. and 3 worker) and 4 threads.
  56. d) run gfix -sweep <database> - not specifying switch -parallel: sweep will run
  57. using 4 attachments in 4 threads.
  58. d) run gfix -sweep -parallel 2 <database>: sweep will run using 2 attachments in
  59. 2 threads. This shows that value in DPB tag isc_dpb_parallel_workers overrides
  60. value of setting ParallelWorkers.