Skip to content

Commit

Permalink
review feedback from @patrick-schultz
Browse files Browse the repository at this point in the history
  • Loading branch information
ehigham committed Oct 8, 2024
1 parent 1a9641f commit 3c702c0
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion hail/src/main/scala/is/hail/backend/ExecuteContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class ExecuteContext(
val theHailClassLoader: HailClassLoader,
val flags: HailFeatureFlags,
val backendContext: BackendContext,
var irMetadata: IrMetadata,
val irMetadata: IrMetadata,
) extends Closeable {

val rngNonce: Long =
Expand Down
5 changes: 3 additions & 2 deletions hail/src/main/scala/is/hail/backend/local/LocalBackend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class LocalBackend(val tmpdir: String) extends Backend with BackendWithCodeCache
override val executionCache: ExecutionCache =
ExecutionCache.fromFlags(flags, fs, tmpdir)
},
IrMetadata(None),
new IrMetadata(),
)(f)
}

Expand Down Expand Up @@ -182,9 +182,10 @@ class LocalBackend(val tmpdir: String) extends Backend with BackendWithCodeCache
ctx.time {
TypeCheck(ctx, ir)
Validate(ir)
assert(ir.typ.isRealizable)
val queryID = Backend.nextID()
log.info(s"starting execution of query $queryID of initial size ${IRSize(ir)}")
ctx.irMetadata = ctx.irMetadata.copy(semhash = SemanticHash(ctx)(ir))
ctx.irMetadata.semhash = SemanticHash(ctx)(ir)
val res = _jvmLowerAndExecute(ctx, ir)
log.info(s"finished execution of query $queryID")
res
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,10 @@ class ServiceBackend(
ctx.time {
TypeCheck(ctx, ir)
Validate(ir)
assert(ir.typ.isRealizable)
val queryID = Backend.nextID()
log.info(s"starting execution of query $queryID of initial size ${IRSize(ir)}")
ctx.irMetadata = ctx.irMetadata.copy(semhash = SemanticHash(ctx)(ir))
ctx.irMetadata.semhash = SemanticHash(ctx)(ir)
val res = _jvmLowerAndExecute(ctx, ir)
log.info(s"finished execution of query $queryID")
res
Expand Down Expand Up @@ -408,7 +409,7 @@ class ServiceBackend(
theHailClassLoader,
flags,
serviceBackendContext,
IrMetadata(None),
new IrMetadata(),
)(f)
}

Expand Down
7 changes: 4 additions & 3 deletions hail/src/main/scala/is/hail/backend/spark/SparkBackend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class SparkBackend(
override val executionCache: ExecutionCache =
ExecutionCache.forTesting
},
IrMetadata(None),
new IrMetadata(),
)

def withExecuteContext[T](
Expand Down Expand Up @@ -408,7 +408,7 @@ class SparkBackend(
override val executionCache: ExecutionCache =
ExecutionCache.fromFlags(flags, fs, tmpdir)
},
IrMetadata(None),
new IrMetadata(),
)(f)
}

Expand Down Expand Up @@ -542,7 +542,8 @@ class SparkBackend(
ctx.time {
TypeCheck(ctx, ir)
Validate(ir)
ctx.irMetadata = ctx.irMetadata.copy(semhash = SemanticHash(ctx)(ir))
assert(ir.typ.isRealizable)
ctx.irMetadata.semhash = SemanticHash(ctx)(ir)
try {
val lowerTable = getFlag("lower") != null
val lowerBM = getFlag("lower_bm") != null
Expand Down
9 changes: 2 additions & 7 deletions hail/src/main/scala/is/hail/expr/ir/Emit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import scala.language.existentials

import java.io._

import sourcecode.Enclosing

// class for holding all information computed ahead-of-time that we need in the emitter
object EmitContext {
def analyze(ctx: ExecuteContext, ir: IR, pTypeEnv: Env[PType] = Env.empty): EmitContext = {
Expand Down Expand Up @@ -58,10 +56,7 @@ case class EmitContext(
methodSplits: Memo[Unit],
inLoopCriticalPath: Memo[Unit],
tryingToSplit: Memo[Unit],
) {
def time[A](block: => A)(implicit E: Enclosing): A =
executeContext.time(block)
}
)

case class EmitEnv(bindings: Env[EmitValue], inputValues: IndexedSeq[EmitValue]) {
def bind(name: Name, v: EmitValue): EmitEnv = copy(bindings = bindings.bind(name, v))
Expand Down Expand Up @@ -106,7 +101,7 @@ object Emit {
nParams: Int,
aggs: Option[Array[AggStateSig]] = None,
): Option[SingleCodeType] =
ctx.time {
ctx.executeContext.time {
TypeCheck(ctx.executeContext, ir)

val mb = fb.apply_method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import is.hail.expr.ir.agg.Extract
import is.hail.expr.ir.analyses.SemanticHash
import is.hail.utils._

final case class IrMetadata(semhash: Option[SemanticHash.Type]) {
final class IrMetadata() {
private[this] var hashCounter: Int = 0
private[this] var markCounter: Int = 0

var semhash: Option[SemanticHash.Type] = None

def nextHash: Option[SemanticHash.Type] = {
hashCounter += 1
semhash.map(SemanticHash.extend(_, SemanticHash.Bytes.fromInt(hashCounter)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ object EmitStream {
env: EmitEnv,
container: Option[AggContainer],
): IEmitCode =
emitter.ctx.time {
emitter.ctx.executeContext.time {

@nowarn("cat=unused-locals&msg=local default argument")
def emitVoid(
Expand Down

0 comments on commit 3c702c0

Please sign in to comment.