Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu usage increases #259

Closed
binbin0325 opened this issue Jul 2, 2022 · 0 comments
Closed

cpu usage increases #259

binbin0325 opened this issue Jul 2, 2022 · 0 comments
Assignees
Labels
type/enhancement New feature or request
Milestone

Comments

@binbin0325
Copy link
Member

binbin0325 commented Jul 2, 2022

Issue Description

Type: bug report

Describe what happened (or what feature you want)

match rule log is printed before each injection,print log serializes the Model instance using Jackson。
this triggers class loading, which can cause a large number of threads to block when there are a large number of requests, leading to a significant increase in CPU usage

LOGGER.info("Match rule: {}", JsonUtil.writer().writeValueAsString(model));

匹配规则日志在每次注入之前打印,打印日志使用Jackson序列化Model实例。 这会触发类加载,当有大量请求时,这会导致大量线程阻塞,从而导致CPU使用率陡增(抖动一下)

java.lang.Thread.State: RUNNABLE
at java.lang.String.charAt(String.java:657)
at java.io.UnixFileSystem.normalize(UnixFileSystem.java:87)
at java.io.File.<init>(File.java:279)
at sun.net.www.protocol.file.Handler.openConnection(Handler.java:80)
- locked <0x00000000c01f2740> (a sun.net.www.protocol.file.Handler)
at sun.net.www.protocol.file.Handler.openConnection(Handler.java:72)
- locked <0x00000000c01f2740> (a sun.net.www.protocol.file.Handler)
at java.net.URL.openConnection(URL.java:979)
at sun.net.www.protocol.jar.JarFileFactory.getConnection(JarFileFactory.java:65)
at sun.net.www.protocol.jar.JarFileFactory.getPermission(JarFileFactory.java:154)
at sun.net.www.protocol.jar.JarFileFactory.getCachedJarFile(JarFileFactory.java:126)
at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:81)
- locked <0x00000000c00171f0> (a sun.net.www.protocol.jar.JarFileFactory)
at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:152)
at java.net.URL.openStream(URL.java:1045)
at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:1309)
......
at java.lang.reflect.Method.invoke(Method.java:498)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:689)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:755)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:755)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1516)
at com.fasterxml.jackson.databind.ObjectWriter._writeValueAndClose(ObjectWriter.java:1217)
at com.fasterxml.jackson.databind.ObjectWriter.writeValueAsString(ObjectWriter.java:1086)
at com.alibaba.chaosblade.exec.common.injection.Injector.inject(Injector.java:69)
at com.alibaba.chaosblade.exec.common.aop.AfterEnhancer.afterAdvice(AfterEnhancer.java:46)
at com.alibaba.chaosblade.exec.common.plugin.MethodEnhancer.afterAdvice(MethodEnhancer.java:47)
at com.alibaba.chaosblade.exec.bootstrap.jvmsandbox.AfterEventListener.onEvent(AfterEventListener.java:93)
at com.alibaba.jvm.sandbox.core.enhance.weaver.EventListenerHandler.handleEvent(EventListenerHandler.java:116)
at com.alibaba.jvm.sandbox.core.enhance.weaver.EventListenerHandler.handleOnEnd(EventListenerHandler.java:426)
at com.alibaba.jvm.sandbox.core.enhance.weaver.EventListenerHandler.handleOnReturn(EventListenerHandler.java:363)
at java.com.alibaba.jvm.sandbox.spy.Spy.spyMethodOnReturn(Spy.java:192)

sun.net.www.protocol.jar.JarFileFactory is blocking 181 threads.

Describe what you expected to happen

Jackson serialization is not used in the Model toString method
LOGGER.info("Match rule: {}", model);

How to reproduce it (as minimally and precisely as possible)

Tell us your environment

Anything else we need to know?

@binbin0325 binbin0325 changed the title CPU usage increases cpu usage increases Jul 2, 2022
@tiny-x tiny-x added this to the v1.7.2 milestone May 10, 2023
@tiny-x tiny-x added the type/enhancement New feature or request label May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants