Showing posts with label DTrace. Show all posts
Showing posts with label DTrace. Show all posts

Tuesday, April 23, 2013

ZFS Analytics

While woking with ZFS performance I created a dashboard to get a good overview with lots of different statistics. It's powered by Dtrace, python and graphite. There is a high level of detail but still easy to correlate different statistics.

It feels almost like fishworks analytics lite but without advanced features such as drill-down and heat maps. An example from a box running OpenIndiana:



You get a good view of how the layers interact, the latency for reads in ZFS compared to reads in from the physical disks, average latency, maximum latency, average read size and see how much more data ZFS reads form prefetch including hit rate etc.

I based this on the iomon dtrace script with some glue to send it into graphite, I also added ARC statistics and CPU/Network statistics. ( There is a iomon-graphite effort available on the web but that did not give me correct statistics and did not include things like CPU and network utilization ).

iomon.d

Sunday, April 15, 2012

OmniOS

OmniOS is a new illumos-based server distribution with commercial support available was announced at the DTrace conference.

It contains the features you expect like Crossbow, ZFS, DTrace, IPS and Comstar but also includes KVM and updates in userland (Python, GCC, Perl, OpenSSL etc.)

"OmniOS is our vision of what OpenSolaris could have been had it remained in the open. It runs better, faster and has more innovations,” continued Schlossnagle. “OmniTI did not want to lose the benefits that OpenSolaris technologies brought to customers, so we decided to pursue the continuation of the OS on our own. We've been running OmniOS in our data centers for six months and have seen tremendous results. We’re excited to announce our news at the DTrace conference because of its importance and relevance to this community."
- Theo Schlossnagle, CEO of OmniTI

More information, install images and source repositories are available here: omnios.omniti.com

I have only installed the image into VirtualBox witch was painless and quick, I might post an update when I've had time for some exploring.

OmniTI Debuts OmniOS, an Open Source Operating System for the Solaris Community

Tuesday, January 3, 2012

The all-seeing eye of DTrace

I was recently involved with a problem related to backup software running on Solaris, as part of a general health check of the system I stumbled on something interesting that was not visible using conventional tools.

This tuned out to be a good opportunity to put my DTrace skill to work together with a few finished scripts. Once again it struck what how amazing this tool is, you can really see everything that is going on in your system and as it turns out, you can even see problems that does not even exist. Since this was so much fun and a good example I will walk through the steps again:

The thing that caught my eye was the output from errinfo of the DTrace toolkit. There are a very high rate of system calls returning in error, namely close() with -9 "Bad file number", as seen with errinfo:
whoami        ioctl   22     13  Invalid argument                 
init ioctl 25 212 Inappropriate ioctl for device
awk stat64 2 520 No such file or directory
java lwp_cond_wait 62 3492 timer expired
processx close 9 102073391 Bad file number
Syscall errors are in itself normal can be seen on any systems, but usually not several thousand per second. As the error message indicates this happens when a close() is issued on a file handle (Integer) that does not represent an open file for that process, which at first look seems like a quite useless operation.

We can also see that close() is by far the most used system call here:
# dtrace -q -n 'BEGIN { close=0;total=0 } syscall::close:entry \
{ close = close + 1 } syscall:::entry { total = total + 1 } END \
{ printf("%d close calls of %d total calls\n",close,total) }'

309530 close calls of 426212 total calls
Looking at which file descriptor the process is trying to close shows that there is an even distribution of close between 0 and 65536 and the only successful calls where to numbers lower than 1024 where numbers normally used unless a process has a very high amount of open files.
# dtrace -n 'syscall::close:entry { this->fd = arg0 } syscall::close:return \
/ errno!= 0 / { @failed = lquantize(this->fd,0,65536,16384) } syscall::close:return \
/errno == 0/ { @good = lquantize(this->fd,0,65535,1024) }
dtrace: description 'syscall::close:entry ' matched 3 probes
value ------------- Distribution ------------- count
< 0 | 7
0 |@@@@@@@@@@@@@ 414811
16384 |@@@@@@@@@ 294912
32768 |@@@@@@@@@ 294912
49152 |@@@@@@@@@ 294912
>= 65536 | 0

value ------------- Distribution ------------- count
< 0 | 0
0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12459
1024 | 0
The processes responsible only lives only a short while, but by using dtruss i could trace system calls based on the process name:
 15889/1:  fork1()   = 0 0
15889/1: lwp_sigmask(0x3, 0x0, 0x0) = 0xFFFF 0
11385/1: getpid(0x0, 0x1, 0x1CD0) = 15889 0
11385/1: lwp_self(0x0, 0x1, 0x40) = 1 0
11385/1: lwp_sigmask(0x3, 0x0, 0x0) = 0xFFFF 0
11385/1: fcntl(0xA, 0x9, 0x0) = 0 0
11385/1: schedctl(0xFFFFFFFF7F7361B8, 0xFFFFFFFF7F738D60, 0x11A340)
= 2139062272 0
11385/1: lwp_sigmask(0x3, 0x0, 0x0) = 0xFFFF 0
11385/1: sigaction(0x12, 0xFFFFFFFF7FFDEE20, 0x0) = 0 0
11385/1: sigaction(0x2, 0xFFFFFFFF7FFDEE20, 0x0) = 0 0
11385/1: sigaction(0xF, 0xFFFFFFFF7FFDEE20, 0x0) = 0 0
11385/1: getrlimit(0x5, 0xFFFFFFFF7FFDED90, 0x0) = 0 0
11385/1: close(0x3) = 0 0
11385/1: close(0x4) = 0 0
11385/1: close(0x5) = 0 0
11385/1: close(0x6) = 0 0
....
11397/1: close(0xFFFF) = -1 Err#9
The process is issuing close on all numbers between 0x3 to 0xFFFF in a loop, as expected the first few are actually open and closed correctly but the other was majority is returning error -9.

If we look in the beginning of the trace we can see a fork, followed a little later by getrlimit(0x5,...), if we look at what that arguments to getrlimit means:
# egrep "RLIMIT.*5" /usr/include/sys/resource.h
#define RLIMIT_NOFILE 5 /* file descriptors */
The process is checking the limit of file descriptors and then closes the whole possible range which seems a little unnecessary since almost none of them are open. But this was just after a fork, and a forked process inherits all the open files of it's parent, this might not be what you want so a close is in order. There are however no easy way of getting a list of all used file descriptors so what we see here is a brute-force approach of making sure none are open before continuing. This would probably not have been noticed if it weren't for the unusual high limit of file descriptors.
# plimit $(pgrep processx|head -1) | grep nofiles
nofiles(descriptors) 65536 65536
Perhaps a iteration with close on the contents of /proc/${PID}/fd would have been less resource consuming in this scenario.

All of this was done in a production system without impact to applications which is crucial, you must be able to trust that it will never bring your system down. This is something DTrace can be trusted with where some platforms lacking it but tries to provide somewhat similar observability fails, read Brendans blog: using systemtap or the older but entertaining DTrace knockoffs.

Download the DTracetoolkit here.

Monday, August 15, 2011

First impressions of SmartOS/illumos KVM

A live image of SmartOS from Joyent with KVM was released today together with the source for the whole illumos KVM implementation. Much effort have been put into this by the Joyent team and the illumos community is blessed to have such great contributors. This is the first major feature that stands out from OpenSolaris/Solaris 11 Express.

This does not only makes illumos capable of running various fully virtualized guests, it also provides several other unique features for the guest compared to other virtualization hosts. First the security is better than vanilla KVM since there is a specific zone brand for KVM instances that also isolates it inside a zone even if a bug is exploited in KVM. Add to that the fully virtualized network stack with QOS that crossbow provides, all the features of ZFS (with bandwidth throttling in SmartOS) and DTrace!

This will bring most of the features of natives zones on illumos to a variety of other guest operating systems running under KVM and all common operating systems are already working including Windows, FreeBSD and Linux.

Have a look at Bryans slides from the presentation at KVM summit 2011, especially those with visualized DTrace statistics from KVM instances! There are also some screenshots of various guests running under KVM.

smartos.org
SmartOS (Live ISO image)
KVM on illumos

Sunday, February 6, 2011

illumos news

There have been some news surrounding the illumos project, the community developed and maintained version of the OS/Net consolidation and future code base for Nexenta and OpenIndiana.

First Nexenta have hired three known developers from the OpenSolaris community. The development process have also been changed to become more scalable so that more developers can participate. This is done by having Advocates accepting and reviewing patches instead of giving commit access to all contributors:

"So now, rather than developers pushing changes directly to our mercurial tree, going forward Advocates will take patches from Contributors (either via hg export or patch file), verify that the content of the patch is what was reviewed, and will then be responsible for integrating those changes into our shared master."

It's encouraging to see that two of the three persons behind DTrace is active in the illumos project, Bryan Cantrill posted this to illumos-devel a few days ago:

"For whatever it's worth, I have some DTrace patches and some user-land SMF patches to send to whomever is most appropriate. (Both of these add new features, FWIW.)"

Welcome to new Nexentians
Change to illumos contribution process

Monday, October 25, 2010

Both Mike and Brendan quits Oracle

The last of the tree DTrace creators are now leaving Oracle, Mike Shapiro, who also was part of the FishWorks core team. Another member of the FishWorks team was Brendan Greg who also resigned from Oracle. Those of you who didn't now about Bredan before probably got to know who he was when he became famous for screaming at disks in a online video.

DTrace and ZFS is the core foundation of the S7000 storage appliance, now the whole team who invented DTrace is gone and so are the two core persons behind ZFS, Jeff Bonwick and Bill Moore.

There are a lot of other great people behind these products, but the ones listed above are rare and extremly talented engineers and have all been part of breaking new ground in their area of expertice. The FishWorks team even created a usable web interface, a rare thing comming from Sun.

Mike Shapiro: End of file
Brendan Gregg: G'Day and Goodbye
Brendan Gregg screaming, Unusual disk latency
FishWorks, Now it can be told

Wednesday, August 18, 2010

Adam Leventhal also quits Oracle

It seems that Oracle is no place for talented high profile engineers, Adam Leventhal is also leaving Sun. Adam was also part of the team that created DTrace and latest Fishworks together with Bryan Cantrill who left a few weeks ago. The most known persons from the Fishworks team has their blogs linked from the dtrace.org site, even Mike Shapiro and Brendan Gregg which are still at Oracle. Nice to see that they keep together even when two of them have left Oracle.

I'm sad too see him leave Oracle but I wish him the best in whatever he decides to do. I can only hope that he in some way will continue to be involved with Solaris. Maybe hi swears his allegiance to Illumos just as as Bryan Cantrill did (He is VP of Engineering at Joyent which have stated they will be involved with Illumos). Maybe he even joins Mike at Joyent, it seem like a good fit for creative people, especially ex-Sun (I meet the Joyent guys a year ago over a lunch, fantastic people and a very interesting company).

The new home for Adams blog with the "Leaving Oracle" entry:
http://dtrace.org/blogs/ahl/

Monday, July 26, 2010

Good luck Bryan

There are many good engineers working with Solaris, but a few of them get noticed a bit more. Bryan Cantrill is one of those and sadly he is now leaving Sun/Oracle. Bryan is the inventor of DTrace which he created together with Mike Shapiro and Adam Leventhal and he have even kissed a girl. Once upon a time he was requited to Sun Microsystems by Jeff Bonwick, the father of ZFS. The last few years he was a vital part of the FishWorks team used in the S7000 storage series that uses DTrace to produce graphical analytics of performance data.

I wish Bryan the best whatever he decides to do. I will keep an eye out for his next endeavor.

The new home of Bryan's blog which also holds his last entry from the Sun/Oracle blog: dtrace.org/blogs/bmc

Bryan's profile at Sun Labs: Bryan Cantrill - Sun Labs

Friday, May 28, 2010

Putback and a new build for 2010.05

The DTrace TCP/UDP providers discussed in this post have now been integrated into the OpenSolaris source. Another useful enhancement also made it's way into the source, PSARC/2010/181 PRIV_SYS_RES_BIND privilege. This will make it possible delegate permission to bind processes to specific processor sets from within the zone.

A new build of what is to become the next release of OpenSolaris is also probably finished or at least very close to finished, the second respin of build 134, 134b:

Author: david.comay@oracle.com
Repository: /hg/pkg/gate
Latest revision: 48706bcc893fc2c3ed76528eb4bc4b5dcb940f95
Total changesets: 1
Log message:
16087 resync repository to snv-134b

Monday, November 3, 2008

Follow the white rabbit

Yesterday i encountered a strange problem which was very entertaining to debug and dtrace came to the rescue as as always. I had done a fresh install of Solaris Nevada build 101 on a AMD64 machine at home. The installation went fine and i started to configure on the host, but after a while i begun to get error messages like: "couldn't set locale correctly". I checked the SYSV package containing my locale, en_US.8859-1:

# pkgchk SUNWlang-en-extra
ERROR: /usr/lib/locale/en_US.ISO8859-1/en_US.ISO8859-1.so.3
pathname does not exist


The installation logs showed that the package had been installed correctly. I tried to reinstall the package which temporarily fixed the problem but after 10 minutes or so it the file was missing again. I repeated this twice to see if there was any time pattern, but it gave me no clue to why the files was removed. I decided to use both BSM auditing and dtrace to see what might be causing the removal of the file. I waited and waited, but the file stayed there so i started to use the system as ordinary, that somehow triggered the removal of the file!?

A dtrace script created by Chris Gerhard showed me what caused the removal of the file:

# ./delete.d
dtrace: script './trace.d' matched 2 probes
CPU ID FUNCTION:NAME
0 75683 unlink:return man prctl
UID 0 PPID 11244 sh


Audit also logged the unlink of the file, following the trail it could have shoved me that man was responsible:

header,242,2,unlink(2),,ollespappa,2008-11-03 02:52:01.096 +01:00
path,/usr/lib/locale/en_US.ISO8859-1/en_US.ISO8859-1.so.3
attribute,100555,root,bin,65538,320199,18446754073709451615
subject,arne,root,root,root,root,15984,2799982011,1330 5632 xx.xx.xx.xx
return,success,0


So, man(1) unlinked the file, that did not make any sense at all. A dtrace one liner gave me more information:

# dtrace -n 'pid$target:libc:unlink:entry { printf("unlink(%s)\n",copyinstr(arg0)); ustack(); }' -c 'man ls'
CPU ID FUNCTION:NAME
1 76165 unlink:entry unlink(/usr/lib/locale/en_US.ISO8859-1/en_US.ISO8859-1.so.3)
libc.so.1`unlink
man`format+0xd54
man`searchdir+0x14d
man`mandir+0x194
man`manual+0x1c1
man`main+0x5d4
man`_start+0x7d


The unlink was called from the format function of man, Looking at the source I identified which line was responsible for the unlink:
2754 (void) unlink(tmpdir);

After some more investigation I realized that the argument string to the unlink command might not get initialized, it then points out in space. For this system it pointed at a string which represented the path to a file which could be unlinked. This occurs only if the manual page is in another format than SGML since the variables are initialized inside an SGML-related if-statement :

2612 if (sgml_flag == 1) {
2613 if (check_flag == 0) {
2614 strcpy(tmpdir, "/tmp/sman_XXXXXX");


This bug seems to have been in Solaris for ages, but the uninitialized string might never have come to point to anything useful to unlink, it could perhaps be the switch to SunStudio 12 in snv100 that triggered this behavior.

This is now CR 6767074.