--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
To post to this group, send email to prometheus-developers@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/989bd868-29e3-4a4d-b746-5508ab0323bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
It would be great with performance-increase on this library. We struggle a bit with the scrape time the way it is now. One thing to be aware of during the design is that som jmx-beans may not have registered the first time the scraper runs, so that it should allow for more beans appearing after some time.
2018-01-23 5:29 GMT+01:00 Andrey Falko <ma3o...@gmail.com>:
Hi everyone,
While profiling some applications on I've noticed that the following regex shows up very high in my top functions list: https://github.com/prometheus/jmx_exporter/blob/master/collector/src/main/java/io/prometheus/jmx/JmxScraper.java#L177
To make matters worse, when my applications get highly loaded, the scrape time grows linearly. That regex is invoked on every scrape, slows down my systems, and causes delayed metrics feedback. The crux of the problem is that getKeyPropertyList is created on every scrape: https://github.com/prometheus/jmx_exporter/blob/master/collector/src/main/java/io/prometheus/jmx/JmxScraper.java#L161 . I'd like that to happen a lot less frequently.
I propose one of the following solutions:
1) Change the code to only run that function in the JmxCollector constructor and reloadConfig function (I happen to be sitting on this change locally)
2) Memoize getKeyPropertyList
3) Change yaml configuration so that users have the option to auto-discover and load all jmx mbeans and use reflection to find their properties (i.e. no regexes). That discovery would happen once at runtime. We'd still keep the current regex method and users can keep their old configs.
I'm more than happy to contribute one of these as a pull request and am open to other ideas as well.
Please advise on how I should proceed. Thank you!
Best regards,
Andrey Falko
--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsubscri...@googlegroups.com.
To post to this group, send email to prometheus-developers@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/989bd868-29e3-4a4d-b746-5508ab0323bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
To post to this group, send email to prometheus-developers@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CAGO7Ob0qAf%2Bdum_me9RCj5kNDYLvhhVEsmQZkaRXujj042n37g%40mail.gmail.com.
Hi everyone,
While profiling some applications on I've noticed that the following regex shows up very high in my top functions list: https://github.com/prometheus/jmx_exporter/blob/master/collector/src/main/java/io/prometheus/jmx/JmxScraper.java#L177
To make matters worse, when my applications get highly loaded, the scrape time grows linearly. That regex is invoked on every scrape, slows down my systems, and causes delayed metrics feedback. The crux of the problem is that getKeyPropertyList is created on every scrape: https://github.com/prometheus/jmx_exporter/blob/master/collector/src/main/java/io/prometheus/jmx/JmxScraper.java#L161 . I'd like that to happen a lot less frequently.
I propose one of the following solutions:
1) Change the code to only run that function in the JmxCollector constructor and reloadConfig function (I happen to be sitting on this change locally)
2) Memoize getKeyPropertyList
3) Change yaml configuration so that users have the option to auto-discover and load all jmx mbeans and use reflection to find their properties (i.e. no regexes). That discovery would happen once at runtime. We'd still keep the current regex method and users can keep their old configs.
I'm more than happy to contribute one of these as a pull request and am open to other ideas as well.
Please advise on how I should proceed. Thank you!
Best regards,
Andrey Falko
--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
To post to this group, send email to prometheus-developers@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/989bd868-29e3-4a4d-b746-5508ab0323bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Tue, Jan 23, 2018 at 2:51 AM, Brian Brazil
<brian.brazil@robustperception.io> wrote:
>>
>> I propose one of the following solutions:
>> 1) Change the code to only run that function in the JmxCollector
>> constructor and reloadConfig function (I happen to be sitting on this change
>> locally)
>
>
> mBeans can be (and often are) added after the exporter starts.
>
Good point, I didn't consider this. I can think of two ways to solve that:
(a) Add an option to yaml that allows users to specify a delay at
agent start up. The default would be something reasonable.
(b) Have an option where the mBeans are re-polled at regular
intervals. There is already a "reloadConfig" feature; perhaps a subset
of that can be run at a user-specified cadence w/ a reasonable
default.
I'm guessing that (b) would be better because it would cover the
dynamic mBean use-cases. However (a) could be used by non-dynamic use
cases to get maximum efficiency. Perhaps both (a) and (b) could be
implemented too.
>>
>> 2) Memoize getKeyPropertyList
>
>
> Some applications can have a lot of churn, do you have an idea to prevent
> this becoming a memory leak?
>
My initial assumption was that mBeans only need to be polled once, so
there would be logic to only run regexes if the keyPropertyList was
missing; so effectively after initial load, it would ignore any churn
and only have the initial mBeans loaded. In lieu of my assumption, the
only idea I have to avoid a leak is to split getKeyPropertyList to run
in another thread at its own cadence. However, that would essentially
look like what I described solution 1)(b) above.
>>
>> 3) Change yaml configuration so that users have the option to
>> auto-discover and load all jmx mbeans and use reflection to find their
>> properties (i.e. no regexes). That discovery would happen once at runtime.
>> We'd still keep the current regex method and users can keep their old
>> configs.
>
>
> Same issues as for 1), and would probably break something.
>
Yes, this would have the same issues as 1). (a) and (b) would apply to
this idea as well. In terms of breaking something, wouldn't that be
minimized by this being a required opt-in via config? All the previous
code would most remain untouched with this idea.
> Brian
>
On Tue, Jan 23, 2018 at 12:04 PM, Brian Brazil
<brian.brazil@robustperception.io> wrote:
>>
>> >>
>> >> 2) Memoize getKeyPropertyList
>> >
>> >
>> > Some applications can have a lot of churn, do you have an idea to
>> > prevent
>> > this becoming a memory leak?
>> >
>>
>> My initial assumption was that mBeans only need to be polled once, so
>> there would be logic to only run regexes if the keyPropertyList was
>> missing; so effectively after initial load, it would ignore any churn
>> and only have the initial mBeans loaded. In lieu of my assumption, the
>> only idea I have to avoid a leak is to split getKeyPropertyList to run
>> in another thread at its own cadence. However, that would essentially
>> look like what I described solution 1)(b) above.
>
>
> I don't see how another thread helps, we need up to date results
> synchronously with a scrape. This is a cache size question.
>
What if we keep track of the result of `beanConn.queryMBeans(name,
null)` as a hash value, when it changes, we run getKeyPropertyList
similar to how it is done today, else proceed with cache?
whitelistObjectNames is of a bound size, so we'd have a 1-to-1 mapping
of hashes to track.
As far as the cache of the results from
getKeyPropertyList, we'd have the following map:
HashMap<ObjectName, LinkedHashMap<String, String>>
If ObjectName is no longer present in the latest queryMBeans, then we
delete it from the map. This way, I think the amount of memory used by
the KeyProperty list map would follow the memory bounds of the mBeans
the application maintains.
The main problem with the JMX approach is that each bean call is reflected JMX which makes things impossibly slow. It's an RPC and there is ethernet latency on each call.
Usually that's pretty fast but most JMX uses use thousands and thousands of calls so performance falls quickly.There are components like jolokia:which then use REST for accessing the data. They're very fast, but they require an agent which means you can't really use a sidecar approach. You have to add the agent to the JVM via a command line and then you get a REST interface for pulling out the data.
--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
To post to this group, send email to prometheus-developers@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/8bdc33ef-70a0-4386-a9a2-042674fdf51e%40googlegroups.com.
On 24 January 2018 at 15:45, <bur...@scalefastr.io> wrote:The main problem with the JMX approach is that each bean call is reflected JMX which makes things impossibly slow. It's an RPC and there is ethernet latency on each call.There's no network latency when using a JMX agent, it's all inside a JVM.
