[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-serviceability-dev
Subject:    =?UTF-8?B?UkZDOiBFeHRlbmQgRENtZChEaWFnbm9zdGljLUNvbW1hbmQpIGZyYW1ld29yayB0byBzdXBw?= =?UTF-8?B?b3J0I
From:       "Denghui Dong" <denghui.ddh () alibaba-inc ! com>
Date:       2021-10-25 8:37:07
Message-ID: 7f2df6ad-7d73-46ac-a23e-959fd6b4d4af.denghui.ddh () alibaba-inc ! com
[Download RAW message or body]

[Attachment #2 (text/plain)]

Hi there!

We'd like to discuss a proposal for extending the current DCmd framework to support \
Java level DCmd.

At present, DCmd only allows the VM to register commands, which can be called through \
jcmd or JMX. It would be beneficial if the user could create their own commands.

The idea of this extension originally came from our internal Java agent that detects \
the misusage of Unsafe API.

This agent can collect the call sites that allocate or free direct memory in the \
application(NMT could not do it IMO) to detect direct memory leaks.

In the beginning, it just prints all call sites, without any statistical function, \
it's hard to use.

So we plan to use a way similar to jeprof (from jemalloc) to generate a report file \
that aggregates all useful information.

During the implementation process, we found that we need a mechanism to notify the \
agent to generate reports.

The common practice is:
a) Register a service port, triggered by an HTTP request
b) Triggered by signal
c) Generate reports periodically, or when the process exits

But these three ways have certain problems.
For a) we need to introduce a network component, will increase the complexity of \
implementation For b) we cannot pass parameters
For c) some files that may never be used will be generated

Essentially, this question is how to notify the application to do a certain task, or \
in other words, how do we issue a command to the application. We believe that other \
Java developers will also encounter similar problems.  (And sometimes there may be \
multiple unrelated dependent components in a Java application that require such a \
mechanism.)

Naturally, we think that jcmd can already issue some commands registered in VM to the \
application, why can't we extend to the java level?

This feature will be very useful for some lightweight tools, just like the scenario \
we encountered, to notify the tools to perform certain operations.

In addition, this feature will also bring benefits to Java beginners.

For example, in the beginning, beginners may not use advanced log components, but \
they will also encounter the need to output debug logs. They may write code like \
this:

```
    if (debug) {
      System.out.println("...");
    }
```

If developers can easily control the value of debug, it's attractive.

Like this:

```
    Factory.register("MyApp.flipDebug", out -> debug = !debug);

    jcmd <pid> MyApp.flipDebug
```

For mainstream framework, we can apply this feature to trigger some common \
activities, such as health checks, graceful shutdown, and dynamic configuration \
updates, But to be honest, these frameworks are very mature and stable, and for \
compatibility purposes, it's hard to let them use this extension.

Comments welcome!

Thanks,
Denghui


[Attachment #3 (text/html)]

<div class="__aliyun_email_body_block"><div  style="clear:both;"><span  \
style="font-family:Microsoft Yahei;font-size:14.0px;color:#000000;">Hi&nbsp;there!<br \
><br >We'd&nbsp;like&nbsp;to&nbsp;discuss&nbsp;a&nbsp;proposal&nbsp;for&nbsp;extending \
> &nbsp;the&nbsp;current&nbsp;DCmd&nbsp;framework&nbsp;to&nbsp;support&nbsp;Java&nbsp;level&nbsp;DCmd.<br \
> ><br >At&nbsp;present,&nbsp;DCmd&nbsp;only&nbsp;allows&nbsp;the&nbsp;VM&nbsp;to&nbsp \
> > ;register&nbsp;commands,&nbsp;which&nbsp;can&nbsp;be&nbsp;called&nbsp;through&nbsp \
> > ;jcmd&nbsp;or&nbsp;JMX.&nbsp;It&nbsp;would&nbsp;be&nbsp;beneficial&nbsp;if&nbsp;the&nbsp;user&nbsp;could&nbsp;create&nbsp;their&nbsp;own&nbsp;commands.<br \
> > ><br >The&nbsp;idea&nbsp;of \
> > > this&nbsp;extension&nbsp;originally&nbsp;came&nbsp;from&nbsp;our&nbsp;internal&n \
> > > bsp;Java&nbsp;agent&nbsp;that&nbsp;detects&nbsp;the&nbsp;misusage&nbsp;of&nbsp;Unsafe&nbsp;API.<br \
> > > ><br >This&nbsp;agent&nbsp;can&nbsp;collect&nbsp;the&nbsp;call&nbsp;sites&nbsp;t \
> > > > hat&nbsp;allocate&nbsp;or&nbsp;free&nbsp;direct&nbsp;memory&nbsp;in&nbsp;the&n \
> > > > bsp;application(NMT&nbsp;could&nbsp;not&nbsp;do&nbsp;it&nbsp;IMO)&nbsp;to&nbsp;detect&nbsp;direct&nbsp;memory&nbsp;leaks.<br \
> > > > ><br >In&nbsp;the&nbsp;beginning,&nbsp;it&nbsp;just&nbsp;prints&nbsp;all&nbsp; \
> > > > > call&nbsp;sites,&nbsp;without&nbsp;any&nbsp;statistical&nbsp;function,&nbsp;it's&nbsp;hard&nbsp;to&nbsp;use.<br \
> > > > > ><br >So&nbsp;we&nbsp;plan&nbsp;to&nbsp;use&nbsp;a&nbsp;way&nbsp;similar&nbs \
> > > > > > p;to&nbsp;jeprof&nbsp;(from&nbsp;jemalloc)&nbsp;to&nbsp;generate&nbsp;a&nb \
> > > > > > sp;report&nbsp;file&nbsp;that&nbsp;aggregates&nbsp;all&nbsp;useful&nbsp;information.<br \
> > > > > > ><br >During&nbsp;the&nbsp;implementation&nbsp;process,&nbsp;we&nbsp;found \
> > > > > > > &nbsp;that&nbsp;we&nbsp;need&nbsp;a&nbsp;mechanism&nbsp;to&nbsp;notify&nbsp;the&nbsp;agent&nbsp;to&nbsp;generate&nbsp;reports.<br \
> > > > > > > ><br >The&nbsp;common&nbsp;practice&nbsp;is:<br \
> > > > > > > > >a)&nbsp;Register&nbsp;a&nbsp;service&nbsp;port,&nbsp;triggered&nbsp;by&nbsp;an&nbsp;HTTP&nbsp;request<br \
> > > > > > > > > >b)&nbsp;Triggered&nbsp;by&nbsp;signal<br \
> > > > > > > > > > >c)&nbsp;Generate&nbsp;reports&nbsp;periodically,&nbsp;or&nbsp;when&nbsp;the&nbsp;process&nbsp;exits<br \
> > > > > > > > > > > ><br \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \
> > > > > > > > > > > > \



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic