From 0acbbb0c2429b82a7c8b9b7640cb1ccf9d04c5c0 Mon Sep 17 00:00:00 2001 From: Shautvast Date: Fri, 4 Aug 2023 18:08:47 +0200 Subject: [PATCH] initial commit --- .gitignore | 3 + Cargo.lock | 607 +++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 12 + README.md | 21 ++ src/Filler.class | Bin 0 -> 615 bytes src/Filler.java | 14 ++ src/lib.rs | 46 ++++ src/main.rs | 65 +++++ stdout | 55 +++++ 9 files changed, 823 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 README.md create mode 100644 src/Filler.class create mode 100644 src/Filler.java create mode 100644 src/lib.rs create mode 100644 src/main.rs create mode 100644 stdout diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..db84685 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +target/ +*.iml +.idea/ \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..985ae02 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,607 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + +[[package]] +name = "bytemuck" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" + +[[package]] +name = "cc" +version = "1.0.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c6b2562119bf28c3439f7f02db99faf0aa1a8cdfe5772a2ee155d32227239f0" +dependencies = [ + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags 1.3.2", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "colored" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6" +dependencies = [ + "is-terminal", + "lazy_static", + "windows-sys 0.48.0", +] + +[[package]] +name = "console" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "unicode-width", + "windows-sys 0.45.0", +] + +[[package]] +name = "ctrlc" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a011bbe2c35ce9c1f143b7af6f94f29a167beb4cd1d29e6740ce836f723120e" +dependencies = [ + "nix", + "windows-sys 0.48.0", +] + +[[package]] +name = "drawille" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64e461c3f1e69d99372620640b3fd5f0309eeda2e26e4af69f6760c0e1df845" +dependencies = [ + "colored", + "fnv", +] + +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "errno" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" + +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi 0.3.2", + "rustix", + "windows-sys 0.48.0", +] + +[[package]] +name = "jop" +version = "0.1.0" +dependencies = [ + "console", + "ctrlc", + "once_cell", + "regex", + "rgb", + "textplots", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "linux-raw-sys" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "meval" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f79496a5651c8d57cd033c5add8ca7ee4e3d5f7587a4777484640d9cb60392d9" +dependencies = [ + "fnv", + "nom", +] + +[[package]] +name = "nix" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "static_assertions", +] + +[[package]] +name = "nom" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5b8c256fd9471521bcb84c3cdba98921497f1a331cbc15b8030fc63b82050ce" + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" + +[[package]] +name = "rgb" +version = "0.8.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20ec2d3e3fc7a92ced357df9cebd5a10b6fb2aa1ee797bf7e9ce2f17dffc8f59" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "rustix" +version = "0.38.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee020b1716f0a80e2ace9b03441a749e402e86712f15f16fe8a8f75afac732f" +dependencies = [ + "bitflags 2.3.3", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "structopt" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "textplots" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c771910e9d7e37d50f6d39f5ce4c4351fd797dcaed9a348e911877401af1b799" +dependencies = [ + "drawille", + "meval", + "rgb", + "structopt", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "unicode-ident" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.1", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..16b27cd --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "jop" +version = "0.1.0" +edition = "2021" + +[dependencies] +regex = "1.9" +once_cell = "1.18" +textplots = "0.8" +rgb = "0.8" +console = "0.15" +ctrlc = "3.4.0" \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8f3e1ae --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +**JOP** + +=>'java top' + +* Simple commandline utility that parses the output of java verbose gc and plots it in a graph +* Can be used for tailing the file, or on historic files +* Sample usage: + +```bash +java -verbose:gc -cp src Filler >outfile +``` +and: +```bash +jop outfile +``` +or: +```bash +cargo run outfile +``` + +* tested on jdk20/G1 collector \ No newline at end of file diff --git a/src/Filler.class b/src/Filler.class new file mode 100644 index 0000000000000000000000000000000000000000..4a99059bb59a6aaf2bb693490cfda3f54cb11e03 GIT binary patch literal 615 zcmZ8e%TB^j5Iwg=3vCsApyFFl11`jU3DIawOi&m2h`PE!LoSwLN-^<^T&oLTi67wi zxK`)3Myi{cJ7?z1nVkFn`SJ!}6RSEDs2XA>1~ABwYVm7cbhz6r9@biR-Demq30L@K z1~p$eNg$4d2Hk`KlX|NgoG=VkeO|xZ=T|@T@lxISF;=g3dS2ZoFKLevTDmT8#uC}B&_|KM(s0VN zR4JH)N^klxit~ibQD&3})*iv`0>T1C*_JVZMOqb(ZV+9f$$Mx|7<$H-g45ft4}ui* jNd~fnNEMRK{R-uRa{%KNnX^aCJV5&|rx9m4*tYTwaA$k* literal 0 HcmV?d00001 diff --git a/src/Filler.java b/src/Filler.java new file mode 100644 index 0000000..1d69b63 --- /dev/null +++ b/src/Filler.java @@ -0,0 +1,14 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +// sample program to mimic a memory leak +public class Filler { + static List someList = new ArrayList<>(); + + public static void main(String[] args) { + while (true) { + someList.add(UUID.randomUUID()); + } + } +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..3bc4861 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,46 @@ +use core::f32; +use std::str::FromStr; + +use once_cell::sync::Lazy; +use regex::Regex; + +#[derive(Debug)] +pub struct GcLine { + pub ts: f32, + pub used_before: usize, + pub used_after: usize, + pub total_memory: usize, + pub duration: f32, +} + +static GC: Lazy = Lazy::new(|| { + Regex::new(r#"\[(\d+\.\d+)(.)]\[info]\[gc].+?\s(\d+)(.)->(\d+)(.)\((\d+)(.)\)\s(\d+\.\d+)(.+)"#).unwrap() +}); + +pub fn parse(line_str: &str) -> Option { + if let Some(captures) = GC.captures(line_str) { + let _qunit_ts = captures.get(2).unwrap().as_str(); + let ts = f32::from_str(captures.get(1).unwrap().as_str()).unwrap(); + let unit_ub = parse_mem_unit(captures.get(4).unwrap().as_str()); + let used_before = usize::from_str(captures.get(3).unwrap().as_str()).unwrap() * unit_ub; + let unit_ua = parse_mem_unit(captures.get(6).unwrap().as_str()); + let used_after = usize::from_str(captures.get(5).unwrap().as_str()).unwrap() * unit_ua; + let unit_tm = parse_mem_unit(captures.get(8).unwrap().as_str()); + let total_memory = usize::from_str(captures.get(7).unwrap().as_str()).unwrap() * unit_tm; + let duration = f32::from_str(captures.get(9).unwrap().as_str()).unwrap(); + + Some(GcLine { ts, used_before, used_after, total_memory, duration }) + } else { + None + } +} + + +fn parse_mem_unit(value: &str) -> usize { + match value { + "K" => 1_024, + "M" => 1_048_576, + "G" => 1_073_741_824, + _ => 1 + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..9466f63 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,65 @@ +use std::env::args; +use std::io::BufReader; +use std::io::prelude::*; +use std::process::{Command, Stdio}; +use std::sync::{Arc, atomic::{AtomicBool, Ordering}}; +use std::thread::sleep; +use std::time::Duration; + +use textplots::{Chart, ColorPlot, Shape}; + +const RED: rgb::RGB8 = rgb::RGB8::new(0xFF, 0x00, 0x00); +const GREEN: rgb::RGB8 = rgb::RGB8::new(0x00, 0xFF, 0x00); + + +fn main() { + let filename = args().nth(1).expect("requires filename"); + + let should_run = Arc::new(AtomicBool::new(true)); + let should_run_ctrlc_ref = should_run.clone(); + + let term = console::Term::stdout(); + term.hide_cursor().unwrap(); + term.clear_screen().unwrap(); + + ctrlc::set_handler(move || { + should_run_ctrlc_ref + .as_ref() + .store(false, Ordering::Relaxed); + }).unwrap(); + + let mut cmd = Command::new("tail") + .args(&["-f", "-n", "+1", &filename]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::null()) + .spawn() + .unwrap(); + let mut reader = BufReader::new(cmd.stdout.take().unwrap()); + let mut line = String::new(); + + let mut points_before: Vec<(f32, f32)> = vec![]; + let mut points_after: Vec<(f32, f32)> = vec![]; + + while should_run.as_ref().load(Ordering::Acquire) { + reader.read_line(&mut line).unwrap(); + let parsed_line = jop::parse(&line); + if let Some(l) = parsed_line { + points_after.push((l.ts.clone(), l.used_after as f32)); + points_before.push((l.ts, l.used_before as f32)); + let max_ts = points_after.last().unwrap().0.clone(); + + term.move_cursor_to(0, 0).unwrap(); + Chart::new_with_y_range(200, 100, 0., max_ts, 0.0, l.total_memory as f32) + .linecolorplot(&Shape::Lines(&points_before), GREEN) + .linecolorplot(&Shape::Lines(&points_after), RED) + .display(); + } + + sleep(Duration::from_millis(100)); // pause for nice animation + line.clear(); + } + + let term = console::Term::stdout(); + term.show_cursor().unwrap(); +} \ No newline at end of file diff --git a/stdout b/stdout new file mode 100644 index 0000000..1b10abe --- /dev/null +++ b/stdout @@ -0,0 +1,55 @@ +[0.005s][info][gc] Using G1 +[0.103s][info][gc] GC(0) Pause Young (Normal) (G1 Evacuation Pause) 27M->10M(520M) 2.060ms +[0.141s][info][gc] GC(1) Pause Young (Normal) (G1 Evacuation Pause) 30M->15M(520M) 1.669ms +[0.261s][info][gc] GC(2) Pause Young (Normal) (G1 Evacuation Pause) 79M->36M(520M) 4.556ms +[0.346s][info][gc] GC(3) Pause Young (Normal) (G1 Evacuation Pause) 80M->55M(520M) 4.884ms +[0.473s][info][gc] GC(4) Pause Young (Normal) (G1 Evacuation Pause) 119M->78M(716M) 6.351ms +[0.651s][info][gc] GC(5) Pause Young (Normal) (G1 Evacuation Pause) 174M->112M(716M) 11.142ms +[0.854s][info][gc] GC(6) Pause Young (Normal) (G1 Evacuation Pause) 216M->153M(716M) 7.671ms +[1.218s][info][gc] GC(7) Pause Young (Normal) (G1 Evacuation Pause) 329M->217M(716M) 16.569ms +[1.699s][info][gc] GC(8) Pause Young (Normal) (G1 Evacuation Pause) 397M->266M(1048M) 11.305ms +[2.031s][info][gc] GC(9) Pause Young (Normal) (G1 Evacuation Pause) 462M->347M(1048M) 14.888ms +[2.732s][info][gc] GC(10) Pause Young (Normal) (G1 Evacuation Pause) 687M->482M(1048M) 27.605ms +[3.494s][info][gc] GC(11) Pause Young (Normal) (G1 Evacuation Pause) 782M->566M(1048M) 25.743ms +[4.171s][info][gc] GC(12) Pause Young (Concurrent Start) (G1 Humongous Allocation) 826M->634M(1264M) 13.245ms +[4.171s][info][gc] GC(13) Concurrent Mark Cycle +[4.235s][info][gc] GC(13) Pause Remark 740M->628M(1264M) 0.430ms +[4.268s][info][gc] GC(13) Pause Cleanup 644M->644M(1264M) 0.119ms +[4.270s][info][gc] GC(13) Concurrent Mark Cycle 98.885ms +[4.977s][info][gc] GC(14) Pause Young (Prepare Mixed) (G1 Evacuation Pause) 962M->699M(1264M) 22.188ms +[5.913s][info][gc] GC(15) Pause Young (Mixed) (G1 Evacuation Pause) 1031M->779M(1264M) 16.748ms +[6.298s][info][gc] GC(16) Pause Young (Concurrent Start) (G1 Humongous Allocation) 933M->833M(1264M) 11.029ms +[6.298s][info][gc] GC(17) Concurrent Mark Cycle +[6.393s][info][gc] GC(17) Pause Remark 991M->935M(1576M) 0.635ms +[6.443s][info][gc] GC(17) Pause Cleanup 959M->959M(1576M) 0.171ms +[6.444s][info][gc] GC(17) Concurrent Mark Cycle 146.046ms +[6.893s][info][gc] GC(18) Pause Young (Prepare Mixed) (G1 Evacuation Pause) 1169M->966M(1576M) 26.730ms +[7.811s][info][gc] GC(19) Pause Young (Mixed) (G1 Evacuation Pause) 1342M->1059M(1576M) 24.425ms +[8.576s][info][gc] GC(20) Pause Young (Concurrent Start) (G1 Evacuation Pause) 1387M->1149M(1576M) 11.655ms +[8.576s][info][gc] GC(21) Concurrent Mark Cycle +[8.706s][info][gc] GC(21) Pause Remark 1209M->1129M(1896M) 0.584ms +[8.760s][info][gc] GC(21) Pause Cleanup 1155M->1155M(1896M) 0.127ms +[8.761s][info][gc] GC(21) Concurrent Mark Cycle 185.106ms +[9.143s][info][gc] GC(22) Pause Young (Prepare Mixed) (G1 Evacuation Pause) 1337M->1143M(1896M) 17.451ms +[10.306s][info][gc] GC(23) Pause Young (Mixed) (G1 Evacuation Pause) 1783M->1431M(1956M) 30.252ms +[11.245s][info][gc] GC(24) Pause Young (Concurrent Start) (G1 Evacuation Pause) 1763M->1523M(1956M) 15.647ms +[11.245s][info][gc] GC(25) Concurrent Mark Cycle +[11.423s][info][gc] GC(25) Pause Remark 1605M->1485M(2488M) 0.706ms +[11.494s][info][gc] GC(25) Pause Cleanup 1519M->1519M(2488M) 0.129ms +[11.496s][info][gc] GC(25) Concurrent Mark Cycle 250.721ms +[11.781s][info][gc] GC(26) Pause Young (Prepare Mixed) (G1 Evacuation Pause) 1651M->1473M(2488M) 21.780ms +[13.126s][info][gc] GC(27) Pause Young (Mixed) (G1 Evacuation Pause) 2077M->1615M(2720M) 39.142ms +[13.739s][info][gc] GC(28) Pause Young (Concurrent Start) (G1 Humongous Allocation) 1899M->1695M(2720M) 24.405ms +[13.739s][info][gc] GC(29) Concurrent Undo Cycle +[13.739s][info][gc] GC(29) Concurrent Undo Cycle 0.099ms +[15.442s][info][gc] GC(30) Pause Young (Normal) (G1 Evacuation Pause) 2575M->2125M(2836M) 41.096ms +[16.660s][info][gc] GC(31) Pause Young (Concurrent Start) (G1 Evacuation Pause) 2577M->2251M(2836M) 25.461ms +[16.660s][info][gc] GC(32) Concurrent Mark Cycle +[16.932s][info][gc] GC(32) Pause Remark 2377M->2197M(3676M) 0.965ms +[17.039s][info][gc] GC(32) Pause Cleanup 2247M->2247M(3676M) 0.207ms +[17.043s][info][gc] GC(32) Concurrent Mark Cycle 383.074ms +[17.365s][info][gc] GC(33) Pause Young (Prepare Mixed) (G1 Evacuation Pause) 2395M->2161M(3676M) 25.485ms +[19.377s][info][gc] GC(34) Pause Young (Mixed) (G1 Evacuation Pause) 3073M->2379M(3676M) 68.276ms +[20.753s][info][gc] GC(35) Pause Young (Concurrent Start) (G1 Humongous Allocation) 2935M->2527M(3676M) 24.848ms +[20.753s][info][gc] GC(36) Concurrent Mark Cycle +[20.771s][info][gc] GC(36) Concurrent Mark Cycle 18.020ms