-
Notifications
You must be signed in to change notification settings - Fork 57
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
feat: support auto increase heap limit #217
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ed7dac4
fix: normal exit
hyj1991 b297364
feat: support auto increase heap limit
hyj1991 3cc5df3
feat: support auto incr heap limit
hyj1991 3499b99
feat: support auto increase heap limit size
hyj1991 dbba157
test: add test
hyj1991 f62d0ae
ignore windows
hyj1991 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "heap_limit.h" | ||
|
||
#include "configure-inl.h" | ||
#include "environment_data.h" | ||
#include "logger.h" | ||
|
||
namespace xprofiler { | ||
static const char module_type[] = "heap_limit"; | ||
|
||
size_t NearHeapLimitCallback(void* data, size_t current_heap_limit, | ||
size_t initial_heap_limit) { | ||
// const size_t heapdump_factor = 2; | ||
// size_t max_limit = (std::numeric_limits<size_t>::max)() / 4; | ||
// size_t increased_heap = | ||
// current_heap_limit + | ||
// std::min(max_limit, initial_heap_limit * heapdump_factor); | ||
|
||
int auto_incr_heap_limit_size = GetConfig<int>("auto_incr_heap_limit_size"); | ||
size_t increased_heap = | ||
current_heap_limit + auto_incr_heap_limit_size * 1024 * 1024; | ||
|
||
ThreadId thread_id = *static_cast<ThreadId*>(data); | ||
InfoT(module_type, thread_id, | ||
"current_heap_limit is %d, initial_heap_limit is %d, " | ||
"auto_incr_heap_limit_size is %d, increased_heap is " | ||
"%d.", | ||
current_heap_limit, initial_heap_limit, auto_incr_heap_limit_size, | ||
increased_heap); | ||
|
||
return increased_heap; | ||
} | ||
|
||
void AutoIncreaseHeapLimit(v8::Isolate* isolate) { | ||
EnvironmentData* env_data = EnvironmentData::GetCurrent(isolate); | ||
ThreadId thread_id = env_data->thread_id(); | ||
|
||
InfoT(module_type, thread_id, "auto increase heap limit hook."); | ||
isolate->AddNearHeapLimitCallback(NearHeapLimitCallback, | ||
static_cast<void*>(&thread_id)); | ||
} | ||
} // namespace xprofiler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef XPROFILER_SRC_HOOKS_HEAP_LIMIT_H | ||
#define XPROFILER_SRC_HOOKS_HEAP_LIMIT_H | ||
|
||
#include "nan.h" | ||
|
||
namespace xprofiler { | ||
void AutoIncreaseHeapLimit(v8::Isolate* isolate); | ||
} // namespace xprofiler | ||
|
||
#endif /* XPROFILER_SRC_HOOKS_HEAP_LIMIT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const { filterTestCaseByPlatform } = require('../utils'); | ||
|
||
const exitFatalErrorScriptPath = path.join(__dirname, '../scripts/fatal_error.js'); | ||
|
||
exports = module.exports = function () { | ||
const list = [ | ||
{ | ||
title: 'limit hook is valid', | ||
subTitle: 'auto increase heap limit is ok.', | ||
jspath: exitFatalErrorScriptPath, | ||
} | ||
]; | ||
|
||
return filterTestCaseByPlatform(list); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
持续监听么?要不要增加一个 maxLimitation 的限制?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不需要,limit 其实只是一个值,它除了让 v8 判断是否需要 OOM,不会反映到实际内存上的