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

Raise default number of workers #1288

Merged
merged 1 commit into from
Jul 16, 2024
Merged
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
11 changes: 8 additions & 3 deletions lib/Echidna/Types/Campaign.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module Echidna.Types.Campaign where
import Control.Concurrent (ThreadId)
import Data.Aeson
import Data.Map (Map)
import Data.Maybe (fromMaybe)
import Data.Text (Text)
import Data.Text qualified as T
import Data.Word (Word8, Word16)
import GHC.Conc (numCapabilities)

import Echidna.ABI (GenDict, emptyDict, encodeSig)
import Echidna.Types
Expand Down Expand Up @@ -211,9 +211,14 @@ defaultSymExecAskSMTIters :: Integer
defaultSymExecAskSMTIters = 1

-- | Get number of fuzzing workers (doesn't include sym exec worker)
-- Defaults to 1 if set to Nothing
-- Defaults to `N` if set to Nothing, where `N` is Haskell's -N value,
-- usually the number of cores, clamped between 1 and 4.
getNFuzzWorkers :: CampaignConf -> Int
getNFuzzWorkers conf = fromIntegral (fromMaybe 1 (conf.workers))
getNFuzzWorkers conf = maybe defaultN fromIntegral conf.workers
where
n = numCapabilities
Copy link
Member

Choose a reason for hiding this comment

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

is it the same as getNumCapabilities?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, but this is "pure", getNumCapabilities is IO

maxN = max 1 n
defaultN = min 4 maxN -- capped at 4 by default

-- | Number of workers, including SymExec worker if there is one
getNWorkers :: CampaignConf -> Int
Expand Down
4 changes: 2 additions & 2 deletions tests/solidity/basic/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ rpcUrl: null
rpcBlock: null
# Etherscan API key
etherscanApiKey: null
# number of workers
workers: 1
# number of workers. By default (unset) its value is the clamp of the number cores between 1 and 4
workers: null
# events server port
server: null
# whether to add an additional symbolic execution worker
Expand Down
Loading