2 Star 12 Fork 6

PerfMa / xpocket

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

XPocket 用户文档

XPocket

XPocket 是PerfMa为终结性能问题而生的开源的插件容器,它是性能领域的乐高,将定位或者解决各种性能问题的常见的Linux命令,JDK工具,知名性能工具等适配成各种XPocket插件,并让它们可以相互联动一键解决特定的性能问题。 目前XPocket插件生态已经实现了HSDB、JDB、JConsole、Perf、Arthas等多个优秀的开源性能工具的插件化集成,现阶段主要侧重性能领域。

当你遇到以下类似问题时,XPocket可以帮助到你:

  1. 系统存在性能问题?
  2. 问题排查时一头雾水,无从下手?
  3. 使用一个新的工具,下载、文档、安装完就下班了?
  4. 好不容易用起来,只因输出不合理就又要去找新工具?
  5. 有些自己实现的小工具散落各处?
  6. 排查过的问题记不记住全凭脑子?

XPocket支持JDK 8+,支持Linux/Mac/Windows,采用命令行交互模式,提供丰富的 Tab 自动补全功能,支持管道操作。

插件开源生态

XPocket在线教程

XPocket官方网站

XPocket插件中心

快速开始

1.下载模拟程序,解压并运行

wget https://a.perfma.net/xpocket/download/XPocket-demo.tar.gz
tar -xvf  XPocket-demo.tar.gz
cd simulator
sh run.sh

2.下载xpocket,然后解压并运行(注:如果您当前的jdk版本大于jdk8,请使用xpocket_jdk9+.sh)

wget https://a.perfma.net/xpocket/download/XPocket.tar.gz
tar -xvf  XPocket.tar.gz
sh xpocket/xpocket_jdk8.sh

启动成功后如下所示 plugins

3.使用插件

1.查看插件列表

plugins

列表如下图所示 plugins

2.使用命令 use + pluginName 或者 use + pluginName@NameSpace 来使用插件,例

use jdb@JDK

4.切换插件

  • 查看插件列表
  • 使用 use + pluginName 或者 use + pluginName@NameSpace 来使用插件

5.获取帮助

利用help命令来获取更多帮助信息

  • 获取插件相关的帮助信息 : help + pluginName@NameSpace ,例如。
help jdb@JDK
  • 获取命令相关的帮助信息 : help + pluginName.commandName (如果已经切换到插件的操作空间下,可以直接使用 help + commandName 的方式),例如。
help jdb.cont
  • 切换到某个插件的操作空间下后,可以通过help命令查看当前插件的命令列表。

6.管道操作

场景:当前插件位于JConsole下,需要attach上我们的demo程序。

  • 常规操作(jps -> 获取demo程序的pid -> 使用attach命令attach目标进程)。

  • XPocket的管道操作只需一条命令即可(jps | grep demo | split -i 0 | attach),如下所示。 cd

7.退出插件

XPocket退出插件的方式很简单,只需要使用命令 cd 即可,cd命令可以退出当前插件,使得当前的操作空间回到系统层,如下图所示。 cd

8.退出XPocket

退出XPocket使用命令 quit 即可,如下图所示

quit

插件开发

详情请见开发者指南

现有插件

HSDB

简介

探索JVM的运行时数据,强大的JVM运行时状态分析工具(注:由于jdk8以上开始实施模块化,导致HSDB与其的运行机制不兼容)。

操作指南

Command-Name                   Command-Description
  hsdb                         hsdb [path of sa-jdi.jar] start hsdb command line
  
Tips:
  only support Windows platform

更多操作以及介绍请参考官方介绍

github

插件概况

JDB

简介

Java调试器(JDB)是Java类在命令行中调试程序的工具, 它实现了Java平台调试器体系结构, 它有助于使用Java调试接口(JDI)检测和修复Java程序中的错误。

操作指南

 Command-Name                   Command-Description
   jdb                          jdb <options> <class> <arguments>

 Tips:
 1.使用jdb -help获取详细帮助信息。
 2.使用jdb -listconnectors 获取当前支持的所有连接器。
 3.可以使用例如 jdb -connect com.sun.jdi.SocketAttach:hostname=127.0.0.1,port=8000 链接已经开启debug模式的java进程。
 4.使用jdb -classspath .:$CLASS_PATH 来启动jdb会话(windows上需要使用;分隔多个路径),然后通过stop in/at 设置断点并使用run启动一个可以被debug的java进程。
 5.启动jdb会话以后也可以通过help命令获取详细帮助。

更多操作以及介绍请参考官方介绍

github

插件概况

Perf

简介

Perf功能强大,它可以检测CPU性能计数器,跟踪点,kprobes和uprobes(动态跟踪),它能够进行轻量级分析。它也包含在Linux内核的tools / perf下,并且经常更新和增强, Perf最初是在Linux中使用性能计数器子系统的工具,并且进行了各种增强以添加跟踪功能,更详细的内容请参考Perf介绍

操作指南

  Command-Name                   Command-Description
  config                         Get and set variables in a configuration file.
  context-switches               process context-switches detail
  page-faults                    process page-faults detail
  lock                           Analyze lock events
  ftrace                         simple wrapper for kernel's ftrace functionality
  report                         Read perf.data (created by perf record) and display the profile
  analyze                        analyze process cpu usage
  record                         Run a command and record its profile into perf.data
  sched                          Tool to trace/measure scheduler properties (latencies)
  probe                          Define new dynamic tracepoints
  script                         Read perf.data (created by perf record) and display trace output
  version                        display the version of perf binary
  list                           List all symbolic event types
  annotate                       Read perf.data (created by perf record) and display annotated code
  create-java-perf-map           generate /tmp/perf-<pid>.map files for just-in-time(JIT)-compiled methods for use with perf
  stat                           Run a command and gather performance counter statistics
  proc-stat                      process performance stats

Perf插件集成了PerfMa自己增加的几条命令如:analyze命令: analyze -p [pid] (-p 指定进程采集热点) analyze -detail 查看进程CPU热点抓取结果 同时支持perf原生的命令和参数,并且针对java程序集成了perf-map-agent 这个工具,可以协助显示java的调用栈信息.具体使用方式见命令的帮助信息(如 help analyze)

github

插件概况

Arthas

简介

Arthas 是Alibaba开源的Java诊断工具,深受开发者喜爱,支持JDK 6+,支持Linux/Mac/Windows,采用命令行交互模式,同时提供丰富的 Tab 自动补全功能,进一步方便进行问题的定位和诊断。

操作指南

 Command-Name                   Command-Description
   attach                       attach [pid],attach a java process and start the Arthas server in localhost 3658,then connect it

 Tips:
 Arthas allows developers to troubleshoot production issues for Java applications without modifying code or restarting servers.

XPocket管控了Arthas在attach进程之前的输入输出,attach之后的具体使用请参考Arthas官方文档

github

插件概况

JConsole

简介

JConsole 是一个内置Java性能分析器,用于对JVM中内存,线程和类等的监控,这款工具的好处在于,占用系统资源少,而且结合Jstat,可以有效监控到java内存的变动情况,以及引起变动的原因。在项目追踪内存泄露问题时,很实用。

操作指南

 Command-Name                   Command-Description
   attach                       attach <local jvm pid>
  
 Tips:
 1.使用help获取帮助信息。
 2.更详细的功能,请attach一个进程后使用

注:插件化后的JConsole相比gui版本的JConsole在显示与操作上有所区别,但是数据的采集方式是一样的。

github

插件概况

VJMap

简介

分代版的jmap(新生代,存活区,老生代),是排查内存缓慢泄露,老生代增长过快原因的利器。因为jmap -histo PID 打印的是整个Heap的对象统计信息,而为了定位上面的问题,我们需要专门查看OldGen对象,和Survivor区大龄对象的工具。 vjmap的原始思路来源于R大的TBJMap ,翻新后支持JDK8,支持Survivor区大龄对象过滤。 注意:因为VJMap的原理,只支持CMS和ParallelGC,不支持G1。

操作指南

 Command-Name                   Command-Description
   vjmap                        vjmap 1.0.9 - prints per GC generation (Eden, Survivor, OldGen) object details of a given process.

 Tips:
 Usage: vjmap <options> <PID>
 Usage: vjmap <options> <executable java path> <coredump file path>
 Usage "help vjmap" show options info
 
 Example:
  打印整个堆中对象的统计信息,按对象的total size排序:
  vjmap -all PID > /tmp/histo.log
  
  推荐,打印老年代的对象统计信息,按对象的oldgen size排序,比-all快很多,暂时只支持CMS:
  vjmap -old PID > /tmp/histo-old.log
  
  推荐,打印Survivor区的对象统计信息,默认age>=3
  vjmap -sur PID > /tmp/histo-sur.log
  
  推荐,打印Survivor区的对象统计信息,查看age>=4的对象
  vjmap -sur:minage=4 PID > /tmp/histo-sur.log
  
  推荐,打印Survivor区的对象统计信息,单独查看age=4的对象:
  vjmap -sur:age=4 PID > /tmp/histo-sur.log
 

github

插件概况

Doraemon

简介

Doraemon是PerfMa开发的一款链接性能分析产品的体验工具,操作简单,功能强大,提供jvm参数分析,线程离线分析以及内存离线分析的功能

操作指南

  Command-Name                   Command-Description
    attach                         attach <local jvm pid>
    detach                         detach
    analyse                        use 'analyse <AbsolutePath>' to analyse memory dump file
    help                           command help info
    
  Tips:
  1.更丰富的操作,请先attach一个进程

插件概况

插件中心

更丰富的内容,建议您前往插件中心

Tips

  • sa-jdi.jar 主要用于支持插件VJMap的正常使用(注:由于jdk8以上开始实施模块化,导致VJMap的运行机制不兼容)。
  • 框架扩展开发的包依赖: com.perfma.xlab:xpocket-framework-spi:2.0.0-RELEASE

镜像仓库

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

XPocket 是PerfMa开源的工具容器框架,用于集成现有的或新开发的工具,统一用户UI与交互体验;使工具开发者只需要关注核心逻辑的开发,并且使XPocket的用户可以以相同的交互体验使用大量不同的工具。 目前XPocket生态已经实现了HSDB、JDB、JConsole、Perf、Arthas等多个优秀的开源工具的插件化集成,现阶段主要侧重性能领域。 同时XPocket建立了一套不同工具间进行数据和行为交互的机制,使得XPocket容器中的多个工具可以实现管道式的协同工作。 展开 收起
Java 等 3 种语言
Apache-2.0
取消

发行版 (3)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/perfma/xpocket.git
git@gitee.com:perfma/xpocket.git
perfma
xpocket
xpocket
main

搜索帮助