[ZBXNEXT-4577] Convert configuration cache mutexes to read/write locks Created: 2018 Jan 05  Updated: 2024 Apr 10  Resolved: 2018 Jun 12

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Proxy (P), Server (S)
Affects Version/s: None
Fix Version/s: 4.0.0alpha8, 4.0 (plan)

Type: New Feature Request Priority: Trivial
Reporter: Andris Zeila Assignee: Vladislavs Sokurenko
Resolution: Fixed Votes: 0
Labels: performance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File pthread_lock.diff    
Issue Links:
Causes
causes ZBX-15200 Number of items periodically spikes Closed
causes ZBX-14751 Cross-compiling not working on OpenWR... Closed
Epic Link: DEV-677
Team: Team A
Sprint: Sprint 25, Sprint 26, Sprint 27, Sprint 28, Sprint 29, Sprint 30, Sprint 31, Sprint 32, Sprint 33, Sprint 34, Sprint 35, Sprint 36
Story Points: 5

 Description   

Zabbix does a lot of read only requests to configuration cache. By replacing configuration cache mutex with read/write lock we could parallelize such requests.

Preliminary tests showed around 60% data processing maximum throughput increase when configuration cache mutex was replaced with pthread based read/write lock.

We need to re-evaluate the implementation complexity and test results with on the latest trunk version and decide if we move forward with it.

There are few thoughts to consider:

  • dependency on pthread library
  • while pthread supports shared memory based read/write locks it might not be supported on all platforms. In this case we should fall back to mutexes.
  • replacing semaphore based mutexes with pthread mutexes using futexes would give small performance boost even without read/write locks.


 Comments   
Comment by Andris Zeila [ 2018 Jan 08 ]

Some quick performance data based on latest trunk:
Trigger processing enabled, history backend, event processing disabled. 4 proxies sending 2m values each (8m total).

Description Vps
semaphore based mutexes (default) 105k
pthread based mutexes 122k
configuration cache lock replaced with read-write lock and DCconfig_get_items_by_itemids() lock is replaced with read lock 152k
Comment by Andris Zeila [ 2018 Jan 08 ]

POC patch is attached. However one problem with read-write locks is handling of process exits. It might actually be impossible to add read-write locks while Zabbix processes simply exists in the case of fatal or terminate signal (most probably pthread_rwlock_unlock() is not safe to use in singal handler, but then again we already are doing things that are not supposed to be done in signal handler).

Comment by Vladislavs Sokurenko [ 2018 Jun 08 ]

Available in:

  • pre-4.0.0alpha8 (trunk) r81685
Comment by Vladislavs Sokurenko [ 2018 Jun 08 ]

(6) Upgrade notes:
Additional dependencies

  • libpthread - the POSIX Threads library is now mandatory when compiling Zabbix server and Zabbix proxy. It is required for process shared mutexes and read-write locks. If mutexes are available, but cannot be process shared then Zabbix will fallback to using semaphores as before the upgrade.

Installation requirements:
https://www.zabbix.com/documentation/4.0/manual/installation/requirements
Required for mutex and read-write locks support.

martins-v Updated documentation:

RESOLVED

vso thanks, lets also add zlib as mandatory to upgrade notes and requirements, because it is mandatory.
zlib - the compression library is now mandatory when compiling Zabbix server and Zabbix proxy.

martins-v RESOLVED

vso CLOSED

Comment by Vladislavs Sokurenko [ 2018 Jun 08 ]

(7) What's new:
Improved performance of Zabbix server by replacing semaphores to pthread mutexes and read-write locks.

martins-v RESOLVED in what' s new.

vso CLOSED

Generated at Fri Apr 26 02:07:23 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.