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

src, build: Enable Intel Vtune profiling for JavaScript #3785

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ parser.add_option("--fully-static",
help="Generate an executable without external dynamic libraries. This "
"will not work on OSX when using default compilation environment")

parser.add_option("--enable-vtune-profiling",
action="store_true",
dest="enable_vtune_profiling",
help="Enable profiling support for Intel Vtune profiler to profile"
"JavaScript code executed in nodejs. This feature is only available "
"for ia32, x32 or x64 platform.")


parser.add_option("--link-module",
action="append",
dest="linked_module",
Expand Down Expand Up @@ -679,6 +687,15 @@ def configure_node(o):
o['variables']['node_core_target_name'] = 'node_base'
o['variables']['node_target_type'] = 'static_library'

if target_arch in ('x86', 'x64', 'ia32', 'x32'):
o['variables']['node_enable_v8_vtunejit'] = b(options.enable_vtune_profiling)
elif options.enable_vtune_profiling:
raise Exception(
'vtune profiler for JavaScript is only supported on x86, x32 or x64 '
'platform.')
else:
o['variables']['node_enable_v8_vtunejit'] = 'false'

if flavor in ('solaris', 'mac', 'linux', 'freebsd'):
use_dtrace = not options.without_dtrace
# Don't enable by default on linux and freebsd
Expand Down
8 changes: 8 additions & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'node_use_openssl%': 'true',
'node_shared_openssl%': 'false',
'node_v8_options%': '',
'node_enable_v8_vtunejit%': 'false',
'node_target_type%': 'executable',
'node_core_target_name%': 'node',
'library_files': [
Expand Down Expand Up @@ -221,6 +222,13 @@
'defines': [ 'NODE_HAVE_SMALL_ICU=1' ],
}]],
}],
[ 'node_enable_v8_vtunejit=="true" and (target_arch=="x64" or \
target_arch=="ia32" or target_arch=="x32")', {
'defines': [ 'NODE_ENABLE_VTUNE_PROFILING' ],
'dependencies': [
'deps/v8/src/third_party/vtune/v8vtune.gyp:v8_vtune'
],
}],
[ 'node_use_openssl=="true"', {
'defines': [ 'HAVE_OPENSSL=1' ],
'sources': [
Expand Down
7 changes: 7 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
#include "v8-profiler.h"
#include "zlib.h"

#ifdef NODE_ENABLE_VTUNE_PROFILING
#include "../deps/v8/src/third_party/vtune/v8-vtune.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the linter was complaining about this line. Can you run make lint and add a // NOLINT comment if it's unhappy?

#endif

#include <errno.h>
#include <limits.h> // PATH_MAX
#include <locale.h>
Expand Down Expand Up @@ -4025,6 +4029,9 @@ static void StartNodeInstance(void* arg) {
Isolate::CreateParams params;
ArrayBufferAllocator* array_buffer_allocator = new ArrayBufferAllocator();
params.array_buffer_allocator = array_buffer_allocator;
#ifdef NODE_ENABLE_VTUNE_PROFILING
params.code_event_handler = vTune::GetVtuneCodeEventHandler();
#endif
Isolate* isolate = Isolate::New(params);
if (track_heap_objects) {
isolate->GetHeapProfiler()->StartTrackingHeapObjects(true);
Expand Down
7 changes: 5 additions & 2 deletions vcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ set i18n_arg=
set download_arg=
set release_urls_arg=
set build_release=
set enable_vtune_profiling=

:next-arg
if "%1"=="" goto args-done
Expand Down Expand Up @@ -71,6 +72,7 @@ if /i "%1"=="full-icu" set i18n_arg=%1&goto arg-ok
if /i "%1"=="intl-none" set i18n_arg=%1&goto arg-ok
if /i "%1"=="download-all" set download_arg="--download=all"&goto arg-ok
if /i "%1"=="ignore-flaky" set test_args=%test_args% --flaky-tests=dontcare&goto arg-ok
if /i "%1"=="enable-vtune" set enable_vtune_profiling="--enable-vtune-profiling"&goto arg-ok

echo Warning: ignoring invalid command line option `%1`.

Expand Down Expand Up @@ -168,7 +170,7 @@ goto run
if defined noprojgen goto msbuild

@rem Generate the VS project.
python configure %download_arg% %i18n_arg% %debug_arg% %snapshot_arg% %noetw_arg% %noperfctr_arg% --dest-cpu=%target_arch% --tag=%TAG%
python configure %download_arg% %i18n_arg% %debug_arg% %snapshot_arg% %noetw_arg% %noperfctr_arg% %enable_vtune_profiling% --dest-cpu=%target_arch% --tag=%TAG%
if errorlevel 1 goto create-msvs-files-failed
if not exist node.sln goto create-msvs-files-failed
echo Project files generated.
Expand Down Expand Up @@ -259,13 +261,14 @@ echo Failed to create vc project files.
goto exit

:help
echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/intl-none] [nobuild] [nosign] [x86/x64] [download-all]
echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/intl-none] [nobuild] [nosign] [x86/x64] [download-all] [enable-vtune]
echo Examples:
echo vcbuild.bat : builds release build
echo vcbuild.bat debug : builds debug build
echo vcbuild.bat release msi : builds release build and MSI installer package
echo vcbuild.bat test : builds debug build and runs tests
echo vcbuild.bat build-release : builds the release distribution as used by nodejs.org
echo vcbuild.bat enable-vtune : builds nodejs with Intel Vtune profiling support to profile JavaScript
goto exit

:exit
Expand Down