Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

scripts: disable tcmalloc to support valgrind memcheck #170

Merged
merged 6 commits into from
Oct 16, 2018

Conversation

neverchanje
Copy link
Contributor

@neverchanje neverchanje commented Oct 12, 2018

Now we are able to use:

$ ./run.sh build --disable_gperf 

to disable tcmalloc, and we can then perform valgrind memcheck in builder/bin/<test_name>, like

$ cd builder/bin/dsn_nfs_test
$ valgrind --tool=memcheck ./dsn_nfs_test config.ini
==21639== Memcheck, a memory error detector
==21639== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==21639== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==21639== Command: ./dsn_nfs_test config.ini
==21639== 
service_api_c.cpp:526:run():dsn_runtime_init_time_ms = 1539334013034 (2018-10-12 16:46:53.034)
W2018-10-12 16:46:53.443 (1539334013443832197 5487) unknown.io-thrd.21639: [mimic] network server started at port 20101, channel = RPC_CHANNEL_TCP, ...
W2018-10-12 16:46:53.450 (1539334013450292365 5487) unknown.io-thrd.21639: [mimic] network server started at port 20101, channel = RPC_CHANNEL_UDP, ...
W2018-10-12 16:46:53.466 (1539334013466403987 5491)  mimic.io-thrd.21649: You may need priviledge to set thread priority. errno = 1
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from nfs
[ RUN      ] nfs.basic
[       OK ] nfs.basic (378 ms)
[----------] 1 test from nfs (387 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (420 ms total)
[  PASSED  ] 1 test.
==21639== 
==21639== HEAP SUMMARY:
==21639==     in use at exit: 5,825,683 bytes in 1,342 blocks
==21639==   total heap usage: 8,286 allocs, 6,944 frees, 6,482,819 bytes allocated
==21639== 
==21639== LEAK SUMMARY:
==21639==    definitely lost: 104 bytes in 5 blocks
==21639==    indirectly lost: 384 bytes in 4 blocks
==21639==      possibly lost: 46,518 bytes in 805 blocks
==21639==    still reachable: 5,778,677 bytes in 528 blocks
==21639==         suppressed: 0 bytes in 0 blocks
==21639== Rerun with --leak-check=full to see details of leaked memory
==21639== 
==21639== For counts of detected and suppressed errors, rerun with: -v
==21639== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

@@ -79,6 +79,14 @@ else
echo "NO_TEST=NO"
fi

# valgrind can not work together with gpertools
if [ "$WITH_VALGRIND" == "YES" ]
Copy link
Contributor

Choose a reason for hiding this comment

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

为什么不直接把命令叫做ENABLE_GPERF,偏要叫做WITH_VALGRIND?

Copy link
Contributor Author

@neverchanje neverchanje Oct 12, 2018

Choose a reason for hiding this comment

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

原本是准备叫 --disable_gperf,但是我感觉作为 shell 工具,叫 --with_valgrind 更易用更直观,当然你觉得名字一致比较重要就可以改

Copy link
Contributor

@shengofsun shengofsun Oct 12, 2018

Choose a reason for hiding this comment

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

我觉得名字一致比较重要:用了某个命令,到底干了什么事情,这样比较直观的。另一个原因是,我想禁用gperf的原因,不一定是要开valgrind, 也可能就是想单纯的对比下性能。

你可以在--disable_gperf的help里面,或者一些文档里面说明"you may want to use this option when you want to run valgrind"之类的。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的

Copy link
Contributor

Choose a reason for hiding this comment

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

另外我看你把format子命令删了。这样的话,也可以顺手把scripts/linux/format.sh也一起删了。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已删

shengofsun
shengofsun previously approved these changes Oct 12, 2018
shengofsun
shengofsun previously approved these changes Oct 15, 2018
@neverchanje neverchanje mentioned this pull request Oct 15, 2018
9 tasks
run.sh Outdated
@@ -61,6 +51,7 @@ function usage_build()
echo " --enable_gcov generate gcov code coverage report, default no"
echo " -v|--verbose build in verbose mode, default no"
echo " --notest build without building unit tests, default no"
echo " --disable_gperf build without gperftools, default no"
Copy link
Member

Choose a reason for hiding this comment

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

build without gperftools (to bring in tcmalloc)

@neverchanje neverchanje merged commit 06b106e into XiaoMi:master Oct 16, 2018
vagetablechicken pushed a commit to vagetablechicken/rdsn that referenced this pull request Nov 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants