simplify monitoring after fishnet 2
parent
6442d8a422
commit
0bf13da1c0
|
@ -515,8 +515,6 @@ object mon {
|
|||
}
|
||||
def status(enabled: Boolean) = gauge("fishnet.client.status").withTag("enabled", enabled)
|
||||
def version(v: String) = gauge("fishnet.client.version").withTag("version", v)
|
||||
def stockfish(v: String) = gauge("fishnet.client.engine.stockfish").withTag("version", v)
|
||||
def python(v: String) = gauge("fishnet.client.python").withTag("version", v)
|
||||
}
|
||||
def queueTime(sender: String) = timer("fishnet.queue.db").withTag("sender", sender)
|
||||
val acquire = future("fishnet.acquire")
|
||||
|
@ -524,8 +522,6 @@ object mon {
|
|||
def oldest(as: String) = gauge("fishnet.oldest").withTag("for", as)
|
||||
object analysis {
|
||||
object by {
|
||||
def hash(client: String) = gauge("fishnet.analysis.hash").withTag("client", client)
|
||||
def threads(client: String) = gauge("fishnet.analysis.threads").withTag("client", client)
|
||||
def movetime(client: String) = histogram("fishnet.analysis.movetime").withTag("client", client)
|
||||
def node(client: String) = histogram("fishnet.analysis.node").withTag("client", client)
|
||||
def nps(client: String) = histogram("fishnet.analysis.nps").withTag("client", client)
|
||||
|
|
|
@ -17,10 +17,6 @@ private object BSONHandlers {
|
|||
x => BSONString(x.key)
|
||||
)
|
||||
|
||||
import Client.{ Engine, Engines }
|
||||
implicit val EngineBSONHandler = Macros.handler[Engine]
|
||||
implicit val EnginesBSONHandler = Macros.handler[Engines]
|
||||
|
||||
import Client.Instance
|
||||
implicit val InstanceBSONHandler = Macros.handler[Instance]
|
||||
|
||||
|
|
|
@ -49,19 +49,15 @@ object Client {
|
|||
case class Version(value: String) extends AnyVal with StringValue
|
||||
case class Python(value: String) extends AnyVal with StringValue
|
||||
case class UserId(value: String) extends AnyVal with StringValue
|
||||
case class Engine(name: String)
|
||||
case class Engines(stockfish: Engine)
|
||||
|
||||
case class Instance(
|
||||
version: Version,
|
||||
engines: Engines,
|
||||
ip: IpAddress,
|
||||
seenAt: DateTime
|
||||
) {
|
||||
|
||||
def update(i: Instance): Option[Instance] =
|
||||
if (i.version != version) i.some
|
||||
else if (i.engines != engines) i.some
|
||||
else if (i.ip != ip) i.some
|
||||
else if (i.seenAt isAfter seenAt.plusMinutes(5)) i.some
|
||||
else none
|
||||
|
|
|
@ -15,17 +15,8 @@ object JsonApi {
|
|||
|
||||
sealed trait Request {
|
||||
val fishnet: Request.Fishnet
|
||||
val stockfish: Request.Engine
|
||||
|
||||
def instance(ip: IpAddress) =
|
||||
Client.Instance(
|
||||
fishnet.version,
|
||||
Client.Engines(
|
||||
stockfish = Client.Engine(stockfish.name)
|
||||
),
|
||||
ip,
|
||||
DateTime.now
|
||||
)
|
||||
def instance(ip: IpAddress) = Client.Instance(fishnet.version, ip, DateTime.now)
|
||||
}
|
||||
|
||||
object Request {
|
||||
|
@ -38,36 +29,19 @@ object JsonApi {
|
|||
apikey: Client.Key
|
||||
)
|
||||
|
||||
sealed trait Engine {
|
||||
def name: String
|
||||
}
|
||||
|
||||
case class BaseEngine(name: String) extends Engine
|
||||
|
||||
case class FullEngine(
|
||||
name: String,
|
||||
options: EngineOptions,
|
||||
case class Stockfish(
|
||||
flavor: Option[String]
|
||||
) extends Engine {
|
||||
) {
|
||||
def isNnue = flavor.has("nnue")
|
||||
}
|
||||
|
||||
case class EngineOptions(
|
||||
threads: Option[String],
|
||||
hash: Option[String]
|
||||
) {
|
||||
def threadsInt = threads flatMap (_.toIntOption)
|
||||
def hashInt = hash flatMap (_.toIntOption)
|
||||
}
|
||||
|
||||
case class Acquire(
|
||||
fishnet: Fishnet,
|
||||
stockfish: BaseEngine
|
||||
fishnet: Fishnet
|
||||
) extends Request
|
||||
|
||||
case class PostAnalysis(
|
||||
fishnet: Fishnet,
|
||||
stockfish: FullEngine,
|
||||
stockfish: Stockfish,
|
||||
analysis: List[Option[Evaluation.OrSkipped]]
|
||||
) extends Request
|
||||
with Result {
|
||||
|
@ -79,7 +53,7 @@ object JsonApi {
|
|||
|
||||
case class CompleteAnalysis(
|
||||
fishnet: Fishnet,
|
||||
stockfish: FullEngine,
|
||||
stockfish: Stockfish,
|
||||
analysis: List[Evaluation.OrSkipped]
|
||||
) {
|
||||
|
||||
|
@ -100,7 +74,7 @@ object JsonApi {
|
|||
|
||||
case class PartialAnalysis(
|
||||
fishnet: Fishnet,
|
||||
stockfish: FullEngine,
|
||||
stockfish: Stockfish,
|
||||
analysis: List[Option[Evaluation.OrSkipped]]
|
||||
)
|
||||
|
||||
|
@ -179,9 +153,7 @@ object JsonApi {
|
|||
implicit val ClientVersionReads = Reads.of[String].map(Client.Version(_))
|
||||
implicit val ClientPythonReads = Reads.of[String].map(Client.Python(_))
|
||||
implicit val ClientKeyReads = Reads.of[String].map(Client.Key(_))
|
||||
implicit val EngineOptionsReads = Json.reads[Request.EngineOptions]
|
||||
implicit val BaseEngineReads = Json.reads[Request.BaseEngine]
|
||||
implicit val FullEngineReads = Json.reads[Request.FullEngine]
|
||||
implicit val StockfishReads = Json.reads[Request.Stockfish]
|
||||
implicit val FishnetReads = Json.reads[Request.Fishnet]
|
||||
implicit val AcquireReads = Json.reads[Request.Acquire]
|
||||
implicit val ScoreReads = Json.reads[Request.Evaluation.Score]
|
||||
|
|
|
@ -31,13 +31,9 @@ final private class Monitor(
|
|||
) = {
|
||||
Monitor.success(work, client)
|
||||
|
||||
val threads = result.stockfish.options.threadsInt
|
||||
val userId = client.userId.value
|
||||
val userId = client.userId.value
|
||||
|
||||
result.stockfish.options.hashInt foreach { monBy.hash(userId).update(_) }
|
||||
result.stockfish.options.threadsInt foreach { monBy.threads(userId).update(_) }
|
||||
|
||||
monBy.totalSecond(userId).increment(sumOf(result.evaluations)(_.time) * threads.|(1) / 1000)
|
||||
monBy.totalSecond(userId).increment(sumOf(result.evaluations)(_.time) / 1000)
|
||||
|
||||
if (result.stockfish.isNnue)
|
||||
monBy
|
||||
|
@ -85,9 +81,6 @@ final private class Monitor(
|
|||
instances.groupMapReduce(_.version.value)(_ => 1)(_ + _) foreach { case (v, nb) =>
|
||||
version(v).update(nb)
|
||||
}
|
||||
instances.groupMapReduce(_.engines.stockfish.name)(_ => 1)(_ + _) foreach { case (s, nb) =>
|
||||
stockfish(s).update(nb)
|
||||
}
|
||||
}
|
||||
|
||||
private def monitorStatus(): Funit =
|
||||
|
|
Loading…
Reference in New Issue