This is an archive of the discontinued LLVM Phabricator instance.

Only scan global sections containing data in LSan on darwin
ClosedPublic

Authored by fjricci on Jul 14 2017, 12:15 PM.

Details

Summary

__DATA segments on Darwin contain a large number of separate sections,
many of which cannot actually contain pointers, and contain const values or
objc metadata. Not scanning sections which cannot contain pointers significantly
improves performance.

On a medium-sized (~4000 files) internal project, I saw a speedup of about 30%
in standalone LSan's execution time (30% improvement in the time spent running
LSan, not the total program time).

Diff Detail

Repository
rL LLVM

Event Timeline

fjricci created this revision.Jul 14 2017, 12:15 PM
fjricci edited the summary of this revision. (Show Details)Jul 14 2017, 12:21 PM
fjricci edited the summary of this revision. (Show Details)
alekseyshl added inline comments.Jul 14 2017, 5:17 PM
lib/lsan/lsan_common_mac.cc
114 ↗(On Diff #106724)

Maybe define an array of those and iterate over it? That will allow us to add a CHECK that literal range name length is < kMaxSegName too.

lib/sanitizer_common/sanitizer_common.h
750 ↗(On Diff #106724)

else you need to initialize name anyway: this->name[0] = '\0';

750 ↗(On Diff #106724)

kMaxSegName -> ARRAY_SIZE(this->name)

lib/sanitizer_common/sanitizer_procmaps_mac.cc
203 ↗(On Diff #106724)

kMaxSegName -> ARRAY_SZIE(segment->name)

alekseyshl edited edge metadata.Jul 14 2017, 5:19 PM

Oh, and darin -> Darwin in the title

fjricci retitled this revision from Only scan global sections containing data in LSan on darin to Only scan global sections containing data in LSan on darwin.Jul 17 2017, 1:13 PM
fjricci updated this revision to Diff 106933.Jul 17 2017, 1:38 PM

Address comments

fjricci updated this revision to Diff 106937.Jul 17 2017, 1:44 PM

sec_names -> kGlobalVarSecNames

alekseyshl accepted this revision.Jul 17 2017, 3:33 PM
alekseyshl added inline comments.
lib/sanitizer_common/sanitizer_common.h
751 ↗(On Diff #106937)

Nit: maybe do it this way:

internal_strncpy(this->name, (name ? name : ""), ARRAY_SIZE(this->name));

This revision is now accepted and ready to land.Jul 17 2017, 3:33 PM
This revision was automatically updated to reflect the committed changes.
fjricci reopened this revision.Jul 20 2017, 10:34 AM

Dependency was reverted.

This revision is now accepted and ready to land.Jul 20 2017, 10:34 AM
fjricci updated this revision to Diff 107550.Jul 20 2017, 10:34 AM
fjricci edited the summary of this revision. (Show Details)

Use blacklist instead of whitelist to avoid false positives

fjricci requested review of this revision.Jul 20 2017, 10:36 AM
fjricci edited edge metadata.

This had to be reverted due to a masking error in its dependency which caused failures on 10.11 buildbots. Since it got reverted anyway, I took the opportunity to look into some false positives in swift, and found that they were caused by this patch. In order to prevent false positives, this now uses a blacklist of sections which definitely do not store pointers instead of a whitelist of sections which do (to avoid missing sections). Would appreciate a re-review.

fjricci updated this revision to Diff 107555.Jul 20 2017, 10:51 AM

clang-format

alekseyshl accepted this revision.Jul 20 2017, 10:55 AM

Makes sense!

This revision is now accepted and ready to land.Jul 20 2017, 10:55 AM
fjricci updated this revision to Diff 107930.Jul 24 2017, 10:58 AM

Rebase and account for new opaque data pointer

This revision was automatically updated to reflect the committed changes.