DTrace

Last updated
DTrace
Original author(s) Bryan Cantrill, Adam Leventhal, Mike Shapiro (Sun Microsystems)
Developer(s) Sun Microsystems, Oracle, Microsoft
Initial releaseJanuary 2005;19 years ago (2005-01)
Repository github.com/opendtrace
Written in C
Operating system Solaris, illumos, macOS, FreeBSD, NetBSD, Linux, [1] Windows [2]
Type Tracing
License CDDL, GPLv2, UPL
Website dtrace.org/about/

DTrace is a comprehensive dynamic tracing framework originally created by Sun Microsystems for troubleshooting kernel and application problems on production systems in real time. Originally developed for Solaris, it has since been released under the free Common Development and Distribution License (CDDL) in OpenSolaris and its descendant illumos, and has been ported to several other Unix-like systems.

Contents

DTrace can be used to get a global overview of a running system, such as the amount of memory, CPU time, filesystem and network resources used by the active processes. It can also provide much more fine-grained information, such as a log of the arguments with which a specific function is being called, or a list of the processes accessing a specific file.

In 2010, Oracle Corporation acquired Sun Microsystems and announced discontinuing OpenSolaris. As a community effort of some core Solaris engineers to create a truly open source Solaris, illumos operating system was announced via webinar on Thursday, 3 August 2010, [3] as a fork on OpenSolaris OS/Net consolidation, including DTrace technology.

In October 2011, Oracle announced the porting of DTrace to Linux, [4] and in 2019 official DTrace for Fedora is available on GitHub. For several years an unofficial DTrace port to Linux was available, with no changes in licensing terms. [5]

In August 2017, Oracle released DTrace kernel code under the GPLv2+ license, and user space code under GPLv2 and UPL licensing. [6] In September 2018 Microsoft announced that they had ported DTrace from FreeBSD to Windows. [2]

In September 2016 the OpenDTrace effort began on github with both code and comprehensive documentation of the system's internals. The OpenDTrace effort maintains the original CDDL licensing for the code from OpenSolaris with additional code contributions coming under a BSD 2 Clause license. The goal of OpenDTrace is to provide an OS agnostic, portable implementation of DTrace that is acceptable to all consumers, including macOS, FreeBSD, OpenBSD, NetBSD, and Linux as well as embedded systems.

Description

Sun Microsystems designed DTrace to give operational insights that allow users to tune and troubleshoot applications and the OS itself.

Testers write tracing programs (also referred to as scripts) using the D programming language (not to be confused with other programming languages named "D"). The language, inspired by C, includes added functions and variables specific to tracing. D programs resemble AWK programs in structure; they consist of a list of one or more probes (instrumentation points), and each probe is associated with an action. These probes are comparable to a pointcut in aspect-oriented programming. Whenever the condition for the probe is met, the associated action is executed (the probe "fires"). A typical probe might fire when a certain file is opened, or a process is started, or a certain line of code is executed. A probe that fires may analyze the run-time situation by accessing the call stack and context variables and evaluating expressions; it can then print out or log some information, record it in a database, or modify context variables. The reading and writing of context variables allows probes to pass information to each other, allowing them to cooperatively analyze the correlation of different events.

Special consideration has been taken to make DTrace safe to use in a production environment. For example, there is minimal probe effect when tracing is underway, and no performance impact associated with any disabled probe; this is important since there are tens of thousands of DTrace probes that can be enabled. New probes can also be created dynamically.

Command line examples

DTrace scripts can be invoked directly from the command line, providing one or more probes and actions as arguments. Some examples:

# New processes with arguments dtrace-n'proc:::exec-success { trace(curpsinfo->pr_psargs); }'# Files opened by process dtrace-n'syscall::open*:entry { printf("%s %s",execname,copyinstr(arg0)); }'# Syscall count by program dtrace-n'syscall:::entry { @num[execname] = count(); }'# Syscall count by syscall dtrace-n'syscall:::entry { @num[probefunc] = count(); }'# Syscall count by process dtrace-n'syscall:::entry { @num[pid,execname] = count(); }'# Disk size by process dtrace-n'io:::start { printf("%d %s %d",pid,execname,args[0]->b_bcount); }'# Pages paged in by process dtrace-n'vminfo:::pgpgin { @pg[execname] = sum(arg0); }'

Scripts can also be written which can reach hundreds of lines in length, although typically only tens of lines are needed for advanced troubleshooting and analysis. Over 200 examples of open source DTrace scripts can be found in the DTraceToolkit, [7] created by Brendan Gregg (author of the DTrace book [8] ), which also provides documentation and demonstrations of each.

Supported platforms

DTrace first became available for use in November 2003, and was formally released as part of Sun's Solaris 10 in January 2005. DTrace was the first component of the OpenSolaris project to have its source code released under the Common Development and Distribution License (CDDL).

DTrace is an integral part of illumos and related distributions.

DTrace is a standard part of FreeBSD [9] and NetBSD. [10]

Apple added DTrace support in Mac OS X 10.5 "Leopard", including a GUI called Instruments. [11] Over 40 DTrace scripts from the DTraceToolkit are included in /usr/bin, [12] including tools to examine disk I/O (iosnoop) and process execution (execsnoop). Unlike other platforms that DTrace is supported on, Mac OS X has a flag (P_LNOATTACH) that a program may set that disallows tracing of that process by debugging utilities such as DTrace and gdb. In the original Mac OS X DTrace implementation, this could affect tracing of other system information, as unrelated probes that should fire while a program with this flag set was running would fail to do so. [13] The OS X 10.5.3 update addressed this issue a few months later. [14] However, since El Capitan, System Integrity Protection prevents user from DTracing protected binary by default.

The Linux port of DTrace has been available since 2008; [15] work continues actively to enhance and fix issues. There is also an active implementation on github. Standard core providers are available (fbt, syscall, profile), plus a special "instr" provider (some of the Solaris providers are not yet available as of 2013). The Linux DTrace implementation is a loadable kernel module, which means that the kernel itself requires no modification, and thus allows DTrace to avoid CDDL vs. GPL licensing conflicts (in its source form, at least). However, once DTrace is loaded the kernel instance will be marked as tainted.

In 2007, a developer at QNX Software Systems announced on his blog that he and a colleague were working on incorporating DTrace into the QNX operating system. [16]

Oracle Corporation added beta DTrace support for Oracle Linux in 2011, [1] as a technology preview in the Unbreakable Enterprise Kernel release 2, which is under GPLv2 (the DTrace Linux kernel module was originally released under CDDL). [17] General availability was announced in December 2012. [18] [19]

On March 11, 2019, Microsoft released their build of DTrace for the Windows 10 insider builds. [20]

Language and application providers

With a supported language provider, DTrace can retrieve context of the code, including function, source file, and line number location. Further, dynamic memory allocation and garbage collection can be made available if supported by the language. [21] Supported language providers include assembly language [ clarification needed ], C, C++, Java, Erlang, JavaScript, Perl, PHP, Python, Ruby, shell script, and Tcl.

Application providers allow DTrace to follow the operation of applications through system calls and into the kernel. Applications that offer DTrace application providers include MySQL, PostgreSQL, Oracle Database, Oracle Grid Engine, and Firefox. [21] [22] [23]

Authors and awards

DTrace was designed and implemented by Bryan Cantrill, Mike Shapiro, and Adam Leventhal.

The authors received recognition in 2005 for the innovations in DTrace from InfoWorld and Technology Review . [24] [25] DTrace won the top prize in The Wall Street Journal 's 2006 Technology Innovation Awards competition. [26] The authors were recognized by USENIX with the Software Tools User Group (STUG) award in 2008. [27]

See also

Related Research Articles

A monolithic kernel is an operating system architecture where the entire operating system is working in kernel space. The monolithic model differs from other operating system architectures in that it alone defines a high-level virtual interface over computer hardware. A set of primitives or system calls implement all operating system services such as process management, concurrency, and memory management. Device drivers can be added to the kernel as modules.

<span class="mw-page-title-main">Oracle Solaris</span> Unix operating system originally developed by Sun Microsystems

Solaris is a proprietary Unix operating system originally developed by Sun Microsystems. After the Sun acquisition by Oracle in 2010, it was renamed Oracle Solaris.

These tables provide a comparison of operating systems, of computer devices, as listing general and technical information for a number of widely used and currently available PC or handheld operating systems. The article "Usage share of operating systems" provides a broader, and more general, comparison of operating systems that includes servers, mainframes and supercomputers.

<span class="mw-page-title-main">OpenSolaris</span> Open source operating system from Sun Microsystems based on Solaris

OpenSolaris is a discontinued open-source computer operating system based on Solaris and created by Sun Microsystems. It was also, perhaps confusingly, the name of a project initiated by Sun to build a developer and user community around the eponymous operating system software.

The Common Development and Distribution License (CDDL) is a free and open-source software license, produced by Sun Microsystems, based on the Mozilla Public License (MPL). Files licensed under the CDDL can be combined with files licensed under other licenses, whether open source or proprietary. In 2005 the Open Source Initiative approved the license. The Free Software Foundation (FSF) considers it a free software license, but one which is incompatible with the GNU General Public License (GPL).

init UNIX system component

In Unix-based computer operating systems, init is the first process started during booting of the operating system. Init is a daemon process that continues running until the system is shut down. It is the direct or indirect ancestor of all other processes and automatically adopts all orphaned processes. Init is started by the kernel during the booting process; a kernel panic will occur if the kernel is unable to start it, or it should die for any reason. Init is typically assigned process identifier 1.

<span class="mw-page-title-main">Bryan Cantrill</span> American computer scientist

Bryan M. Cantrill is an American software engineer who worked at Sun Microsystems and later at Oracle Corporation following its acquisition of Sun. He left Oracle on July 25, 2010, to become the Vice President of Engineering at Joyent, transitioning to Chief Technology Officer at Joyent in April 2014, until his departure on July 31 of 2019. He is now the CTO of Oxide Computer company.

OS-level virtualization is an operating system (OS) virtualization paradigm in which the kernel allows the existence of multiple isolated user space instances, called containers, zones, virtual private servers (OpenVZ), partitions, virtual environments (VEs), virtual kernels, or jails. Such instances may look like real computers from the point of view of programs running in them. A computer program running on an ordinary operating system can see all resources of that computer. However, programs running inside of a container can only see the container's contents and devices assigned to the container.

strace Diagnostic, debugging and instructional userspace utility for Linux

strace is a diagnostic, debugging and instructional userspace utility for Linux. It is used to monitor and tamper with interactions between processes and the Linux kernel, which include system calls, signal deliveries, and changes of process state. The operation of strace is made possible by the kernel feature known as ptrace.

<span class="mw-page-title-main">FreeBSD</span> Free and open-source Unix-like operating system

FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution (BSD). The first version of FreeBSD was released in 1993 developed from 386BSD and the current version runs on x86, ARM, PowerPC and RISC-V processors. The project is supported and promoted by the FreeBSD Foundation.

chattr is the command in Linux that allows a user to set certain attributes of a file. lsattr is the command that displays the attributes of a file.

In the context of computer programming, instrumentation refers to the measure of a product's performance, in order to diagnose errors and to write trace information. Instrumentation can be of two types: source instrumentation and binary instrumentation.

Adam Leventhal is an American software engineer, and one of the three authors of DTrace, a dynamic tracing facility in Solaris 10 which allows users to observe, debug and tune system behavior in real time. Available to the public since November 2003, DTrace has since been used to find opportunities for performance improvements in production environments. Adam joined the Solaris kernel development team after graduating cum laude from Brown University in 2001 with his B.Sc. in Math and Computer Science. In 2006, Adam and his DTrace colleagues were chosen Gold winners in The Wall Street Journal's Technology Innovation Awards contest by a panel of judges representing industry as well as research and academic institutions. A year after Sun Microsystems was acquired by Oracle Corp, Leventhal announced he was leaving the company. He served as Chief Technology Officer at Delphix from 2010 to 2016.

ProbeVue is IBM's implementation of a lightweight dynamic tracing environment introduced in AIX version 6.1. ProbeVue provides the ability to probe running processes in order to provide statistical analysis as well as retrieve data from the probed process. The dynamic nature of ProbeVue allows it to be used as a global system performance tool while retaining the ability to drill into very specific events on a single process or thread.

ptrace is a system call found in Unix and several Unix-like operating systems. By using ptrace one process can control another, enabling the controller to inspect and manipulate the internal state of its target. ptrace is used by debuggers and other code-analysis tools, mostly as aids to software development.

libvirt Management tool

libvirt is an open-source API, daemon and management tool for managing platform virtualization. It can be used to manage KVM, Xen, VMware ESXi, QEMU and other virtualization technologies. These APIs are widely used in the orchestration layer of hypervisors in the development of a cloud-based solution.

<span class="mw-page-title-main">Illumos</span> Free software implementation of the Solaris kernel

Illumos is a partly free and open-source Unix operating system. It is based on OpenSolaris, which was based on System V Release 4 (SVR4) and the Berkeley Software Distribution (BSD). Illumos comprises a kernel, device drivers, system libraries, and utility software for system administration. This core is now the base for many different open-sourced Illumos distributions, in a similar way in which the Linux kernel is used in different Linux distributions.

<span class="mw-page-title-main">Brendan Gregg</span> Australian computer scientist

Brendan Gregg is a computer engineer known for his work on computing performance. He works for Intel, and previously worked at Netflix, Sun Microsystems, Oracle Corporation, and Joyent. He was born in Newcastle, New South Wales and graduated from the University of Newcastle, Australia.

<span class="mw-page-title-main">OpenZFS</span> Open-source implementation of the ZFS file system

OpenZFS is an open-source implementation of the ZFS file system and volume manager initially developed by Sun Microsystems for the Solaris operating system and now maintained by the OpenZFS Project. It supports features like data compression, data deduplication, copy-on-write clones, snapshots, and RAID-Z. It also supports the creation of virtual devices, which allows for the creation of file systems that span multiple disks.

Michael W. Shapiro is an American computer programmer who worked in operating systems and storage at Sun Microsystems, Oracle, and EMC.

References

Notes

  1. 1 2 Wim Coekaerts (2011-10-09). "Trying out dtrace". blogs.oracle.com. Retrieved 2018-02-15.
  2. 1 2 "OS internals: Technical deep-dive into operating system innovations - BRK3365". Microsoft Ignite Channel. 2018-10-08.
  3. D'Amore, Garrett (3 August 2010). "Illumos - Hope and Light Springs Anew - Presented by Garrett D'Amore" (PDF). illumos.org. Retrieved 3 August 2010.
  4. "Oracle To Bring Dtrace To Linux". Slashdot. 2011-10-04. Retrieved 2020-11-11.
  5. "The original DTrace is licensed under Sun's (now Oracle) CDDL license. Original copyrights are left intact. No GPL code is incorporated into the release, to avoid legal conflicts."
  6. Wielaard, Mark J. (2018-02-14). "dtrace for linux; Oracle does the right thing". Mark J. Wielaard blog. Retrieved 2018-02-14.
  7. "DTraceToolkit". Brendan Gregg . Retrieved 2014-06-08.
  8. DTrace: Dynamic Tracing in Oracle Solaris, Mac OS X and FreeBSD. Safari Books. 2011. ISBN   978-0132091510. Archived from the original on 2011-04-06. Retrieved 2011-01-03.
  9. "FreeBSD 7.1-RELEASE Announcement". 2009-01-06. Retrieved 2009-01-06.
  10. "NetBSD source changes, 21 February 2010".
  11. "Mac OS X Leopard - Developer Tools - Instruments". Apple Inc. Archived from the original on 2007-10-24. Retrieved 2007-10-19.
  12. "Mac OS X DTrace". Apple Inc. Retrieved 2010-05-31.
  13. "Mac OS X and the missing probes". Leventhal, Adam H. January 18, 2008. Retrieved 2008-01-20.
  14. "Apple Updates DTrace". Leventhal, Adam H. June 7, 2008. Retrieved 2008-06-16.
  15. "CRiSP tools download page". Archived from the original on 2020-11-16. Retrieved 2011-03-02.
  16. "DTrace on QNX!". Oracle The Observation Deck Blog. November 8, 2007.
  17. Zannoni, Elena; Van Hees, Kris (2012). DTrace on Linux (PDF). Linux Foundation Collaboration Summit. Archived from the original (PDF) on 2014-07-07. Retrieved 2012-04-05.
  18. Koch, Zeynep (December 12, 2012). "Announcement: DTrace for Oracle Linux General Availability". Oracle Linux Blog.
  19. DTrace module source code for Linux [ permanent dead link ]
  20. Pulapaka, Hari (March 11, 2019). "DTrace on Windows". Microsoft Tech Community.
  21. 1 2 DTrace: Dynamic Tracing in Oracle Solaris, Mac OS X and FreeBSD. Prentice Hall. 2011. p. 1152. ISBN   9780132091510.
  22. "Open Grid Scheduler / Grid Engine Documentation". Open Grid Scheduler. Retrieved December 30, 2012.
  23. "DTrace – MDN". Mozilla. Archived from the original on September 5, 2014. Retrieved December 30, 2012.
  24. "Tracing software in real time". Technology Review. MIT. 2005. Retrieved 2007-03-31.
  25. McAllister, Neil (August 2005). "Innovation is alive and well in 2005". InfoWorld. IDG. Archived from the original on 2005-11-23. Retrieved 2007-03-31.
  26. Totty, Michael (September 2006). "The Winners Are..." The Wall Street Journal. Dow Jones & Company, Inc. Retrieved 2007-03-31.
  27. "2008 USENIX Annual Technical Conference (USENIX '08)". 2008. Retrieved 2008-11-26.
  28. "DTrace Tools" . Retrieved 2017-11-27.