Skip to content

Commit

Permalink
Raise default number of workers (#1288)
Browse files Browse the repository at this point in the history
Now the default number of workers will be equal to the number
of cores on the system, with a minimum of 1 and a maximum of 4.
  • Loading branch information
elopez committed Jul 16, 2024
1 parent 7fe4d40 commit 3b5d6d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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
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

0 comments on commit 3b5d6d9

Please sign in to comment.