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

add dumpDetail option in minify-fuzz phase to reduce memory usage #259

Draft
wants to merge 5 commits into
base: minify-fuzz
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .completion
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ _esmeta_completions() {
test262testOpt="-test262-test:target -test262-test:features -test262-test:progress -test262-test:coverage -test262-test:timeout -test262-test:with-yet -test262-test:log -test262-test:concurrent -test262-test:verbose"
injectOpt="-inject:body -inject:defs -inject:out -inject:log"
mutateOpt="-mutate:out -mutate:mutator -mutate:untilValid"
fuzzOpt="-fuzz:log -fuzz:log-interval -fuzz:out -fuzz:debug -fuzz:timeout -fuzz:trial -fuzz:duration -fuzz:seed -fuzz:cp -fuzz:k-fs -fuzz:init"
fuzzOpt="-fuzz:log -fuzz:log-interval -fuzz:out -fuzz:debug -fuzz:timeout -fuzz:trial -fuzz:duration -fuzz:seed -fuzz:cp -fuzz:k-fs -fuzz:init -fuzz:dumpDetail"
coverageinvestigateOpt="-coverage-investigate:out"
analyzeOpt="-analyze:repl"
# completion for commands
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/esmeta/es/util/fuzzer/Fuzzer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Fuzzer(
init: Option[String] = None,
kFs: Int = 0,
cp: Boolean = false,
dumpDetail: Int = 2, // 2: all, 1: partial, 0: no
) {
import Fuzzer.*

Expand Down
4 changes: 4 additions & 0 deletions src/main/scala/esmeta/es/util/fuzzer/MinifyFuzzer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ object MinifyFuzzer {
init: Option[String] = None,
kFs: Int = 0,
cp: Boolean = false,
dumpDetail: Int = 2, // 2: all, 1: partial, 0: no
): Coverage = new MinifyFuzzer(
cfg,
logInterval,
Expand All @@ -44,6 +45,7 @@ object MinifyFuzzer {
init,
kFs,
cp,
dumpDetail,
).result

val logDir: String = s"$MINIFY_FUZZ_LOG_DIR/fuzz-$dateStr"
Expand All @@ -61,6 +63,7 @@ class MinifyFuzzer(
init: Option[String] = None,
kFs: Int = 0,
cp: Boolean = false,
dumpDetail: Int = 2, // 2: all, 1: partial, 0: no
) {
import MinifyFuzzer.*

Expand Down Expand Up @@ -105,6 +108,7 @@ class MinifyFuzzer(
kFs = kFs,
cp = cp,
init = init,
dumpDetail = dumpDetail,
) {
override lazy val logDir = MinifyFuzzer.logDir
override lazy val symlink = MinifyFuzzer.symlink
Expand Down
11 changes: 11 additions & 0 deletions src/main/scala/esmeta/phase/Fuzz.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ case object Fuzz extends Phase[CFG, Coverage] {
kFs = config.kFs,
cp = config.cp,
init = config.init,
dumpDetail = config.dumpDetail,
).result

for (dirname <- config.out) cov.dumpToWithDetail(dirname)
Expand Down Expand Up @@ -104,6 +105,15 @@ case object Fuzz extends Phase[CFG, Coverage] {
StrOption((c, s) => c.init = Some(s)),
"explicitly use the given init pool",
),
(
"dumpDetail",
NumOption((c, k) =>
if (k < 0 || k > 2)
error("invalid dump detail level: please set 0 to 2")
else c.dumpDetail = k,
),
"set the dump detail level (0: no, 1: partial, 2: all)",
),
)
case class Config(
var log: Boolean = false,
Expand All @@ -117,5 +127,6 @@ case object Fuzz extends Phase[CFG, Coverage] {
var init: Option[String] = None,
var kFs: Int = 0,
var cp: Boolean = false,
var dumpDetail: Int = 2, // 2: all, 1: partial, 0: no
)
}
15 changes: 13 additions & 2 deletions src/main/scala/esmeta/phase/MinifyFuzz.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ case object MinifyFuzz extends Phase[CFG, Coverage] {
kFs = config.kFs,
cp = config.cp,
init = config.init,
dumpDetail = config.dumpDetail,
)

for (dirname <- config.out) cov.dumpToWithDetail(dirname)
Expand Down Expand Up @@ -109,18 +110,28 @@ case object MinifyFuzz extends Phase[CFG, Coverage] {
StrOption((c, s) => c.init = Some(s)),
"explicitly use the given init pool",
),
(
"dumpDetail",
NumOption((c, k) =>
if (k < 0 || k > 2)
error("invalid dump detail level: please set 0 to 2")
else c.dumpDetail = k,
),
"set the dump detail level (0: no, 1: partial, 2: all)",
),
)
case class Config(
var log: Boolean = false,
var logInterval: Option[Int] = Some(600), // 1 minute
var logInterval: Option[Int] = Some(600), // 10 minutes by default
var out: Option[String] = None,
var debug: Int = 0,
var timeLimit: Option[Int] = Some(1),
var timeLimit: Option[Int] = Some(1), // 1 second by default
var trial: Option[Int] = None,
var duration: Option[Int] = None,
var seed: Option[Int] = None,
var init: Option[String] = None,
var kFs: Int = 0,
var cp: Boolean = false,
var dumpDetail: Int = 2, // 2: full, 1: partial, 0: no
)
}
Loading