Dynimize Version 2 Beta is for testing purposes only and is not recommended for production use.
dyn·imize
verb
to dynamically optimize the in-memory machine
code of a running process.
modern English: from a combination of
dynamic and optimize.
1. Overview
Dynimize is a user mode program that quickly optimizes the in-memory machine
code of target programs at run-time,
thereby improving the performance of many compute intensive workloads. It does this by applying
profile guided compiler optimizations to live, in-memory executable code, by taking in live machine code, live profiling information,
live process data, and the system environment as input to an optimizing compiler, and then outputting
more optimal machine code back into the live target process or in-memory Linux Kernel executable code.
Dynimize does this without having to
recompile, reconfigure or restart target programs, making it a run-time binary optimizer.
It does not modify a target program's object code or data on disk.
By targeting a workload's in-memory executable, shared libraries and kernel machine code,
it can seamlessly and instantly perform full stack profile guided optimizations across the entire system,
with minimal effort, utilizing the most relevant live profiling information available.
This makes it superior to traditional profile guided compiler optimization which is challenging to apply
across entire systems, suffers from stale profiling data and lack of per-process specialization.
Dynimize typically runs as a background system process.
2. Installation & Quick Start
To install Dynimize, run the following commands in a Linux terminal.
wget https://dynimize.com/dev/install -O install
wget https://dynimizecloud.com/dev/install.sha256 -O install.sha256
sha256sum -c install.sha256; if [ $? -eq 0 ]; then sudo bash ./install; fi
Use your access token to start a subscription license for your host.
sudo dyni -license=start -token=<access token>
To optimize the Linux Kernel or any CPU intensive process who's exe is listed in the [exeList] section of /etc/dyni.conf, run:
sudo dyni -start
The command dyni -status will show target processes or the Kernel progressing from the "profiling",
to "dynimizing", and then "dynimized" states. A process has been fully optimized once
in the "dynimized" state:
$ sudo dyni -status
Dynimize is running
mysqld, pid: 8375, dynimizing
$ sudo dyni -status
Dynimize is running
mysqld, pid: 8375, dynimized
Dynimize can be shutdown with the following command:
$ sudo dyni -stop
If Dynimize is shutdown, all dynimized processes or the Kernel will remain dynimized.
To "undynimize" all dynimized processes or the Kernel, run:
sudo dyni -undo
or alternatively restart the dynimized process or reboot your system to undynimize the Kernel.
To cancel a subscription license for a given host, run the following command on that host:
sudo dyni -license=stop -token=<access token>
To uninstall Dynimize, run:
sudo /opt/dynimize/UNINSTALL.sh
3. System Requirements
3.1 OS requirements
x86-64 Linux Kernel version 2.6.32 or later is required.
3.2 Memory requirements
On average, approximately 4GB of virtual memory (swap + RAM) per target process being
dynimized in parallel is required. This is because Dynimize requires 4 GB per target process in the
"dynimizing" phase, releasing this memory after that. Note that this is the average and
varies by the target process executable.
Dynimize targets multi-process programs with the same memory requirements as single process programs. For example,
NGINX and most other web servers use multiple worker processes with a common parent process. Here Dynimize
does not need to target each process individually.
3.3 VM specific requirements
There are no specific requirements for running inside KVM,
Xen or VMware virtual machines. Therefore Dynimize can be run in most cloud environments.
3.4 Container specific requirements
Dynimize can target containerized processes, such as processes running inside Docker, by
running Dynimize outside of the container directly on the host OS.
Dynimize cannot itself be launched from inside a container.
4. Command Line Options
Synopsys
dyni [options]
General Options
-help
Print the help message.
-start
Start Dynimize as a background daemon process.
-stop
Stop any invocation of Dynimize that is currently running.
-status
Print the state or phase of Dynimize and its optimized processes or the Linux Kernel.
States will be listed in the following format:
target program executable name, pid, state.
-undo
Stop any other invocation of Dynimize that is already running, remove all optimizations already performed by Dynimize on target processes or the Linux Kernel, and then exit.
Dynimize can then be started at a later time and used to dynimize the "undynimized" processes or the Kernel again under different workload conditions.
-redo
The same operation as -undo, except that this invocation of Dynimize will continue running,
and may now proceed to automatically optimize the same processes or Linux Kernel again, along with other programs.
-reoptimize
Allow Dynimize to automatically redynimize a process or the Kernel if it detects that its workload has drastically changed. This option
is disabled by default. Reoptimization can only be performed if the previous optimization was done by the same Dynimize process without Dynimize being restarted.
See the -pid=<PID> option on how -reoptimize affects it.
-version
Print the Dynimize version.
-about
Display product information.
-log=<pathname>
Specify a full pathname for the output log.
-exe=<filename>
The current Dynimize command will only apply to processes run from this executable filename,
or the Linux Kernel if using vmlinux as the filename. Do not specify the full pathname.
-pid=<PID>
The current Dynimize command will only apply to the process specified by this PID. This will cause Dynimize
to exit after dynimizing a process unless used in conjunction with
-reoptimize
-nPrograms=<n>
The maximum number of programs Dynimize will optimize at the same time. The default is 1, meaning that Dynimize
will target one program at a time before optimizing the next program in a workload. A single process such as mysqld,
an entire process group such as the parent and worker processes of NGINX, or the Linux Kernel each count as
one program. Increasing nPrograms requires more virtual memory (RAM + swap). See memory requirements.
-delay=<seconds>
The minimum amount of time since process creation before a process can be targeted by Dynimize. The default is 60.
-window=<seconds>
The total number of seconds Dynimize will spend targeting each program. This includes both the time spent in profiling and optimization. Lengthening this time
will only increase the amount of time Dynimize will use to collect profiling information, which may help improve optimization quality. The default is 90.
-cpu-usage=<percentage>
The minimum percentage CPU usage of a specific program before Dynimize will target it.
For user mode processes, this measurement is equivalent to that of the Linux top command using a delay window of 10 seconds.
For the Linux Kernel, this measurement is equivalent to the sy column (system time percentage)
reported by the Linux vmstat command using a window of 10 seconds,
multiplied by the number of logical CPU cores. The default is 10.
-update
Download and apply any Dynimize updates.
-checkForUpdates
Report if there are any Dynimize updates to apply.
Licensing Options
-token=<access token>
Specify your account access token for use with any licensing actions.
-license=start
Start a subscription license for the current host.
-license=stop
Stop the subscription license for the current host.
-license=fixed
Create a permanent license for the current host.
The account used will be billed for this license at the moment this command is issued,
rather than at the end of the month like subscription licenses.
-license=pull
Download a copy of the license key into /opt/dynimize/license-key
-promo=<promo code>
Specify a promotional code when starting a license.
-info=this
Display the local license information of the current host system.
-info=all
Display the license information of every host system associated with this account.
-name=<license name>
Specify a new name for the license associated with this host. This name will be recorded in the licensing system so
that it is easier to identify each license for each host in the console or on billing invoices.
If not specified, licenses are given default names following the pattern dyni<n>.
-offline
Used with other licensing commands to tell Dynimize not to contact the licensing server,
and instead generate a license command file /opt/dynimize/license-command, which can then be
uploaded here
to generate the resulting license key.
-licenseServer
Run Dynimize as a license server. Requires an internet connection.
See Licensing isolated hosts.
-licensePort=<port>
Include this option on the client and server side if you are running your own Dynimize license server, to specify the port number used by your Dynimize license server.
If not specified then the default port used is 443.
See Licensing isolated hosts.
-licenseHost=<host>
Include this option on the client side if you are running your own Dynimize license server to specify the IP address or hostname of your Dynimize license server.
If not specified then the default license host used is license.dynimize.com.
See Licensing isolated hosts.
-skipPrompt
Skip any prompts verifying the licensing actions to be performed.
*Note that the output log will list all options enabled at Dynimize startup and can be used to verify which options are in effect.
5. Configuration File
On startup, Dynimize is configured based on the settings in /etc/dyni.conf.
The following is a description of these settings. Many of these settings can be
overridden by command line options. Note that starting a line with the # character
will cause that line to be skipped.
All options follow the line in the dyni.conf file containing the string
[options]. If any of those following options are missing,
their default settings are used. Note that the < >
characters should not actually be placed in the log file:
Option
Description
reoptimize
Same as the command line option -reoptimize
log=<pathname>
Same as the command line option -log
maxLogSize=<size>
The max total size of both log files at <path> and <path>.old combined.
Size is in bytes unless specified by MB, M, GB, G, KB, K. The defaults is 1 MB.
initdService
If present, Dynimize will be enabled as service in /etc/init.d and launched on system startup.
autoUpdate
If present, Dynimize will automatically check for Dynimize updates and apply them.
token=<access token>
Same as the command line option ‑token=<access token>
autoRenew
If expired, automatically update the license key in /opt/dynimize/license-key.
licenseServer
Same as the command line option ‑licenseServer
licensePort=<port>
Same as the command line option ‑licensePort=<port>
licenseHost=<host>
Same as the command line option ‑licenseHost=<host>
skipPrompt
Same as the command line option ‑skipPrompt
The lines following [exeList] in dyni.conf
denote the list of allowed optimization targets. These are the names of
the executables that are used to launch the processes or process groups that can be targeted by
Dynimize, one name per line. So for example, the NGINX server process group would
be denoted as nginx. vmlinux is always used to denote the Linux Kernel and associated kernel modules or device drivers.
A process or process group must have been started by an executable on
this list to be dynimized.
Note that if a symbolic or hard link is used to call
an executable, the real executable file name must be specified on the
[exeList].
Beside each target name under the [exeList], one can optionally
specify any of the following:
-window=<seconds>-delay=<seconds>-cpu-usage=<percentage>.
These have the same effect as their associated command line options, except they are only applied to each target that matches the target name. These options
override their equivalents on the command line.
The above example inside dyni.conf will apply the default window, delay and cpu-usage options to mysqld processes,
unless otherwise specified on the command line. For nginx process groups,
it will use a window and delay of 60 and 120 seconds respectively, and a cpu-usage threshold of 30%.
It will use a window of 60 seconds and the default delay and cpu-usage thresholds when targeting the Linux Kernel and other kernel modules along with it.
The lines following [users] list the possible user
names of the owners of processes that can be targeted by Dynimize, one name per line.
If present, a process must match both the [exeList] and
[users] list in order to be dynimized.
By default, no user name is requirement.
The output log specified by -log=<pathname> records all errors and Dynimize status updates
along with their timestamps. It will also list all options enabled at Dynimize startup which can
be used to verify the options that are in effect. On installation the log path is set to /var/log/dyni.log
in /etc/dyni.conf. Once the log file reaches half the maxLogSize, it is moved to the
same path name appended with .old, and a new log is started as the original log file name.
Logging is disabled if the log option is removed from dyni.conf.
6. Dynimize States
A process, process group or Linux Kernel that is being targeted by Dynimize for optimization may be in one of the following states,
as indicated by the dyni -status command. For example:
$ dyni -status
Dynimize is running
mysqld, pid: 8375, dynimizing
The follow are the 6 possible states:
waiting
Dynimize is waiting for a newly created target process to age beyond the delay setting before being targeted.
profiling
This is the first stage of optimization where Dynimize begins collecting high level
profiling statistics for a process.
dynimizing
This is the second stage of optimization where Dynimize instruments the target process,
collects detailed profiling statistics and continuously commits new optimized machine
code regions back to the target process. This stage creates a large amount of CPU and
memory overhead which can temporarily degrade the performance of the target process.
See Dynimize Overheads.
dynimized
This final state indicates that the process has been fully optimized. There is no
longer any overhead from Dynimize and the full performance benefit is now experienced.
undynimized
The process had been optimized by Dynimize and the optimizations were later
undone by the dyni -undo command.
The target process can now be retargeted again
for optimization by restarting Dynimize. Note that each dynimized to undynimized
transition leaves behind a Dynimize machine code cache in the target process, and
so one may wish to restart the target process after many of these transitions.
partly dynimized
This state indicates that the dynimizing phase was interrupted. This can occur
when Dynimize is either intentionally stopped by the user during the dynimizing
phase, or because Dynimize encountered an error condition during the dynimizing
phase and decided to stop optimizing the process. If it is the latter then it is
recommended that you contact Dynimize support to resolve the issue.
7. Dynimize Usage Examples
7.1 General Examples
Below are examples of commands to perform specific tasks with Dynimize.
Start Dynimize as a background daemon process, dynimize any processes or the Linux Kernel encountered on the [exeList] in /etc/dyni.conf
that meet the threshold requirements, and then continue to run and eventually target any new processes that meet these requirements as well:
$ sudo dyni -start
Dynimize a process with pid 9618 and exit once dynimized:
$ sudo dyni -start -pid=9618
Launch Dynimize as a foreground process, only dynimizing process 9618
and then exit. Note that the -start option is omitted here so that
Dynimize is not launched in the background, which can be useful for
running Dynimize from shell scripts that wait for Dynimize to finish before performing the next task:
$ sudo dyni -pid=9618
Launch Dynimize, only dynimizing process 9618, however
in this case Dynimize will continue to run after the process has entered
the "dynimized" state so that it can reoptimize the process if its workload
drastically changes:
$ sudo dyni -start -pid=9618 -reoptimize
The following example will stop any other running instances of Dynimize, remove any optimizations performed by previous Dynimize
invocations, and then continue running. Dynimize may now proceed to optimize these processes or the Linux Kernel again, along
with any anything else that meets its requirements. This could be useful if you think that your workload has drastically changed and want
it reoptimized using current profiling information:
$ sudo dyni -start -redo
Only dynimize processes run from the myprog executable:
$ sudo dyni -start -exe=myprog
Dynimize processes using a shorter time window of 60 seconds:
$ sudo dyni -start -window=60
Start Dynimize with a new log path directory /tmp/log:
$ sudo dyni -start -log=/tmp/log
7.2 Process Groups
Dynimize can internally group a parent and its child processes into a single group and
target that group of processes in a similar manner with similar overheads as a single process. These processes
will also share the same Dynimize code cache.
For Dynimize to target children processes with their parent as one group, they must all be forked from the same parent
process. For example, NGINX or Apache HTTP Server both use a parent process that forks worker
processes. The -pid= option can also be used with the parent pid to target the
entire process group. Node.js processes on the other hand are not forked from a single parent process
and each node process must be optimized separately.
The status of process groups can be tracked in a similar manner as single processes. For example:
$ sudo dyni -status
Dynimize is running
nginx, parent pid 11468 and its children, dynimized
7.3 The Linux Kernel and Drivers
To target the Linux Kernel and any kernel modules or device drivers consuming large amounts of CPU cycles,
add vmlinux to the [exeList] in /etc/dyni.conf before
starting Dynimize.
The status of this optimization can be tracked using the following command:
$ sudo dyni -status
Dynimize is running
vmlinux, dynimized
Alternatively, the following command will run Dynimize as a foreground process and only target
the Linux Kernel and associated kernel modules:
$ sudo dyni -exe=vmlinux
Dynimize will then exit once the optimization completes.
8. Licensing & Billing
One of the primary purposes of Dynimize is to reduce the financial costs of CPU resources consumed by target workloads for a given level of performance.
Therefore to help users reduce billing costs in the cloud, elastic, on-demand subscriptions can be generated on the command line to license Dynimize
with per second billing granularity, thereby matching the billing granularity of CPU resources in many public clouds and allowing for easy licensing automation.
Use your access token to start a subscription license for your host.
sudo dyni -license=start -token=<access token>
To cancel a host's subscription license from the command line,
Dynimize must be shut down and there cannot be any dynimized programs running on that host.
To stop running instances of Dynimize and "undynimize" all dynimized programs, run
sudo dyni -undo
or you can simply stop Dynimize and restart any dynimized processes to "naturally" undynimize them. Rebooting the system does the same to the Linux Kernel. For example, the following commands can restart the mysqld process for MySQL after stopping Dynimize.
sudo dyni -stop
service mysql restart
To then cancel a subscription license for a given host, run the following command on that host.
sudo dyni -license=stop -token=<access token>
By default, time is accounted for using per second granularity, but only when the license is later correctly cancelled
from the command line. See Billing time granularity for exceptions.
Time accounting for any licenses used begins 7 days after your account was activated.
This initial wait period is your free trial, after which each license is then priced at $1 per
CPU core per 30 days, prorated per second of usage when cancelled
from the command line on the licensed host.
For example, if you only have 1 hour and 48 minutes of use over the course of a month on a
4 core host, you will only be invoiced $0.01. Your account will be billed at the end of each
month for subscription license time used during that month.
8.1 Fixed licenses
A fixed license is only billed once per host, priced according to the number of CPU cores on the system. It will support a single host indefinitely,
and is not transferable to a different host.
You can start a fixed license with the following command.
sudo dyni -license=fixed -token=<access token>
A fixed license can also be created on a host anytime after a subscription license was started.
In that case, the subscription license is implicitly stopped and no subscription time will be
billed past that point for that host. A fixed license is then created at the standard price.
8.2 Viewing licenses
To view all the active licenses associated with your account, run
sudo dyni -info=all -token=<access token>
To only view the license on the current host, run
sudo dyni -info=this -token=<access token>
8.3 Storing your access token
Your access token in the option -token=<access token> acts as the credentials for accessing
the Dynimize licensing system. To prevent it from being stored in your bash history, you may want to
change your access token and then use that new value in the
configuration file /etc/dyni.conf by placing it in the token=<access token> field.
You can then omit -token=<access token> from the command line. Note that any use of
-token=<access token> on the command line will automatically update the value in /etc/dyni.conf.
8.4 License key expiration
Licensing commands will store the current license key in /opt/dynimize/license-key.
While fixed license keys never expire, subscription license keys will report that Dynimize
is expired 30 days after license key creation, and prevent Dynimize from starting or performing further
optimizations (if already running) after 60 days from license key creation. If the flag autoRenew is set in /etc/dyni.conf
and the server has internet access or network access to a
self hosted license server,
Dynimize will automatically update the license key every 30 days.
This provides an additional 30 day window to address any issues encountered renewing the license key.
8.5 Anonymous bookkeeping
The licensing system creates a relatively unique identifier for each licensed host.
This identifier combines system values such as the MAC address and the number of CPU cores.
This information is combined into a 32-bit identifier that contains a fraction of
the total bits of the original system values, in such a way that those original values cannot be extracted
from this unique identifier. This allows Dynimize to associate a license with a specific host without
transmitting any of the real system values of that host, maintaining a degree of anonymity and privacy.
This identifier is also used to allow the licensing system to ignore redundant licensing commands.
For example, starting a subscription license on a host that already has a fixed or subscription
license will have no effect.
Note that all communication between a host and a license server is encrypted through TLS.
This communication only happens when a licensing command is issued by the user, or a subscription license
key is automatically updated once expired, which is once every 30 days only if autoRenew is enabled and a
subscription license is in use. Dynimize does not require a network connection to the licensing system
outside of those times.
8.6 Billing time granularity
Dynimize time accounting is performed with per second billing granularity only when a subscription
license is stopped from the command line. However, if /opt/dynimize/dyni-node is modified on the host at
any point after license key creation, per second billing granularity will not be possible for the
next licensing command and the host may continue to accrue billable time for an additional 30 days
after the subscription license is stopped from the command line. Additionally, if the MAC address
or number of CPU cores on the licensed host has changed, Dynimize licensing commands will fail to
recognize the host system and the subscription license will need to be stopped from the web portal,
where per second billing granularity cannot be used. In this case, Dynimize will continue to accrue
billable time for an additional 30 days after the subscription license is stopped from the web portal.
IMPORTANT: For the above reasons, it is important to stop a
subscription license from the command line of any cloud instance before terminating that instance.
This is because any new instance will have a different MAC address, requiring the
original instance license to be stopped from the web portal and thereby forfeiting per second
billing granularity.
8.7 Licensing isolated hosts
Some security policies do not allow specific servers access to the internet.
This can be classified as either fully or partially isolated.
Fully isolated hosts cannot connect to the internet or any other server that has internet access.
Partially isolated hosts do not have internet access but are allowed to reach
other servers that do have internet access.
8.7.1 Licensing fully isolated hosts
To license fully isolated offline servers without an internet connection,
you can perform any licensing command using the -offline flag. For example:
The above command will generate the following file on your server: /opt/dynimize/license-command
When that license-command file is uploaded
here,
a licensing action will be performed that is equivalent to
running the above command without the -offline
flag on the same server but with an internet connection.
Once uploaded, you will be prompted to save the resulting license-key file which must be moved to your server
at the location /opt/dynimize/license-key
8.7.2 Licensing partially isolated hosts
Dynimize can be run for free as a licensing
server on your own system that does have internet access and is reachable by the isolated servers
you wish to create licenses for. This will allow isolated hosts to issue regular licensing commands and
automatically renew subscription licenses through your own self-hosted Dynimize licensing server.
To run Dynimize as a licensing server background process, run the following command on the host with internet access.
sudo dyni -start -licenseServer
Alternatively, you can set licenseServer in /etc/dyni.conf
You can then run any licensing command on
the isolated servers that can reach the above licensing server host using the
-licenseHost=<IP|host> flag. For example, to start a subscription
license on an internet isolated host assuming the above self-hosted license server has an IP address of 10.30.1.72,
run the following command.
You can also set licenseHost=<IP|host>
in /etc/dyni.conf on the isolated servers.
Note that the server's domain name can be used in place of the IP address in the above example.
By default, all licensing commands use port 443. To change this in the above example, on both systems use the command line option
-licensePort=<port number> or set
licensePort=<port number> in /etc/dyni.conf.
Workload Requirements
To obtain benefit from the current version of Dynimize,
all of the following workload conditions must be met:
Long running processes
The processes being optimized have long lifetimes, and their workloads are long running
in order to amortize the warmup time associated with optimization.
Linux x86-64
Optimized processes or Linux Kernels must be 64-bit, derived from x86-64 executables and shared
libraries, which must comply with the x86-64 ABI and ELF-64 formats.
Dynamically Linked
Target processes must be dynamically linked to their shared libraries. Statically
linked processes are not yet supported. Most Linux programs are dynamically linked.
No self modifying code
Any self modifying code inside target processes will be excluded from optimization.
This includes Just-In-Time compiler code caches found in Java virtual machines.
No GC-mapped code
Any machine code that is tracked by garbage collector maps (GC maps) cannot be safely targeted. This
means Rust and Go applications cannot be targeted by Dynimize.
Front-end CPU stalls
The workload wastes a lot of time in CPU instruction cache misses, instruction TLB misses,
and to a lesser extent branch mispredictions.
Because of these requirements, Dynimize uses a configurable allowlist approach when determining
if programs are allowed to be optimized. The processes currently supported are as follows, named by the
executable they are launched from:
• nginx (NGINX) • httpd or apache2 (Apache HTTP Server) • litespeed (LiteSpeed Web Server) • mongod (MongoDB Server) • mysqld (MySQL Server, MariaDB Server or Percona Server for MySQL) • mariadbd (MariaDB Server) • postgres (PostgreSQL Server) • db2sysc (IBM Db2 Server) • redis or redis-check-rdb (Redis) • memcached (Memcached) • node (Node.js) • php-fpm (PHP processor) • python, python2, or python3 (Python runtime) • ruby (Ruby runtime) • java (Java Virtual Machine)
Note that when targeting processes launched from one of the above exes, both the in-memory executable and shared library code of these
processes are optimized.
In addition, the Linux Kernel and other kernel modules are also supported optimization targets.
Other programs are not currently supported, and while many can be used with Dynimize, they should be very
thoroughly tested with Dynimize before being deployed in a
production environment. If you find Dynimize useful for other workloads
outside of the ones listed above, we'd love to hear about it. Let us know at info@dynimize.com.
Future versions of Dynimize may eliminate many of these workload requirements,
broadening the variety of applicable scenarios as well as further increasing the performance
delivered in previously beneficial cases.
10. Dynimizing the Linux Kernel
The Linux Kernel and other CPU intensive kernel modules can be dynimized by
including vmlinux under [exeList] in the /etc/dyni.conf file.
10.1 Signing the Dynimize Kernel Module
The following section is only relevant if Secure Boot is enabled in the system BIOS settings.
When Dynimize targets the Linux Kernel, it will utilize
the Dynimize kernel module /opt/dynimize/dyni0000.ko as a code cache for the
optimized machine code Dynimize generates. Subsequent calls to dyni -undo
followed by dynimizing vmlinux again will load additional copies of dyni0000.ko,
renamed anything from dyni0001.koto dyni<nnnn>.ko,
corresponding to the number of times vmlinux is re-dynimized. If Secure Boot is enabled, these kernel modules
must all be generated and signed before use. This can be done with any of the
following approaches.
1. If Secure Boot is enabled when Dynimize is installed, the installer will
detect this and then ask if the secure boot Dynimize installation step should
be performed. This step will install any missing signing tools, generate and
enroll a new signing key, generate 10 copies of dyni0000.ko (dyni0000.ko to
dyni0009.ko), each signed with the new signing key and then archived as .tar.gz
files in /opt/dynimize/mods/. This entire Secure Boot step for Dynimize can
also be invoked any time by calling:
/opt/dynimize/mok_scripts/MOK.sh
This script will leave behind the enrolled signing key at
/opt/dynimize/.sign/MOK.priv. It is recommended that this
key be removed from the host and stored securely for future use. This script can be called in the future
if a new signing key needs to be generated and enrolled.
2. If the signing tools are already installed and there is already a signing
key at /opt/dynimize/.sign/MOK.priv, invoking
/opt/dynimize/mok_scripts/MOK_SIGN_ALL.sh
will generate the signed dyni<nnnn>.ko.tar.gz files in /opt/dynimize/mods/ using that key. If using a
different signing key, place it at /opt/dynimize/.sign/MOK.priv before invoking
this script. Note that this signing method is attempted automatically by dyni if the Linux Kernel refuses to
load dyni<nnnn>.ko, such as after the Linux Kernel is updated and the Dynimize Kernel modules have not yet been
re-signed.
3. To specify a custom signing command to be used as a template to sign all
the generated dyni<nnnn>.ko.tar.gz files, call
This command generates all the versions of
dyni<nnnn>.ko needed, signed using that custom signing command as a template
with the appropriate paths to each kernel module automatically substituted
for the one in the example command.
Note that these kernel modules must be re-signed each time the Linux
Kernel is updated if Secure Boot is enabled.
10.2 Dynimize & Livepatching The Linux Kernel
A dynimized Linux Kernel must be undynimized before a livepatching service is used to successfully apply updates.
Some examples of livepatching services are KernelCare, Canonical Livepatch, kpatch, ksplice and kGraft.
For example:
$ sudo dyni -status
Dynimize is running
vmlinux, dynimized
Because the Linux kernel is dynimized, it should be undynimized before applying the livepatch updates:
$ sudo dyni -undo
vmlinux is now undynimized
Now the livepatch updates can be applied, after which the updated Linux Kernel can be re-dynimized again:
$ commands to apply livepatch updates...
$ sudo dyni -start
11. Miscellaneous Notes
Sequential CPU speedup
Dynimize usage may result in the speedup of the target application and/or a
reduction in CPU resources consumed by that application. Speedup typically occurs
when sequential CPU performance is a bottleneck. When sequential CPU performance is
not a bottleneck, a reduction in CPU resources used by the optimized process is
experienced which can be observed by an increase in CPU idling.
Dynimize can respond to changes in workload
Once all target applications
are sufficiently optimized, Dynimize will enter idle mode.
If Dynimize was originally started with the reoptimize option,
it may then respond at a later time to a significant change in the
CPU workload of an already dynimized process by redynimizing it.
It will also dynimize any new CPU intensive undynimized process that was started from
an executable on the exeList.
Zero downtime
Target applications do NOT need to be restarted in order to be dynimized.
Once Dynimize is started it will automatically detect and begin dynimizing them immediately.
One Dynimize instance per OS host
Dynimize is not designed to be run as multiple instances on the same host OS.
If a second instance is launched in parallel, it will detect an already running
instance of Dynimize and exit.
Single threaded
Dynimize is currently single threaded and will only consume the resources of at
most one CPU core, even when optimizing multiple target processes in parallel.
No handoffs between Dynimize instances
A new Dynimize process will not dynimize a target process that has already been
dynimized by a previous Dynimize process, unless that target process has been undynimized
using the -undo or -redo flags.
No stale shared libraries
Dynimize will not target a running process if its shared libraries on disk have changed
after they were loaded into that running process. dyni -status will report "stale shared libraries"
for that target process and that program must be restarted before Dynimize can target it.
Dynimized processes stay dynimized
Once Dynimize is shut down, any dynimized processes will continue to run in the dynimized state.
However if a dynimized process is then restarted, any previous optimizations will have disappeared and
Dynimize will need to be started again to target the application.
12. Example Life Cycle of Dynimize and a Target Application
Dynimize is started as a background process and begins in idle mode, monitoring system processes.
This state consumes virtually no CPU resources:
$ dyni -start
A new target application process such as mysqld is then launched and becomes
CPU intensive, or an already running target application becomes CPU intensive.
Dynimize detects this and begins to dynimize the target application. Profiling data is gathered,
and incremental, atomic updates to the target application's machine code are made.
This takes about 90 seconds by default,
unless the -window=<seconds> option changes that setting:
$ dyni -status
Dynimize is running
mysqld, pid: 8375, dynimizing
Dynimize has completed its current batch of optimization work and enters idle mode:
$ dyni -status
Dynimize is running
mysqld, pid: 8375, dynimized
A new target application is launched and Dynimize returns to step 3. Additionally, if the workload of the previously dynimized
process has drastically changed and Dynimize was started with the reoptimize option, it also returns to step 3.
Although Dynimize is single threaded, it can apply these steps to multiple
target processes at the same time.
13. Dynimize Overheads
Dynimize introduces both CPU and memory overheads when ramping up performance during the
dynimizing phase, with plans to reduce these overheads in future releases. The following section addresses these overheads.
13.1 Dynimize CPU overhead
CPU overhead exists during the warm-up phase when a process is being dynimized.
There are two components of CPU overhead during this phase.
The most obvious is the amount of CPU cycles that the dyni process is actually consuming.
While at first spiking to 100% utilization of a single core for less than a second,
dyni typically fluctuates at around 20% CPU utilization (of a single core) for the remainder
of the dynimizing phase. Because it is quite rare to be fully utilizing all hardware threads
on a large multi-core system, the single threaded dyni process is unlikely to result
in significant overheads in this regards. The second CPU performance overhead that takes
place is that of application profiling, and although brief, it typically makes a larger impact.
Both these overheads are offset by the gradual machine code optimizations that take effect,
and are completely eliminated once the process reaches the dynimized phase.
Therefore an initial warmup period lasting the equivalent of the -window=<seconds>
setting (default 90 seconds) should be set aside for programs using Dynimize.
12.2 Dynimize Memory overhead
Memory overhead also exists, where the dyni process typically requires on average around 4 GB of
virtual memory for each target program being dynimized, while it is dynimizing them. However this can vary
depending on the program being targeted. The Linux Kernel, or an entire process group such as the parent and
worker processes of NGINX each count as one single program for this purpose. Each worker process in a process group
will not incur separate memory overheads by Dynimize.
Most of this virtual memory consumption is used for book keeping purposes when dynimizing,
and so the dynamic range of memory accesses is limited and does
little to trigger additional page faults in memory constrained workloads.
However, at least 4GB total of free swap space + RAM is typically required for each dynimized process during
the dynimizing phase. Once a process is dynimized, most of that memory is freed. The dyni process then typically
consumes 50-150 MB of virtual memory per dynimized process. This is used for book keeping
purposes in order to react to drastic workload changes in dynimized processes. This memory
also undergoes a very small range of dynamic accesses, and should therefore have negligible
impact on system paging.
Note that when using -reoptimize, if a drastic workload change occurs for a specific process
then that target process may be redynimized and will return to the
dynimizing phase. In this case Dynimize will briefly incur the 4 GB virtual memory
overhead per target process again.
An additional use of memory is the 35 MB code cache used by the just-in-time compiler that
is loaded into the target process at the start of the first dynimizing phase. That code cache is shared by the parent and children of a process group such as NGINX.
That being said, the actual access patterns of
machine code instruction memory with the addition of the code cache are more constrained
than that of the original undynimized process, and so the resident memory pages used there
should be less in most cases. Note that the flags -undo
and -redo will leave behind this 35 MB code cache in a target
process, and any subsequent reoptimization of a target process by Dynimize will then create a new code cache when that same process
first enters the dynimizing state again.
On the other hand, when the -reoptimize flag is used and dyni detects a drastic workload change in a process
already dynimized by the current dyni invocation and subsequently reoptimizes it, Dynimize will continue to use the same code cache
initially setup by the current dyni invocation.
Overall, because of the limited range of dynamic memory accesses, these memory overheads
should not affect performance in memory constrained environments. Therefore more RAM is
typically not required. However one should make sure that the system swap space can accommodate
the increased virtual memory used during the dynimizing phase in memory constrained environments.
Questions & Feedback
We love answering questions and your feedback is extremely valuable! Please use the discussion
form below for anything related to this documentation.