-
Notifications
You must be signed in to change notification settings - Fork 949
introduce a new Input/Output: FileInput/FileOutput #5515
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
Conversation
@@ -44,3 +45,13 @@ class PlainInput[J: IsoString](input: InputStream, converter: SupportConverter[J | |||
|
|||
def close() = input.close() | |||
} | |||
|
|||
class FileInput(file: File) extends Input { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this in the new Input that uses Parser.parseFromFile
directly , instead of IsoString
to convert to a interdemiary String
first. This is where this whole PR started...
@@ -23,14 +24,15 @@ abstract class CacheStore extends Input with Output { | |||
} | |||
|
|||
object CacheStore { | |||
@deprecated("Create your own IsoString[JValue]", "1.4") | |||
implicit lazy val jvalueIsoString: IsoString[JValue] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this val is kept just for bincompt...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to deprecate this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it can be removed in the future
@@ -47,38 +49,44 @@ abstract class CacheStoreFactory { | |||
} | |||
|
|||
object CacheStoreFactory { | |||
@deprecated("Create your own IsoString[JValue]", "1.4") | |||
implicit lazy val jvalueIsoString: IsoString[JValue] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this val is kept just for bincompt...
IO.createDirectory(base) | ||
|
||
def make(identifier: String): CacheStore = new FileBasedStore(base / identifier, converter) | ||
@deprecated("Use constructor without converter", "1.4") | ||
def this(base: File, converter: sjsonnew.SupportConverter[J], isoString: sjsonnew.IsoString[J]) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this constructor was added, just for bincompt, but some parameters will just be ignored...
IO.touch(file, setModified = false) | ||
|
||
@deprecated("Use constructor without converter", "1.4") | ||
def this(file: File, converter: sjsonnew.SupportConverter[J])(implicit e: sjsonnew.IsoString[J]) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this constructor was added, just for bincompt, but some parameters will just be ignored...
tests are failing on windows... any help with those? |
https://github.com/sbt/sbt/blob/develop/sbt/src/sbt-test/actions/previous/build.sbt
so for some reason |
fixed the windows error which was caused by typelevel/jawn#109, however now the build fails in 2.13 because in 2.13 we use jawn 1.0... |
finally tests are green |
val store = new FileBasedStore(file, sjsonnew.support.scalajson.unsafe.Converter) | ||
val store = new FileBasedStore(file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you see difference in load time from this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I havent benchmarked this change against my sample project in #5508...
Do you think I should add that sample project to a scripted test so is easier to check? or is it too much for a unit test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok for the tests to prove just the correctness, but if we're making some optimization or changes aimed at performance improvement, I would like to see some data even if it's casually done local testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @eed3si9n! I rebased this PR and compared the performance of this PR versus 1.4.0-M1 and did not see any significant improvements. I can try to write some jmh benchmarks, but I see there aren't benchmarks in the project...
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a mixed feeling about jmh. In general they are useful. But since the Scala compiler is complicated, even with 10 warmup or whatever C2 would keep optimizing for like 10 minutes, even longer.. so that means that more iteration you run, the performance gets better at least for compilation. See sbt/zinc#767 (comment). This might affect sbt indirectly since there are some aspect of compilation. So to minimize the fluctuation, we should reuse *.class
files between the iteration?
Existing code that might be relevant for benchmarking is scripted test and server test.
- https://github.com/sbt/sbt/blob/develop/scripted-sbt-redux/src/main/scala/sbt/scriptedtest/ScriptedTests.scala
- https://github.com/sbt/sbt/blob/develop/scripted-sbt-redux/src/main/scala/sbt/scriptedtest/RemoteSbtCreator.scala
- https://github.com/sbt/sbt/blob/develop/server-test/src/test/scala/testpkg/TestServer.scala#L173-L174
See also https://github.com/eatkins/scala-build-watch-performance
37842d4
to
1268b8f
Compare
Hi @eed3si9n I rebased this PR against 1.4.4 and compare these changes against it with https://github.com/jtjeferreira/sbt-multi-module-sample I see some improvements in FileInput vs PlainInput (872 vs 1052 samples in the flamegraph), but no improvements in FileOutput vs PlainOutput (both around 240 samples in the flamegraph). WDYT? should we merge? should we close? should we benchmark differently? |
the flamegraphs can be found in this commit jtjeferreira/sbt-multi-module-sample@c6a288f |
Thanks for the candid assessment. As a general idea streaming bytes directly into files sounds like a good idea. What do you think about merging this to develop, targeting for sbt 1.5.0? (Planned to be out early 2021, as opposed to the normal year-long wait) If that's ok, could you squash the commits plz? |
5dd22d3
to
dd411ca
Compare
* FileInput avoids the intermediate String parsing of PlainInput * FileOuput also avoid the intermediate String representation of PlainOutput
looks good to me. the commits were squashed. |
Uh oh!
There was an error while loading. Please reload this page.