Skip to content

TypeTag materialization, stringification appears to be a significant overhead in logging API #5607

@retronym

Description

@retronym
  def logEvent[A: JsonFormat: TypeTag](level: Level.Value, event: => A): Unit = {
    val v: A = event
    val tag = StringTypeTag[A]
    LogExchange.getOrElseUpdateJsonCodec(tag.key, implicitly[JsonFormat[A]])
    // println("logEvent " + tag.key)
    val entry: ObjectEvent[A] = ObjectEvent(level, v, channelName, execId, tag.key)
    xlogger.log(
      ConsoleAppender.toXLevel(level),
      new ObjectMessage(entry)
    )
  }

I don't quite know whether to believe what I'm seeing here:

image

but it suggests far too much time is spent logging (only 12k samples were spent in scalac and zinc)

ManagedLogger.success could be tunneled through to a version of logEvent that accepted a pre-stringified tag, rather than a TypeTag.

I'd really suggest use of ClassTag instead of TypeTag as the key here, although there might be a good reason that you want the generic types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions