Last active
August 29, 2015 14:10
-
-
Save bahamas10/98bd876ece6ad3abce81 to your computer and use it in GitHub Desktop.
pfiles in zone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fcntl.h> | |
#include <stdio.h> | |
#define FILE_TO_OPEN "/etc/passwd" | |
#define TIMES 5000 | |
int main() { | |
int fd; | |
int i; | |
printf("pid: %d\n", getpid()); | |
for (i = 0; i < TIMES; i++) { | |
if (fd = open(FILE_TO_OPEN, O_RDONLY) == -1) { | |
perror("open"); | |
return 1; | |
} | |
} | |
sleep(300); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dave - sjc1-dave-01 sunos ~ $ ./open-5k & | |
[1] 32690 | |
pid: 32690 | |
dave - sjc1-dave-01 sunos ~ $ sudo dtrace -n 'syscall:::entry /pid == $target/ { @[probefunc]=count(); }' -c "sudo pfiles 32690" | |
dtrace: description 'syscall:::entry ' matched 233 probes | |
... | |
(pfiles output) | |
forksys 1 | |
getcwd 1 | |
pipe 1 | |
putmsg 1 | |
recv 1 | |
schedctl 1 | |
setrlimit 1 | |
sigpending 1 | |
so_socketpair 1 | |
sysi86 1 | |
waitsys 1 | |
write 1 | |
getrlimit 2 | |
gtime 2 | |
munmap 2 | |
privsys 2 | |
setpgrp 2 | |
systeminfo 2 | |
lwp_sigmask 3 | |
pollsys 3 | |
setcontext 3 | |
so_socket 3 | |
getgroups 4 | |
setgroups 4 | |
setuid 4 | |
sysconfig 4 | |
setregid 8 | |
setreuid 8 | |
getpid 9 | |
fcntl 10 | |
lseek 10 | |
priocntlsys 11 | |
ioctl 12 | |
brk 15 | |
doorfs 18 | |
getuid 20 | |
fstat 23 | |
sigaction 33 | |
memcntl 36 | |
mmapobj 39 | |
resolvepath 39 | |
lwp_cond_broadcast 40 | |
read 43 | |
mmap 51 | |
close 62 | |
open 65 | |
stat 87 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var net = require('net'); | |
for (var i = 0; i < 5000; i++) | |
net.connect(80, 'daveeddy.com'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dave - sjc1-dave-01 sunos ~ $ ./open-5k-sockets.js & | |
[1] 34728 | |
dave - sjc1-dave-01 sunos ~ $ sudo ptime pfiles 34728 | |
34728: node ./open-5k-sockets.js | |
real 1:28.918439782 | |
user 0.695646071 | |
sys 1:26.230105158 |
Author
bahamas10
commented
Dec 5, 2014
without LD_PRELOAD
dave - sjc1-dave-01 sunos ~/pfiles $ ./open-sockets.js &
[1] 75375
dave - sjc1-dave-01 sunos ~/pfiles $ opened 1000 sockets
ptime pfiles 75375 > /dev/null
real 45.522214487
user 0.334410765
sys 44.691393983
with LD_PRELOAD
dave - sjc1-dave-01 sunos ~/pfiles $ ./open-sockets.js &
[1] 75690
dave - sjc1-dave-01 sunos ~/pfiles $ opened 1000 sockets
LD_PRELOAD=./readlink.so /usr/bin/amd64/ptime /usr/bin/amd64/pfiles 75690 > /dev/null
real 3.887839734
user 0.328562456
sys 2.558752763
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment