Menu

How is -j option working ?

gluttony38
2019-12-09
2019-12-09
  • gluttony38

    gluttony38 - 2019-12-09

    Hi,

    I just have seen that there is a -j <jobs></jobs> option that "Start <jobs>
    threads to do the checking simultaneously</jobs>
    " but it seems not working on
    v1.89, indeed, for a same cppcheck command, when I run without -j option
    it took 3 minutes 25 seconds (command run under Linux with preceding time
    command, like time cppcheck <files> <options></options></files>), and when I run the same
    command adding -j 14 (I have 16 cores, just want to keep 2 free for other
    stuff), it took the same time and when I run htop on another terminal I
    can see there is only one core working for cppcheck command.

    Is there something I'm missing with this option ?

    Thanks

     
  • Daniel Marjamäki

    It analyzes each TU separately in 1 core. So if you only have 1 TU then -j does not help. If you have 100 TUs then you should have got 14 cores for the analysis.
    If you have many TUs and get 1 core then something seems to be wrong.. can you please tell us what compiler/os you're using?

     
  • versat

    versat - 2019-12-09

    -j is used to analyze files in parallel. So if there is only one file to analyze it does not speed up anything as far as I know.
    Did you analyze a project with many files or just one or a few files?
    There are different implementations for Windows and Linux, but they should behave in the same way (For the user there should not be a difference). Under Cygwin there were severe issues with the Linux implementation (using fork) so we had to disable it here. If you try -j 2 under Cygwin it will directly print an error. What OS do you use?

    Edit: I wrote at the same time as Daniel :) I also meant TU when I wrote "files".

     

    Last edit: versat 2019-12-09
  • Daniel Marjamäki

    TU="Translation Unit"
    If you scan a folder recursively that has 100 cpp files then there are 100 TUs. If you just tell Cppcheck to scan 1 file then -j does not help.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.