Skip to content

Commit

Permalink
resolve conficts and release koom 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglianbao committed Sep 28, 2021
2 parents 0b3f4de + 3fad6f0 commit 5bfec10
Show file tree
Hide file tree
Showing 1,037 changed files with 22,505 additions and 14,207 deletions.
78 changes: 54 additions & 24 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
Expand All @@ -16,12 +16,12 @@ AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
Expand Down Expand Up @@ -50,54 +50,84 @@ BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 100
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
- Regex: '^<.*\.h>'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
Expand All @@ -111,13 +141,13 @@ SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
Standard: Auto
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
Expand Down
22 changes: 13 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# v1.0.4
First version with java-oom.

# v1.0.5
Enhancement
- Add custom root dir validity check.

Bug fix
- StripHprofHeapDumper bugfix.
# v2.0.0
New Features
- Add Native Leak Monitor
- Add Thread Leak Monitor

# v1.1.0
Enhancement
Expand All @@ -17,4 +12,13 @@ Bug fix
- Hardcode cacheDir path on unpredictable case.
- Add try-catch in abnormal start, delete abnormal json file.

# v1.0.5
Enhancement
- Add custom root dir validity check.

Bug fix
- StripHprofHeapDumper bugfix.

# v1.0.4
First version with java-oom.

112 changes: 17 additions & 95 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,101 +9,23 @@ An OOM killer on mobile platform by Kwai.

KOOM creates a mobile high performance online memory monitoring solution,which supplies a detailed report when OOM related problems are detected, and has solved a large number of OOM issues in the Kwai application. It's currently available on **Android**.

## Highlights

### High Performance
KOOM blocks the application less than 100ms by forking child process to dump hprof, it also has an efficient leak detect module and a fast hprof analysis module.

### High Reliability
KOOM's performance and stability have withstood the test of hundreds of millions of number of users and devices.

### Less Code
You just need to init KOOM, and it will take care of other things for you. Advanced custom config is also supported.


## Getting started

### First look of koom-demo

Try to run the koom-demo project first, and have a general understanding of the functionality provided by KOOM.

### Gradle dependencies

```gradle
dependencies {
implementation 'com.kwai.koom:java-oom:1.1.0'
}
```

### Quick Tutorial
You can setup KOOM as soon as you want to start memory monitoring, to setup on App startup, you can do like this:

```Java
public class KOOMApplication extends Application {

@Override
public void onCreate() {
super.onCreate();
KOOM.init(this);
}

}
```

### Java-oom Heap Report

Heap dump and analysis is executed automatically.

When the java heap is over the threshold by heap monitor, the heap dump and heap analysis is triggered then.

A java-oom heap report will be generated when heap analysis done.

Find a time to get the report manually.
```Java
public void getReportManually() {
File reportDir = new File(KOOM.getInstance().getReportDir());
for (File report : reportDir.listFiles()) {
// Upload the report or do something else.
}
}
```

Or set a listener to listen and get the report file status.
```Java
public void listenReportGenerateStatus() {
KOOM.getInstance().setHeapReportUploader(file -> {
// Upload the report or do something else.
// File is deleted automatically when callback is done by default.
});
}
```

### JAVA8 Requirements
```gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
```

### Custom Feature

See wiki [Advanced Custom Feature](https://github.com/KwaiAppTeam/KOOM/wiki/Advanced-Custom-Feature)

### Compatibility

See wiki [Compatibility](https://github.com/KwaiAppTeam/KOOM/wiki/Compatibility)

### FAQ

See wiki [FAQ](https://github.com/KwaiAppTeam/KOOM/wiki/FAQ)

## Performance
Randomly dump hprof of real users online, and the time consumed by normal dump and for dump blocking users is as follows:

<img src="https://github.com/KwaiAppTeam/KOOM/wiki/images/android_benchmark.png" width="500">

For more detail, please refer to [our benchmark](https://github.com/KwaiAppTeam/KOOM/wiki/android_benchmark).
With the increasing complexity of mobile terminal business logic and the gradual popularity of scenarios with high memory requirements such as 4K codec and AR magic watch, the OOM problem has become the number one problem in the stability management of the Kuaishou client.
In the daily version iteration process, OOM surges occasionally occur, and the online environment is very complicated. There are thousands of AB experiments. Pre-prevention and post-recovery cannot be achieved. Therefore, high-performance online memory monitoring solutions are urgently needed.

So how should OOM governance be built? At present, KOOM has the capability of monitoring leakage of Java Heap/Native Heap/Thread, and will build multi-dimensional and multi-business scenarios monitoring in the future.

## Features

### Java Leak Monitor
- The `koom-java-leak` module is used for Java Heap leak monitoring: it uses the Copy-on-write
mechanism to fork the child process dump Java Heap, which solves the problem.
The app freezes for a long time during the dump. For details, please refer to [here](./koom-java-leak/README.md)
### Native Leak Monitor
- The `koom-native-leak` module is a Native Heap leak monitoring solution: use the [Tracing garbage collection](https://en.wikipedia.org/wiki/Tracing_garbage_collection) mechanism to analyze the entire Native Heap, and directly output the leaked memory information like: size/Allocating stacks/etc.;
greatly reduces the cost of analyzing and solving memory leaks for business students. For details, please refer to [here](./koom-native-leak/README.md)
### Thread Leak Monitor
- The `koom-thread-leak` module is used for Thread leak monitoring: it hooks the life cycle
function of the thread, and periodically reports the leaked thread information. For details, please refer to [here](./koom-thread-leak/README.md)

## License
KOOM is under the Apache license 2.0. For details check out the [LICENSE](./LICENSE).
Expand Down
Loading

0 comments on commit 5bfec10

Please sign in to comment.