infer icon indicating copy to clipboard operation
infer copied to clipboard

infer capture takes a pretty long time in my ios project

Open WishQi opened this issue 8 years ago • 11 comments

I am trying to integrate infer into the gitlab-CI. But the "infer capture" phase takes a really long time, which makes it impossible to run infer in CI. The test time is:

build phase time used : 567 seconds
xcpretty phase time used : 14 seconds
infer capture phase time used : 6422 seconds

And the commands are just like this:

xcodebuild -workspace $WORKSPACE -configuration $CONFIGURATION -scheme $SCHEME -sdk $SDK -arch armv7 COMPILER_INDEX_STORE_ENABLE=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= clean build | tee xcodebuild.log

xcpretty -r json-compilation-database -o compile_commands.json < xcodebuild.log

infer capture --keep-going --skip-analysis-in-path Pods --compilation-database-escaped compile_commands.json

Actually, in the recommended CI flow, infer capture with normal mode instead of incremental model is the first step. Is there any method to make it faster?

WishQi avatar Aug 31 '18 09:08 WishQi

When I use the compile_commands.json, actually "--skip-analysis-in-path" is useless.

WishQi avatar Sep 02 '18 10:09 WishQi

The "infer capture" command seems not to continue. The last command in logs is:

[98031][      debug] *** Beginning capture of file /Users/douyin_ios/Aweme/Aweme/Pods/WCDB/objc/WCDB/interface/chaincall/WCTSelectBase.mm ***
[98031][      debug] 
[98031][      debug]  Skip the analysis of source file /Users/douyin_ios/Aweme/Aweme/Pods/WCDB/objc/WCDB/interface/chaincall/WCTSelectBase.mm
[98031][      debug] 
[98031][      debug] 
[98031][ extern err] Error: the following clang command did not run successfully:
[98031][ extern err]     /usr/local/Cellar/infer/0.15.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang
[98031][ extern err]     @/var/folders/vv/vw4sr3qn5g1cmqvwn08cs1800000gn/T/clang_command_.tmp.5b7b6d.txt
[98031][ extern err]   ++Contents of '/var/folders/vv/vw4sr3qn5g1cmqvwn08cs1800000gn/T/clang_command_.tmp.5b7b6d.txt':
[98031][ extern err]     "-cc1" "-triple" "thumbv7-apple-ios7.0.0" "-fsyntax-only" "-disable-free"
[98031][ extern err]     "-disable-llvm-verifier" "-discard-value-names" "-main-file-name"
[98031][ extern err]     "WCTSelectBase.mm" "-mrelocation-model" "pic" "-pic-level" "2"
[98031][ extern err]     "-mthread-model" "posix" "-mdisable-fp-elim" "-masm-verbose"
[98031][ extern err]     "-faligned-alloc-unavailable" "-target-cpu" "generic" "-target-feature"
[98031][ extern err]     "+soft-float-abi" "-target-abi" "apcs-gnu" "-mfloat-abi" "soft"
[98031][ extern err]     "-fallow-half-arguments-and-returns" "-dwarf-column-info"
[98031][ extern err]     "-debug-info-kind=standalone" "-dwarf-version=2" "-debugger-tuning=lldb"
[98031][ extern err]     "-target-linker-version" "351.8" "-resource-dir"
[98031][ extern err]     "/usr/local/Cellar/infer/0.15.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/7.0.0"
[98031][ extern err]     "-dependency-file"
[98031][ extern err]     "/Users/douyin_ios/Library/Developer/Xcode/DerivedData/Aweme-daxlvanriyclfucgbzlsyhppryxc/Build/Intermediates.noindex/Pods.build/AwemeInhouseRelease-iphoneos/WCDB.build/Objects-normal/armv7/WCTSelectBase.d"
[98031][ extern err]     "-MT" "dependencies" "-isysroot"
[98031][ extern err]     "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk"
[98031][ extern err]     "-iquote"
[98031][ extern err]     "/Users/douyin_ios/Library/Developer/Xcode/DerivedData/Aweme-daxlvanriyclfucgbzlsyhppryxc/Build/Intermediates.noindex/Pods.build/AwemeInhouseRelease-iphoneos/WCDB.build/WCDB-generated-files.hmap"
[98031][ extern err]     "-iquote"
[98031][ extern err]     "/Users/douyin_ios/Library/Developer/Xcode/DerivedData/Aweme-daxlvanriyclfucgbzlsyhppryxc/Build/Intermediates.noindex/Pods.build/AwemeInhouseRelease-iphoneos/WCDB.build/WCDB-project-headers.hmap"
[98031][ extern err]     "-include" "/Users/douyin_ios/Aweme/Aweme/AWELive/PrefixHeader.pch"
[98031][ extern err]     "-include"
[98031][ extern err]     "/usr/local/Cellar/infer/0.15.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
[98031][ extern err]     "-D" "POD_CONFIGURATION_AWEME_INHOUSE_RELEASE=1" "-D" "COCOAPODS=1" "-D"
[98031][ extern err]     "POD_CONFIGURATION_AWEME_INHOUSE_RELEASE=1" "-D"
[98031][ extern err]     "WCDB_BUILTIN_COLUMN_CODING" "-D" "WCDB_COCOAPODS" "-D"
[98031][ extern err]     "POD_CONFIGURATION_AWEME_INHOUSE_RELEASE=1" "-D"
[98031][ extern err]     "WCDB_BUILTIN_COLUMN_CODING" "-D" "WCDB_COCOAPODS" "-D"
[98031][ extern err]     "POD_CONFIGURATION_AWEME_INHOUSE_RELEASE=1" "-D" "SQLITE_ENABLE_FTS3"
[98031][ extern err]     "-D" "SQLITE_ENABLE_FTS3_PARENTHESIS" "-D" "SQLITE_ENABLE_API_ARMOR" "-D"
[98031][ extern err]     "SQLITE_OMIT_BUILTIN_TEST" "-D" "SQLITE_OMIT_AUTORESET" "-D"
[98031][ extern err]     "SQLITE_ENABLE_UPDATE_DELETE_LIMIT" "-D" "SQLITE_ENABLE_RTREE" "-D"
[98031][ extern err]     "SQLITE_ENABLE_LOCKING_STYLE=1" "-D" "SQLITE_SYSTEM_MALLOC" "-D"
[98031][ extern err]     "SQLITE_OMIT_LOAD_EXTENSION" "-D" "SQLITE_CORE" "-D"
[98031][ extern err]     "SQLITE_THREADSAFE=2" "-D" "SQLITE_DEFAULT_CACHE_SIZE=250" "-D"
[98031][ extern err]     "SQLITE_DEFAULT_CKPTFULLFSYNC=1" "-D" "SQLITE_DEFAULT_PAGE_SIZE=4096"
[98031][ extern err]     "-D" "SQLITE_OMIT_SHARED_CACHE" "-D" "SQLITE_HAS_CODEC" "-D"
[98031][ extern err]     "SQLCIPHER_CRYPTO_CC" "-D" "USE_PREAD=1" "-D" "SQLITE_TEMP_STORE=2" "-D"
[98031][ extern err]     "SQLCIPHER_PREPROCESSED" "-D" "HAVE_USLEEP" "-D"
[98031][ extern err]     "SQLITE_MALLOC_SOFT_LIMIT=0" "-D" "SQLITE_WCDB_SIGNAL_RETRY=1" "-D"
[98031][ extern err]     "SQLITE_DEFAULT_MEMSTATUS=0" "-D" "SQLITE_ENABLE_COLUMN_METADATA" "-D"
[98031][ extern err]     "SQLITE_DEFAULT_WAL_SYNCHRONOUS=1" "-D" "SQLITE_LIKE_DOESNT_MATCH_BLOBS"
[98031][ extern err]     "-D" "SQLITE_MAX_EXPR_DEPTH=0" "-D" "SQLITE_OMIT_DEPRECATED" "-D"
[98031][ extern err]     "SQLITE_OMIT_PROGRESS_CALLBACK" "-D" "SQLITE_OMIT_SHARED_CACHE" "-D"
[98031][ extern err]     "OMIT_CONSTTIME_MEM" "-D" "OMIT_MEMLOCK" "-D"
[98031][ extern err]     "SQLITE_ENABLE_FTS3_TOKENIZER" "-D" "NS_BLOCK_ASSERTIONS=1" "-D"
[98031][ extern err]     "OBJC_OLD_DISPATCH_PROTOTYPES=0" "-I"
[98031][ extern err]     "/Users/douyin_ios/Library/Developer/Xcode/DerivedData/Aweme-daxlvanriyclfucgbzlsyhppryxc/Build/Intermediates.noindex/Pods.build/AwemeInhouseRelease-iphoneos/WCDB.build/WCDB-own-target-headers.hmap"
[98031][ extern err]     "-I"
[98031][ extern err]     "/Users/douyin_ios/Library/Developer/Xcode/DerivedData/Aweme-daxlvanriyclfucgbzlsyhppryxc/Build/Intermediates.noindex/Pods.build/AwemeInhouseRelease-iphoneos/WCDB.build/WCDB-all-target-headers.hmap"
[98031][ extern err]     "-I"
[98031][ extern err]     "/Users/douyin_ios/Library/Developer/Xcode/DerivedData/Aweme-daxlvanriyclfucgbzlsyhppryxc/Build/Products/AwemeInhouseRelease-iphoneos/WCDB/include"
[98031][ extern err]     "-I" "/Users/douyin_ios/Aweme/Aweme/Pods/Headers/Private" "-I"
[98031][ extern err]     "/Users/douyin_ios/Aweme/Aweme/Pods/Headers/Private/WCDB" "-I"
[98031][ extern err]     "/Users/douyin_ios/Aweme/Aweme/Pods/Headers/Public" "-I"
[98031][ extern err]     "/Users/douyin_ios/Aweme/Aweme/Pods/Headers/Public/WCDB" "-I"
[98031][ extern err]     "/Users/douyin_ios/Aweme/Aweme/Pods/WCDB" "-I"
[98031][ extern err]     "/Users/douyin_ios/Library/Developer/Xcode/DerivedData/Aweme-daxlvanriyclfucgbzlsyhppryxc/Build/Intermediates.noindex/Pods.build/AwemeInhouseRelease-iphoneos/WCDB.build/DerivedSources/armv7"
[98031][ extern err]     "-I"
[98031][ extern err]     "/Users/douyin_ios/Library/Developer/Xcode/DerivedData/Aweme-daxlvanriyclfucgbzlsyhppryxc/Build/Intermediates.noindex/Pods.build/AwemeInhouseRelease-iphoneos/WCDB.build/DerivedSources"
[98031][ extern err]     "-F/Users/douyin_ios/Library/Developer/Xcode/DerivedData/Aweme-daxlvanriyclfucgbzlsyhppryxc/Build/Products/AwemeInhouseRelease-iphoneos/WCDB"
[98031][ extern err]     "-stdlib=libc++" "-Os" "-Wnon-modular-include-in-framework-module"
[98031][ extern err]     "-Werror=non-modular-include-in-framework-module" "-Wno-trigraphs"
[98031][ extern err]     "-Wno-missing-field-initializers" "-Wno-missing-prototypes"
[98031][ extern err]     "-Werror=return-type" "-Wdocumentation" "-Wno-implicit-atomic-properties"
[98031][ extern err]     "-Werror=deprecated-objc-isa-usage" "-Werror=objc-root-class"
[98031][ extern err]     "-Wno-arc-repeated-use-of-weak" "-Wimplicit-retain-self"
[98031][ extern err]     "-Wno-non-virtual-dtor" "-Wno-overloaded-virtual"
[98031][ extern err]     "-Wno-exit-time-destructors" "-Wduplicate-method-match"
[98031][ extern err]     "-Wno-missing-braces" "-Wparentheses" "-Wswitch" "-Wno-unused-function"
[98031][ extern err]     "-Wno-unused-label" "-Wno-unused-parameter" "-Wno-unused-variable"
[98031][ extern err]     "-Wunused-value" "-Wempty-body" "-Wuninitialized"
[98031][ extern err]     "-Wconditional-uninitialized" "-Wno-unknown-pragmas" "-Wno-shadow"
[98031][ extern err]     "-Wno-four-char-constants" "-Wno-conversion" "-Wconstant-conversion"
[98031][ extern err]     "-Wint-conversion" "-Wbool-conversion" "-Wenum-conversion"
[98031][ extern err]     "-Wno-float-conversion" "-Wnon-literal-null-conversion"
[98031][ extern err]     "-Wobjc-literal-conversion" "-Wno-shorten-64-to-32" "-Wno-newline-eof"
[98031][ extern err]     "-Wno-selector" "-Wno-strict-selector-match" "-Wundeclared-selector"
[98031][ extern err]     "-Wdeprecated-implementations" "-Wno-c++11-extensions" "-Wprotocol"
[98031][ extern err]     "-Wdeprecated-declarations" "-Winvalid-offsetof" "-Wno-sign-conversion"
[98031][ extern err]     "-Winfinite-recursion" "-Wmove" "-Wcomma" "-Wblock-capture-autoreleasing"
[98031][ extern err]     "-Wstrict-prototypes" "-Wrange-loop-analysis" "-Wunguarded-availability"
[98031][ extern err]     "-Wno-ignored-optimization-argument" "-Wno-everything" "-w"
[98031][ extern err]     "-std=gnu++11" "-fdeprecated-macro" "-fdebug-compilation-dir"
[98031][ extern err]     "/Users/douyin_ios/Aweme/Aweme/Pods" "-ferror-limit" "19"
[98031][ extern err]     "-fmacro-backtrace-limit" "0" "-fmessage-length" "0" "-stack-protector"
[98031][ extern err]     "1" "-fblocks" "-fencode-extended-block-signature"
[98031][ extern err]     "-fmodules-prune-interval=86400" "-fmodules-prune-after=345600"
[98031][ extern err]     "-fbuild-session-timestamp=1535945000000000000"
[98031][ extern err]     "-fmodules-validate-once-per-build-session" "-fobjc-runtime=ios-7.0.0"
[98031][ extern err]     "-fobjc-arc" "-fobjc-arc-cxxlib=libc++" "-fobjc-arc-exceptions"
[98031][ extern err]     "-fobjc-weak" "-fobjc-exceptions" "-fcxx-exceptions" "-fexceptions"
[98031][ extern err]     "-fsjlj-exceptions" "-fpascal-strings" "-fmax-type-align=16"
[98031][ extern err]     "-fno-common" "-fdiagnostics-show-option"
[98031][ extern err]     "-fdiagnostics-show-note-include-stack" "-vectorize-loops"
[98031][ extern err]     "-vectorize-slp" "-serialize-diagnostic-file"
[98031][ extern err]     "/Users/douyin_ios/Library/Developer/Xcode/DerivedData/Aweme-daxlvanriyclfucgbzlsyhppryxc/Build/Intermediates.noindex/Pods.build/AwemeInhouseRelease-iphoneos/WCDB.build/Objects-normal/armv7/WCTSelectBase.dia"
[98031][ extern err]     "-x" "objective-c++"
[98031][ extern err]     "/Users/douyin_ios/Aweme/Aweme/Pods/WCDB/objc/WCDB/interface/chaincall/WCTSelectBase.mm"
[98031][ extern err]     "-include"
[98031][ extern err]     "/usr/local/Cellar/infer/0.15.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
[98031][ extern err]     "-Wno-everything"
[98031][ extern err]   
[98031][ extern err] 
[98031][environment] Infer log identifier is 
!

And then it will not continue until for a long time.

WishQi avatar Sep 03 '18 04:09 WishQi

Thanks for the report @WishQi. Infer capture is not expected to take much more than the compilation time (say, less than 2x time) so there's probably something wrong here.

When I use the compile_commands.json, actually "--skip-analysis-in-path" is useless.

I'll look into that first.

jvillard avatar Sep 03 '18 08:09 jvillard

@jvillard Yeah, there must be something wrong but I have no idea about that. So I posted the log and looked forward to your help.

WishQi avatar Sep 03 '18 09:09 WishQi

@dulmarod Is there any methods? Infer capture dose not work well.

WishQi avatar Sep 11 '18 04:09 WishQi

@jvillard I have found during the capture phase there are files on which infer spent a long time. But it seems just similar to other files, nothing special. The part of the report is as follows:

[57207][environment] Analyzer: capture
[57207][environment] Active checkers: annotation reachability (Java), biabduction (C/C++/ObjC, Java), fragment retains view (Java), immutable cast (Java), liveness (C/C++/ObjC), printf args (Java), ownership (C/C++/ObjC), RacerD (C/C++/ObjC, Java), SIOF (C/C++/ObjC), uninitialized variables (C/C++/ObjC)
[57207][      debug] 
[57207][      debug] *** Beginning capture of file /Users/douyin_ios/AWEFoundationKit/AWEFoundationKit/Classes/View/GrowingTextView/AWETextViewInternal.m ***
[57207][      debug] Clang frontend action is translating and linting
[57207][      debug] Loading the following linters files: /usr/local/Cellar/infer/0.15.0/lib/infer/infer/bin/../lib/linter_rules/linters.al
[57207][      debug] Elapsed: 2.427s.
[57207][      debug] 
[57207][environment] Infer log identifier is 
.[50819][      debug] 
[50819][      debug] *** Beginning capture of file /Users/douyin_ios/AWEFoundationKit/AWEFoundationKit/Classes/View/Bubble/AWEBubbleManager.m ***
[50819][      debug] Clang frontend action is translating and linting
[50819][      debug] Loading the following linters files: /usr/local/Cellar/infer/0.15.0/lib/infer/infer/bin/../lib/linter_rules/linters.al
[50819][      debug] 
[50819][ intern err] /Users/douyin_ios/AWEFoundationKit/AWEFoundationKit/Classes/View/Bubble/AWEBubbleManager.m:20:45: ERROR translating statement 'DeclRefExpr'
[50819][ intern err] /Users/douyin_ios/AWEFoundationKit/AWEFoundationKit/Classes/View/Bubble/AWEBubbleManager.m:20:45: ERROR translating statement 'ImplicitCastExpr'
[50819][ intern err] /Users/douyin_ios/AWEFoundationKit/AWEFoundationKit/Classes/View/Bubble/AWEBubbleManager.m:20:44-55: ERROR translating statement 'ObjCMessageExpr'
[50819][ intern err] 
[50819][      debug] Elapsed: 21min13s.

It took 21min for infer to capture the AWEBubbleManager.m while the size of the file is just 10kb and it only has 260 rows.

WishQi avatar Sep 14 '18 02:09 WishQi

@WishQi interesting, thanks! Can you try disabling the linters with --no-linters? Maybe that's what slowing down the capture.

jvillard avatar Sep 14 '18 09:09 jvillard

@jvillard It doesn't work. I ran man infer and found that --no-linters is used during infer analyze, but the phase is infer capture.

WishQi avatar Sep 14 '18 10:09 WishQi

@WishQi The linters are actually run during the capture phase as they work differently than the other infer analyses. Have you tried infer capture --no-linters ... to see if the capture time decreases?

jvillard avatar Sep 14 '18 10:09 jvillard

@jvillard I have tried that, but it doesn't work.

WishQi avatar Sep 14 '18 10:09 WishQi

I have also faced this issue. MacOS 10.14.5 Mojave Infer version v0.16.0

hovox avatar Jul 29 '19 12:07 hovox