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

[sbt BSP] editing a file fires buildTarget/compile against independent project #3719

Closed
tanishiking opened this issue Mar 15, 2022 · 15 comments
Assignees
Labels
BSP Generic BSP related tickets sbt server Relates to sbt BSP server support

Comments

@tanishiking
Copy link
Member

tanishiking commented Mar 15, 2022

Describe the bug

Clone: https://github.com/tanishiking/sbt-multi-project/tree/20a3d476dc874db295fb3af3450873f8f211f1ea

// project/build.properties
sbt.version=1.6.2
// build.sbt
lazy val proj1 = (project in file("proj1"))
lazy val proj2 = (project in file("proj2")).dependsOn(proj1)
// proj1/src/main/scala/A.scala
package proj1

object A {
  val a = "aaa"
}
// proj2/src/main/scala/B.scala

package proj2

import proj1.A

object B {
  def b = println(A.a)
}

  • (compile all projects)
  • open and edit proj2/src/main/scala/B.scala

the metals log shows:

2022.03.15 16:26:59 INFO  Processing buildTarget/compile
2022.03.15 16:26:59 INFO  compiling proj1
2022.03.15 16:26:59 INFO  time: compiled proj1 in 7ms
2022.03.15 16:26:59 INFO  compiling proj2
2022.03.15 16:26:59 INFO  compiling 1 Scala source to /Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj2/target/scala-2.12/classes ...
2022.03.15 16:26:59 INFO  done compiling
2022.03.15 16:26:59 INFO  time: compiled proj2 in 0.63s
2022.03.15 16:26:59 INFO  Processing buildTarget/scalaMainClasses
2022.03.15 16:26:59 INFO  compiling proj1
2022.03.15 16:26:59 INFO  time: compiled proj1 in 5ms
2022.03.15 16:26:59 INFO  compiling proj2
2022.03.15 16:26:59 INFO  time: compiled proj2 in 6ms
2022.03.15 16:26:59 INFO  Processing buildTarget/scalaTestClasses
  • compilation on proj1 happens (though no files compiled thanks to zinc).
    • (and buildTarget/scalaMainClasses compiles proj1)

Expected behavior

sbt doesn't run compile against proj1 as bloop (looks it) doesn't.
I'm not sure how much it costs on CPU (if there're a lot of subprojects like 60~, it may cost a lot), but it would be nice if independent projects compilation doesn't run every time we edit a file.

(I'm not sure is this a metals issue or an sbt issue. I'll take a look metals side first, then if it's not the metals fault, I'll open a ticket in the sbt repo).

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

v0.11.2

Extra context or search terms

sbt 1.6.2
BSP

@tanishiking tanishiking added sbt server Relates to sbt BSP server support BSP Generic BSP related tickets labels Mar 15, 2022
@tgodzik
Copy link
Contributor

tgodzik commented Mar 15, 2022

Thanks for finding this, I wonder if it's related to #6782 ?

We can check via BSP logs what gets sent to sbt and this way figure out on which end the problem lays.

@tanishiking
Copy link
Member Author

Thanks for finding this, I wonder if it's related to #6782 ?

I'm not sure, that feature request seems like both for sbt and bloop, and this issue occurs only with sbt BSP 🤔

We can check via BSP logs what gets sent to sbt and this way figure out on which end the problem lays.

Thanks! I'll check the logs 👍

@tanishiking tanishiking self-assigned this Mar 16, 2022
@tanishiking
Copy link
Member Author

Maybe this is just my misunderstanding because of the log output granularity.

Here's the log from .metals/bsp.trace.log when I edit a /proj2/src/main/scala/B.scala, and I can see both sbt and bloop receive only buildTarget/compile, buildTarget/scalaMainClasses, and buildTarget/scalaTestClasses against proj2. There's no request for proj1.

I'll analyze more about the BSP log differences.

sbt BSP log
[Trace - 07:25:46 PM] Sending request 'buildTarget/compile - (11)'
Params: {
  "targets": [
    {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  ]
}


[Trace - 07:25:46 PM] Received notification 'build/logMessage'
Params: {
  "type": 4,
  "message": "Processing buildTarget/compile"
}


[Trace - 07:25:46 PM] Received notification 'build/taskStart'
Params: {
  "taskId": {
    "id": "65",
    "parents": []
  },
  "eventTime": 1647426346177,
  "message": "Compiling proj1",
  "dataKind": "compile-task",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj1/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/publishDiagnostics'
Params: {
  "textDocument": {
    "uri": "file:///Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj1/src/main/scala/A.scala"
  },
  "buildTarget": {
    "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj1/Compile"
  },
  "diagnostics": [],
  "reset": true
}


[Trace - 07:25:46 PM] Received notification 'build/taskFinish'
Params: {
  "taskId": {
    "id": "65",
    "parents": []
  },
  "eventTime": 1647426346181,
  "message": "Compiled proj1",
  "status": 1,
  "dataKind": "compile-report",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj1/Compile"
    },
    "errors": 0,
    "warnings": 0,
    "time": 4
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskStart'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346185,
  "message": "Compiling proj2",
  "dataKind": "compile-task",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/logMessage'
Params: {
  "type": 3,
  "message": "compiling 1 Scala source to /Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj2/target/scala-2.12/classes ..."
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346319,
  "message": "Compiling proj2 (10%)",
  "total": 28,
  "progress": 10,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346319,
  "message": "Compiling proj2 (10%)",
  "total": 28,
  "progress": 10,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346784,
  "message": "Compiling proj2 (25%)",
  "total": 28,
  "progress": 25,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346785,
  "message": "Compiling proj2 (25%)",
  "total": 28,
  "progress": 25,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346793,
  "message": "Compiling proj2 (35%)",
  "total": 28,
  "progress": 35,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346793,
  "message": "Compiling proj2 (35%)",
  "total": 28,
  "progress": 35,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346802,
  "message": "Compiling proj2 (50%)",
  "total": 28,
  "progress": 50,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346802,
  "message": "Compiling proj2 (50%)",
  "total": 28,
  "progress": 50,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346870,
  "message": "Compiling proj2 (60%)",
  "total": 28,
  "progress": 60,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346871,
  "message": "Compiling proj2 (60%)",
  "total": 28,
  "progress": 60,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346877,
  "message": "Compiling proj2 (75%)",
  "total": 28,
  "progress": 75,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346877,
  "message": "Compiling proj2 (75%)",
  "total": 28,
  "progress": 75,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346879,
  "message": "Compiling proj2 (85%)",
  "total": 28,
  "progress": 85,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346879,
  "message": "Compiling proj2 (85%)",
  "total": 28,
  "progress": 85,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346901,
  "message": "Compiling proj2 (100%)",
  "total": 28,
  "progress": 100,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskProgress'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346901,
  "message": "Compiling proj2 (100%)",
  "total": 28,
  "progress": 100,
  "dataKind": "compile-progress",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/logMessage'
Params: {
  "type": 3,
  "message": "done compiling"
}


[Trace - 07:25:46 PM] Received notification 'build/publishDiagnostics'
Params: {
  "textDocument": {
    "uri": "file:///Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj2/src/main/scala/B.scala"
  },
  "buildTarget": {
    "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
  },
  "diagnostics": [],
  "reset": true
}


[Trace - 07:25:46 PM] Received notification 'build/publishDiagnostics'
Params: {
  "textDocument": {
    "uri": "file:///Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj2/src/main/scala/C.scala"
  },
  "buildTarget": {
    "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
  },
  "diagnostics": [],
  "reset": true
}


[Trace - 07:25:46 PM] Received notification 'build/taskFinish'
Params: {
  "taskId": {
    "id": "66",
    "parents": []
  },
  "eventTime": 1647426346905,
  "message": "Compiled proj2",
  "status": 1,
  "dataKind": "compile-report",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    },
    "errors": 0,
    "warnings": 0,
    "time": 720
  }
}


[Trace - 07:25:46 PM] Received response 'buildTarget/compile - (11)' in 770ms
Result: {
  "statusCode": 1
}
Error: null


[Trace - 07:25:46 PM] Sending request 'buildTarget/scalaMainClasses - (12)'
Params: {
  "targets": [
    {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  ]
}


[Trace - 07:25:46 PM] Sending request 'buildTarget/scalaTestClasses - (13)'
Params: {
  "targets": [
    {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  ]
}


[Trace - 07:25:46 PM] Received notification 'build/logMessage'
Params: {
  "type": 4,
  "message": "Processing buildTarget/scalaMainClasses"
}


[Trace - 07:25:46 PM] Received notification 'build/taskStart'
Params: {
  "taskId": {
    "id": "67",
    "parents": []
  },
  "eventTime": 1647426346955,
  "message": "Compiling proj1",
  "dataKind": "compile-task",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj1/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/publishDiagnostics'
Params: {
  "textDocument": {
    "uri": "file:///Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj1/src/main/scala/A.scala"
  },
  "buildTarget": {
    "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj1/Compile"
  },
  "diagnostics": [],
  "reset": true
}


[Trace - 07:25:46 PM] Received notification 'build/taskFinish'
Params: {
  "taskId": {
    "id": "67",
    "parents": []
  },
  "eventTime": 1647426346959,
  "message": "Compiled proj1",
  "status": 1,
  "dataKind": "compile-report",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj1/Compile"
    },
    "errors": 0,
    "warnings": 0,
    "time": 4
  }
}


[Trace - 07:25:46 PM] Received notification 'build/taskStart'
Params: {
  "taskId": {
    "id": "68",
    "parents": []
  },
  "eventTime": 1647426346963,
  "message": "Compiling proj2",
  "dataKind": "compile-task",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    }
  }
}


[Trace - 07:25:46 PM] Received notification 'build/publishDiagnostics'
Params: {
  "textDocument": {
    "uri": "file:///Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj2/src/main/scala/B.scala"
  },
  "buildTarget": {
    "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
  },
  "diagnostics": [],
  "reset": true
}


[Trace - 07:25:46 PM] Received notification 'build/publishDiagnostics'
Params: {
  "textDocument": {
    "uri": "file:///Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj2/src/main/scala/C.scala"
  },
  "buildTarget": {
    "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
  },
  "diagnostics": [],
  "reset": true
}


[Trace - 07:25:46 PM] Received notification 'build/taskFinish'
Params: {
  "taskId": {
    "id": "68",
    "parents": []
  },
  "eventTime": 1647426346970,
  "message": "Compiled proj2",
  "status": 1,
  "dataKind": "compile-report",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
    },
    "errors": 0,
    "warnings": 0,
    "time": 7
  }
}


[Trace - 07:25:46 PM] Received response 'buildTarget/scalaMainClasses - (12)' in 67ms
Result: {
  "items": [
    {
      "target": {
        "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
      },
      "classes": []
    }
  ]
}
Error: null


[Trace - 07:25:46 PM] Received notification 'build/logMessage'
Params: {
  "type": 4,
  "message": "Processing buildTarget/scalaTestClasses"
}


[Trace - 07:25:46 PM] Received response 'buildTarget/scalaTestClasses - (13)' in 83ms
Result: {
  "items": [
    {
      "target": {
        "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/#proj2/Compile"
      },
      "classes": []
    }
  ]
}
Error: null

bloop log
[Trace - 07:32:04 PM] Sending request 'buildTarget/compile - (12)'
Params: {
  "targets": [
    {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj2/?id\u003dproj2"
    }
  ]
}


[Trace - 07:32:04 PM] Received notification 'build/taskStart'
Params: {
  "taskId": {
    "id": "3"
  },
  "eventTime": 1647426724369,
  "message": "Start no-op compilation for proj1",
  "dataKind": "compile-task",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj1/?id\u003dproj1"
    }
  }
}


[Trace - 07:32:04 PM] Received notification 'build/taskFinish'
Params: {
  "taskId": {
    "id": "3"
  },
  "eventTime": 1647426724376,
  "message": "Compiled \u0027proj1\u0027",
  "status": 1,
  "dataKind": "compile-report",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj1/?id\u003dproj1"
    },
    "errors": 0,
    "warnings": 0,
    "isNoOp": true,
    "isLastCycle": true,
    "clientDir": "file:///Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/.bloop/proj1/bloop-bsp-clients-classes/classes-Metals-bU4EFn9mTTCOkqAgZ7QTiw\u003d\u003d/",
    "analysisOut": "file:///Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/.bloop/proj1/proj1-analysis.bin"
  }
}


[Trace - 07:32:04 PM] Received notification 'build/taskStart'
Params: {
  "taskId": {
    "id": "4"
  },
  "eventTime": 1647426724425,
  "message": "Start no-op compilation for proj2",
  "dataKind": "compile-task",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj2/?id\u003dproj2"
    }
  }
}


[Trace - 07:32:04 PM] Received notification 'build/taskFinish'
Params: {
  "taskId": {
    "id": "4"
  },
  "eventTime": 1647426724431,
  "message": "Compiled \u0027proj2\u0027",
  "status": 1,
  "dataKind": "compile-report",
  "data": {
    "target": {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj2/?id\u003dproj2"
    },
    "errors": 0,
    "warnings": 0,
    "isNoOp": true,
    "isLastCycle": true,
    "clientDir": "file:///Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/.bloop/proj2/bloop-bsp-clients-classes/classes-Metals-bU4EFn9mTTCOkqAgZ7QTiw\u003d\u003d/",
    "analysisOut": "file:///Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/.bloop/proj2/proj2-analysis.bin"
  }
}


[Trace - 07:32:04 PM] Received response 'buildTarget/compile - (12)' in 86ms
Result: {
  "statusCode": 1
}
Error: null


[Trace - 07:32:04 PM] Sending request 'buildTarget/scalaMainClasses - (13)'
Params: {
  "targets": [
    {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj2/?id\u003dproj2"
    }
  ]
}


[Trace - 07:32:04 PM] Sending request 'buildTarget/scalaTestClasses - (14)'
Params: {
  "targets": [
    {
      "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj2/?id\u003dproj2"
    }
  ]
}


[Trace - 07:32:04 PM] Received response 'buildTarget/scalaMainClasses - (13)' in 5ms
Result: {
  "items": [
    {
      "target": {
        "uri": "file:/Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/proj2/?id\u003dproj2"
      },
      "classes": []
    }
  ]
}
Error: null


[Trace - 07:32:04 PM] Received response 'buildTarget/scalaTestClasses - (14)' in 8ms
Result: {
  "items": []
}
Error: null



@kpodsiad
Copy link
Member

Isn't title misleading? "editing a file fires buildTarget/compile against independent project" - after looking at the logs it's more like a problem with how build server interprets compile for proj2.

It seems like Bloop knows that nothing changed in proj1 - Start no-op compilation for proj1, but sbt doesn't so it run normal compilation on it. However, Zinc is probably smart enough to detect that nothing changed so this compilation is ends almost immediately.

Does this interpretation make sense @tanishiking ?

@tanishiking
Copy link
Member Author

send a buildTarget/compile against proj2

  • otification build/taskStart (for proj1)
    • bloop: "Start no-op compilation for proj1"
    • sbt: "Compiling proj1"
  • only sbt publishDiagnostics (for proj1)
  • notification build/taskFinish
    • bloop has the following params in data
      • "isNoOp": true,
      • "isLastCycle": true,
      • "clientDir": "file:///Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/.bloop/proj1/bloop-bsp-clients-classes/classes-Metals-bU4EFn9mTTCOkqAgZ7QTiw\u003d\u003d/",
      • "analysisOut": "file:///Users/tanishiking/src/github.com/tanishiking/sbt-multi-project/.bloop/proj1/proj1-analysis.bin"
  • notification build/taskStartfrom proj2
  • only sbt notify build/taskProgress
  • only sbt publishDiagnostics (for proj2)
    • B.scala and C.scala (for each files in the project????)
  • notification build/taskFinish (same, bloop has more field in data)

buildTarget/scalaMainClasses

bloop

does nothing

sbt

  • build/taskStart (proj1)
  • build/publishDiagnostics (A.scala)
  • build/taskFinish

@tanishiking
Copy link
Member Author

@kpodsiad Yes, that's correct.
The thing is

So, basically both sbt and bloop doesn't have difference as per how they handle the buildTarget/compile request against proj2.

@kpodsiad
Copy link
Member

Ahh, now I see that bloop is comparing Zinc Analysis. I wonder if we can make some changes in sbt to align this behavior.

@tanishiking
Copy link
Member Author

tanishiking commented Mar 16, 2022

Yeah, also, bloop seems to compare the Zinc Analysis, and if there's no change in diagnostics, it doesn't notify the build/publishDiagnostics to BSP client (metals). This significantly reduces the message load between metals and bloop.
(maybe it's wrong, I have to verify my hypothesis by reading bloop ;) )

@tanishiking
Copy link
Member Author

@kpodsiad Where did you find the code where bloop compares Zinc Analysis? I'm trying to read bloop code, but I'm new to the repo, it would be helpful if there're some pointers :)

@tanishiking
Copy link
Member Author

Anyway, I'm closing this issue, as it was my misunderstanding.
Instead, I will open issues on sbt/sbt to optimize the BSP's notification behavior as bloop does, by comparing previous Zinc Analysis (?) (after I verify how bloop compares them and optimize the notifications).

@tgodzik
Copy link
Contributor

tgodzik commented Mar 16, 2022

There is a related issue to that sbt/sbt#6103

@kpodsiad
Copy link
Member

@tanishiking
Copy link
Member Author

Thanks! @tgodzik @kpodsiad

@tanishiking
Copy link
Member Author

Opened an issue on sbt/sbt#6844

@kpodsiad kpodsiad added this to the Metals v0.11.3 milestone Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BSP Generic BSP related tickets sbt server Relates to sbt BSP server support
Projects
None yet
Development

No branches or pull requests

3 participants