-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eliminate VCS TimeoutExceptions on startup (#8080)
Having a modest-size files in a project would lead to a timeout when the project was first initialized. This became apparent when testing delivered `.enso-project` files with some data files. After some digging there was a bug in JGit (https://bugs.eclipse.org/bugs/show_bug.cgi?id=494323) which meant that adding such files was really slow. The implemented fix is not on by default but even with `--renormalization` turned off I did not see improvement. In the end it didn't make sense to add `data` directory to our version control, or any other files than those in `src` or some meta files in `.enso`. Not including such files eliminates first-use initialization problems. # Important Notes To test, pick an existing Enso project with some data files in it (> 100MB) and remove `.enso/.vcs` directory. Previously it would timeout on first try (and work in successive runs). Now it works even on the first try. The crash: ``` [org.enso.languageserver.requesthandler.vcs.InitVcsHandler] Initialize project request [Number(2)] for [f9a7cd0d-529c-4e1d-a4fa-9dfe2ed79008] failed with: null. java.util.concurrent.TimeoutException: null at org.enso.languageserver.effect.ZioExec$.<clinit>(Exec.scala:134) at org.enso.languageserver.effect.ZioExec.$anonfun$exec$3(Exec.scala:60) at org.enso.languageserver.effect.ZioExec.$anonfun$exec$3$adapted(Exec.scala:60) at zio.ZIO.$anonfun$foldCause$4(ZIO.scala:683) at zio.internal.FiberRuntime.runLoop(FiberRuntime.scala:904) at zio.internal.FiberRuntime.evaluateEffect(FiberRuntime.scala:381) at zio.internal.FiberRuntime.evaluateMessageWhileSuspended(FiberRuntime.scala:504) at zio.internal.FiberRuntime.drainQueueOnCurrentThread(FiberRuntime.scala:220) at zio.internal.FiberRuntime.run(FiberRuntime.scala:139) at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:49) at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ```
- Loading branch information
Showing
17 changed files
with
274 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
* text eol=lf | ||
*.enso text eol=lf | ||
*.png binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
1 change: 1 addition & 0 deletions
1
distribution/engine/THIRD-PARTY/commons-codec.commons-codec-1.16.0/NOTICES
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,28 @@ | ||
/* | ||
* Copyright 2017 Marc Stevens <[email protected]>, Dan Shumow <[email protected]> | ||
* Distributed under the MIT Software License. | ||
* MIT License | ||
* | ||
* Copyright (c) 2017: | ||
* Marc Stevens | ||
* Cryptology Group | ||
* Centrum Wiskunde & Informatica | ||
* P.O. Box 94079, 1090 GB Amsterdam, Netherlands | ||
* [email protected] | ||
* | ||
* Dan Shumow | ||
* Microsoft Research | ||
* [email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
<p><b>SHA-1 UbcCheck - MIT</b></p> | ||
<p>Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors. </p> | ||
|
||
<p>Copyright (c) 2017:</p> | ||
<div class="ubc-name"> | ||
Marc Stevens | ||
|
||
<p>Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors. </p> | ||
<p>Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
<ul><li>Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. </li> | ||
<li>Redistributions in binary form must reproduce the above copyright notice, | ||
|
||
<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
|
||
<ul><li>Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. </li> | ||
<li>Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. </li> | ||
|
||
<ul><li>The above copyright notice and this permission notice shall be included | ||
|
||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
|
||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
|
||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
|
||
Copyright (C) 2006, 2007, Robin Rosenberg <[email protected]> | ||
|
||
|
@@ -688,3 +671,23 @@ Copyright (c) 2020, Google LLC and others | |
Copyright (c) 2020, Google LLC and others | ||
|
||
Copyright (c) 2021 Qualcomm Innovation Center, Inc. | ||
|
||
Copyright 2017 Marc Stevens <[email protected]>, Dan Shumow <[email protected]> | ||
|
||
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
|
||
Redistributions in binary form must reproduce the above copyright notice, | ||
|
||
Redistributions of source code must retain the above copyright | ||
|
||
Redistributions of source code must retain the above copyright notice, this | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
|
||
and other copyright owners as documented in the project's IP log. | ||
|
||
copyright notice, this list of conditions and the following | ||
|
||
other copyright owners as documented in the project's IP log. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,12 +27,14 @@ import org.enso.languageserver.vcsmanager.Git.{ | |
} | ||
|
||
import scala.jdk.CollectionConverters._ | ||
|
||
import java.time.Instant | ||
import zio.ZIO.attemptBlocking | ||
|
||
private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean) | ||
extends VcsApi[BlockingIO] { | ||
private class Git( | ||
srcDirectory: Path, | ||
ensoDataDirectory: Option[Path], | ||
asyncInit: Boolean | ||
) extends VcsApi[BlockingIO] { | ||
|
||
private val gitDir = ensoDataDirectory | ||
.map(_.resolve(VcsApi.DefaultRepoDir)) | ||
|
@@ -92,18 +94,24 @@ private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean) | |
dotGit.delete() | ||
} | ||
} | ||
|
||
val isDataDir = | ||
ensoDataDirectory.contains _ | ||
val isDataDir = ensoDataDirectory.contains _ | ||
val filesToAdd = | ||
listDirectoryFiles(root, Set(gitDir)) | ||
.filterNot(isDataDir) | ||
.filter(p => | ||
ensoDataDirectory | ||
.map(ensoDir => p.startsWith(ensoDir)) | ||
.getOrElse(p.startsWith(srcDirectory)) || p.startsWith( | ||
srcDirectory | ||
) | ||
) | ||
.map(ensureUnixPathSeparator) | ||
if (filesToAdd.nonEmpty) { | ||
filesToAdd | ||
.foldLeft(jgit.add()) { case (cmd, filePath) => | ||
cmd.addFilepattern(filePath) | ||
} | ||
.setRenormalize(false) | ||
.call() | ||
} | ||
|
||
|
@@ -140,6 +148,7 @@ private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean) | |
// Include files that already are/were in the index | ||
jgit | ||
.add() | ||
.setRenormalize(false) | ||
.addFilepattern(".") | ||
.setUpdate(true) | ||
.call() | ||
|
@@ -151,12 +160,16 @@ private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean) | |
val isDataDir = | ||
(x: String) => unixDataDir.map(dataDir => dataDir == x).getOrElse(false) | ||
val filesToAdd = untracked.flatMap { file => | ||
if (!file.startsWith(unixGitDir) && !isDataDir(file)) { | ||
if ( | ||
!file.startsWith(unixGitDir) && !isDataDir(file) && Path | ||
.of(file) | ||
.startsWith(srcDirectory) | ||
) { | ||
Some(file) | ||
} else None | ||
} | ||
if (!filesToAdd.isEmpty) { | ||
val addCmd = jgit.add() | ||
val addCmd = jgit.add().setRenormalize(false) | ||
filesToAdd.foreach(filePath => | ||
addCmd.addFilepattern(ensureUnixPathSeparator(filePath)) | ||
) | ||
|
@@ -345,9 +358,10 @@ private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean) | |
} | ||
|
||
object Git { | ||
private val HeadRef = "HEAD" | ||
private val AuthorName = "Enso VCS" | ||
private val AuthorEmail = "[email protected]" | ||
private val HeadRef = "HEAD" | ||
private val AuthorName = "Enso VCS" | ||
private val AuthorEmail = "[email protected]" | ||
private val SrcDirectory = Path.of("src") | ||
|
||
private class RepoExists extends Exception | ||
|
||
|
@@ -359,6 +373,6 @@ object Git { | |
asyncInit: Boolean | ||
): VcsApi[BlockingIO] = { | ||
SystemReader.setInstance(new EmptyUserConfigReader) | ||
new Git(dataDir, asyncInit) | ||
new Git(SrcDirectory, dataDir, asyncInit) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.