Jemalloc usage with Virtuoso

jemalloc usage with Virtuoso

jemalloc is a general purpose malloc(3) implementation that emphasizes
fragmentation avoidance and scalable concurrency support.

Installation

RHEL 7.x

  • Install EPEL release RPM package
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  • Install jemalloc
yum install jemalloc
  • Check jemalloc lib is installed
ls -l /lib64/libjemalloc.so.1
  • locate jemalloc.sh script with command:
which jemalloc.sh
  • Virtuoso can be started using jemalloc with one of the following commands:
/usr/bin/jemalloc.sh ./virtuoso-iodbc-t -f 

or

LD_PRELOAD=/usr/lib64/libjemalloc.so.1 ./virtuoso-iodbc-t -f 

if libjemalloc is used from a supplied package via yum or apt-get, it is better to use the shell script provided as it points to the correct shared object.

  • Check Virtuoso is actually using the jemalloc memory allocators with the following command run from the Virtuoso database directory were the lock file (virtuoso.lck) exits:
. ./virtuoso.lck && cat /proc/$VIRT_PID/maps | grep jemalloc
  • Check Virtuoso can be started with jemalloc using command:
MALLOC_CONF=invalid:flag /usr/bin/jemalloc.sh ./virtuoso-iodbc-t -f
Should see `<jemalloc>: Invalid conf pair: invalid:flag` on startup

Example:

[root@ip-172-30-4-211 ec2-user]# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Loaded plugins: amazon-id, search-disabled-repos
epel-release-latest-7.noarch.rpm                         |  15 kB     00:00     
Examining /var/tmp/yum-root-2fC9Jp/epel-release-latest-7.noarch.rpm: epel-release-7-14.noarch
Marking /var/tmp/yum-root-2fC9Jp/epel-release-latest-7.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-14 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package          Arch       Version    Repository                         Size
================================================================================
Installing:
 epel-release     noarch     7-14       /epel-release-latest-7.noarch      25 k

Transaction Summary
================================================================================
Install  1 Package

Total size: 25 k
Installed size: 25 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-14.noarch                                     1/1 
  Verifying  : epel-release-7-14.noarch                                     1/1 

Installed:
  epel-release.noarch 0:7-14                                                    

Complete!
[root@ip-172-30-4-211 ec2-user]# yum install jemalloc
Loaded plugins: amazon-id, search-disabled-repos
epel/x86_64/metalink                                     |  28 kB     00:00     
http://mirror.es.its.nyu.edu/epel/7/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirror.es.its.nyu.edu/epel/7/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
Trying other mirror.
epel                                                     | 4.7 kB     00:00     
(1/3): epel/x86_64/group_gz                                |  99 kB   00:00     
(2/3): epel/x86_64/primary_db                              | 7.0 MB   00:00     
(3/3): epel/x86_64/updateinfo                              | 1.0 MB   00:00     
Resolving Dependencies
--> Running transaction check
---> Package jemalloc.x86_64 0:3.6.0-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch             Version               Repository      Size
================================================================================
Installing:
 jemalloc           x86_64           3.6.0-1.el7           epel           105 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 105 k
Installed size: 317 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/epel/packages/jemalloc-3.6.0-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for jemalloc-3.6.0-1.el7.x86_64.rpm is not installed
jemalloc-3.6.0-1.el7.x86_64.rpm                            | 105 kB   00:00     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-14.noarch (@/epel-release-latest-7.noarch)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : jemalloc-3.6.0-1.el7.x86_64                                  1/1 
  Verifying  : jemalloc-3.6.0-1.el7.x86_64                                  1/1 

Installed:
  jemalloc.x86_64 0:3.6.0-1.el7                                                 

Complete!
[root@ip-172-30-4-211 ec2-user]#
[root@ip-172-30-4-211 ec2-user]# ls -l /lib64/libjemalloc.so.1 
-rwxr-xr-x. 1 root root 212096 Mar 31  2014 /lib64/libjemalloc.so.1
[root@ip-172-30-4-211 ec2-user]# which jemalloc.sh
/bin/jemalloc.sh
[root@ip-172-30-4-211 ec2-user]#
[ec2-user@ip-172-30-4-211 virtuoso]$ MALLOC_CONF=invalid:flag /usr/bin/jemalloc.sh ./virtuoso-iodbc-t_07.20.3238_d321bd5bcd-Linux -f
<jemalloc>: Invalid conf pair: invalid:flag

		Fri Jun 09 2023
22:21:16 OpenLink Virtuoso Universal Server
22:21:16 Version 07.20.3238-pthreads for Linux as of Apr 26 2023 (d321bd5bcd)
22:21:16 uses OpenSSL 1.0.2u  20 Dec 2019
22:21:16 uses parts of PCRE, Html Tidy
22:21:16 Registered to OpenLink Software (INTERNAL USE ONLY)
22:21:16 Personal Edition license for 100 connections
22:21:16 Issued by Patrick van Kleef
22:21:16 This license will expire on Wed Mar 20 12:10:31 2024 GMT
22:21:16 Enabled Cluster Extension
22:21:16 Enabled Column Store Extension
22:21:16 Enabled Virtual Database Extension
22:21:16 Enabled Replication Extension
22:21:16 Database version 3126
22:21:16 SQL Optimizer enabled (max 1000 layouts)
22:21:17 Compiler unit is timed at 0.000243 msec
22:21:17 Roll forward started
22:21:17 Roll forward complete
22:21:18 PL LOG: Can't get list of vad packages in ../vad/
22:21:18 Checkpoint started
22:21:18 Checkpoint finished, log reused
22:21:18 HTTP/WebDAV server online at 8890
22:21:18 Server online at 1111 (pid 359)
22:21:19 ZeroConfig registration virtuoso (IP-172-30-0-77)

[root@ip-172-30-4-211 database]# /usr/bin/jemalloc.sh /home/ec2-user/virtuoso/virtuoso-iodbc-t_07.20.3238_d321bd5bcd-Linux -f

                Tue Jun 13 2023
12:54:12 OpenLink Virtuoso Universal Server
12:54:12 Version 07.20.3238-pthreads for Linux as of Apr 26 2023 (d321bd5bcd)
12:54:12 uses OpenSSL 1.0.2u  20 Dec 2019
12:54:12 uses parts of PCRE, Html Tidy
12:54:12 Registered to OpenLink Software (INTERNAL USE ONLY)
12:54:12 Personal Edition license for 100 connections
12:54:12 Issued by Patrick van Kleef
12:54:12 This license will expire on Wed Mar 20 12:10:31 2024 GMT
12:54:12 Enabled Cluster Extension
12:54:12 Enabled Column Store Extension
12:54:12 Enabled Virtual Database Extension
12:54:12 Enabled Replication Extension
12:54:12 Database version 3126
12:54:12 SQL Optimizer enabled (max 1000 layouts)
12:54:13 Compiler unit is timed at 0.000240 msec
12:54:16 Roll forward started
12:54:16 Roll forward complete
12:54:17 Checkpoint started
12:54:17 Checkpoint finished, log reused
12:54:17 HTTP/WebDAV server online at 8890
12:54:17 Server online at 1111 (pid 27663)
12:54:18 ZeroConfig registration virtuoso (IP-172-30-4-211)

[root@ip-172-30-4-211 database]# . ./virtuoso.lck && cat /proc/$VIRT_PID/maps | grep jemalloc
7f5ad81b0000-7f5ad81e1000 r-xp 00000000 103:02 4879                      /usr/lib64/libjemalloc.so.1
7f5ad81e1000-7f5ad83e0000 ---p 00031000 103:02 4879                      /usr/lib64/libjemalloc.so.1
7f5ad83e0000-7f5ad83e2000 r-xp 00030000 103:02 4879                      /usr/lib64/libjemalloc.so.1
7f5ad83e2000-7f5ad83e3000 rwxp 00032000 103:02 4879                      /usr/lib64/libjemalloc.so.1
[root@ip-172-30-4-211 database]# 

Related