-
Notifications
You must be signed in to change notification settings - Fork 441
JVM RASP 性能
江湖风轻 edited this page Oct 9, 2022
·
1 revision
每个线程无限循环进程创建,文件操作以及网络请求,覆盖大多数 hook 点。由于大多数是 IO 行为,整体 CPU 不会太高,但是产生的消息量巨大。
使用 StopWatch
在每次字节码插入时开始计时,并在执行原始函数时暂停,能够较为精确地记录 RASP 额外指令带来的性能消耗。
单线程低并发:
class | method | tp50(ns) | tp90 | tp95 | tp99 | tp99.99 | max |
---|---|---|---|---|---|---|---|
java.lang.ProcessImpl | start | 96823 | 295512 | 396059 | 612999 | 12748158 | 28223783 |
java.lang.ProcessImpl | getOutputStream | 5733 | 8858 | 11339 | 31768 | 547852 | 824476 |
java.lang.ProcessImpl | getInputStream | 9801 | 27723 | 41737 | 172547 | 766828 | 4967599 |
java.lang.ProcessImpl | getErrorStream | 4961 | 7252 | 9187 | 23882 | 467276 | 849348 |
java.io.FileInputStream | constructor | 10530 | 36148 | 51758 | 241786 | 906853 | 2968732 |
java.io.FileOutputStream | constructor | 8872 | 15839 | 24691 | 135778 | 673014 | 6687335 |
java.io.File | renameTo | 8323 | 24700 | 52743 | 220718 | 1503630 | 90326511 |
java.io.File | list | 61932 | 163706 | 275240 | 483988 | 15104078 | 34878852 |
java.io.File | delete | 67590 | 162136 | 271758 | 457359 | 18258084 | 33088801 |
java.io.File | createNewFile | 14333 | 34837 | 54300 | 243190 | 847079 | 8309822 |
java.net.Socket | connect | 74097 | 181728 | 284542 | 440072 | 10637368 | 20627876 |
sun.nio.ch.Net | connect | 86651 | 167033 | 316820 | 466827 | 11771791 | 24649484 |
java.lang.ClassLoader | loadLibrary | 182276 | 221165 | 221165 | 221165 | 221165 | 347072 |
java.net.URLClassLoader | constructor | 14150 | 35151 | 91930 | 345147 | 1079549 | 26564824 |
java.net.InetAddress | getAllByName | 66681 | 153018 | 259672 | 451448 | 26507928 | 37809513 |
java.net.DatagramSocket | connectInternal | 20964 | 30486 | 38088 | 248244 | 702874 | 14941886 |
sun.nio.fs.UnixNativeDispatcher | open | 15633 | 46561 | 69982 | 292513 | 3567036 | 43932892 |
sun.nio.fs.UnixNativeDispatcher | link | 11774 | 30595 | 49532 | 271219 | 3364283 | 25559608 |
sun.nio.fs.UnixNativeDispatcher | unlink | 9288 | 16216 | 20705 | 55641 | 667421 | 32426994 |
sun.nio.fs.UnixNativeDispatcher | rename | 12422 | 29566 | 42380 | 239380 | 6245418 | 23419290 |
sun.nio.fs.UnixNativeDispatcher | mkdir | 11287 | 31336 | 59343 | 307890 | 2809229 | 23986627 |
sun.nio.fs.UnixNativeDispatcher | rmdir | 9021 | 24555 | 37962 | 226774 | 898130 | 38024814 |
java.io.RandomAccessFile | constructor | 7516 | 11248 | 14803 | 43788 | 493034 | 5449350 |
java.nio.file.Files | copy | 3858 | 6329 | 8346 | 20498 | 560081 | 26756424 |
java.nio.file.Files | move | 4604 | 7905 | 12064 | 32173 | 613606 | 11647599 |
20个线程高并发:
class | method | tp50(ns) | tp90 | tp95 | tp99 | tp99.99 | max |
---|---|---|---|---|---|---|---|
java.lang.ProcessImpl | start | 53475 | 102106 | 261396 | 6078242 | 91228806 | 203956373 |
java.lang.ProcessImpl | getOutputStream | 6484 | 10071 | 12644 | 34445 | 93296365 | 154309431 |
java.lang.ProcessImpl | getInputStream | 8123 | 16245 | 25161 | 90876 | 93247332 | 148152728 |
java.lang.ProcessImpl | getErrorStream | 5960 | 9080 | 11226 | 26872 | 12569229 | 72210908 |
java.io.FileInputStream | constructor | 9209 | 22826 | 31551 | 87251 | 34498824 | 93044092 |
java.io.FileOutputStream | constructor | 8733 | 15253 | 22246 | 66415 | 11528979 | 14134987 |
java.io.File | renameTo | 8424 | 17117 | 24971 | 68799 | 11460630 | 72566531 |
java.io.File | list | 37802 | 69868 | 88489 | 472440 | 170624194 | 253013256 |
java.io.File | delete | 32531 | 77660 | 97376 | 705747 | 17029705 | 67466264 |
java.io.File | createNewFile | 12448 | 33602 | 54330 | 226673 | 20769639 | 302325311 |
java.net.Socket | connect | 77179 | 106788 | 144396 | 781278 | 21663317 | 104182533 |
sun.nio.ch.Net | connect | 76413 | 142734 | 170392 | 731096 | 97617089 | 298959759 |
java.lang.ClassLoader | loadLibrary | 90301 | 156902 | 156902 | 156902 | 156902 | 163938 |
java.net.URLClassLoader | constructor | 13890 | 28133 | 36570 | 231089 | 13576690 | 69458301 |
java.net.InetAddress | getAllByName | 39220 | 152231 | 184362 | 474723 | 209761405 | 373643653 |
java.net.DatagramSocket | connectInternal | 20209 | 33882 | 50706 | 288568 | 9863912 | 44518561 |
sun.nio.fs.UnixNativeDispatcher | open | 12824 | 32555 | 42285 | 105130 | 11422893 | 87704860 |
sun.nio.fs.UnixNativeDispatcher | link | 11356 | 26203 | 36037 | 109681 | 12951552 | 64969375 |
sun.nio.fs.UnixNativeDispatcher | unlink | 8714 | 16788 | 21150 | 53478 | 10385111 | 19177374 |
sun.nio.fs.UnixNativeDispatcher | rename | 12816 | 24615 | 32909 | 86684 | 12245986 | 45848260 |
sun.nio.fs.UnixNativeDispatcher | mkdir | 11112 | 21851 | 29271 | 91360 | 9351289 | 124326385 |
sun.nio.fs.UnixNativeDispatcher | rmdir | 8999 | 18185 | 24686 | 72341 | 16610711 | 125197066 |
java.io.RandomAccessFile | constructor | 7327 | 10654 | 13097 | 39918 | 26870544 | 92967952 |
java.nio.file.Files | copy | 5274 | 9509 | 14814 | 40133 | 8411528 | 41764104 |
java.nio.file.Files | move | 4728 | 7327 | 8489 | 20678 | 7875707 | 36816949 |
内存占用:50M 注入后内存立刻增长 30M,包括 JVM 开启的 AttachListener 线程,加载 SmithAgent 以及初始化 RASP 守护线程等带来的消耗。netty 开始通过 unix socket 与 server 通信后,缓存队列以及 socket 通信再次占用 20M。
单线程低并发情况下,注入时 CPU 飙升,随后 Agent 初始再次导致一波尖刺,然后逐步稳定,对 CPU 负载影响微乎其微。
20个线程高并发情况下,状况类似。