我遇到了一个奇怪的scala-io
moveTo
方法问题。这是我的文件系统,tmp
目录位于 ram 中。
~ % df -Th ~/ :) 文件系统类型 已用大小 可用 使用% 已安装 rootfs rootfs 112G 18G 89G 17% / /dev devtmpfs 3.9G 0 3.9G 0% /dev 运行 tmpfs 3.9G 236K 3.9G 1% /运行 /dev/sda btrfs 112G 18G 89G 17% / shm tmpfs 3.9G 872K 3.9G 1% /dev/shm tmpfs tmpfs 3.9G 34M 3.9G 1% /tmp
将文件从tmp
主目录或向后移动时,首先它很慢(主观上约为 1M/s,而iotop
显示可笑的 1500M/s),其次它会导致 100% 的 cpu 负载。在同一文件系统中移动文件时,一切都按预期工作。
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_03).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import scalax.file.Path
import scalax.file.Path
scala> val tmp = Path("/tmp/ensime")
tmp: scalax.file.Path = Path(/tmp/ensime)
scala> tmp.exists
res0: Boolean = true
scala> val home = Path("/home/_4e6/dest")
home: scalax.file.Path = Path(/home/_4e6/dest)
scala> home.exists
res1: Boolean = false
scala> tmp.moveTo(home) // very slow
res2: scalax.file.Path = Path(/home/_4e6/dest)
scala> home.moveTo(tmp) // a bit faster but still unsatisfactory
res3: scalax.file.Path = Path(/tmp/ensime)
此外,copyTo
方法工作正常;replace
并且atomicMove
flags 不会改变任何东西;并且ramfs
不适合我。
scala> val fs = scalax.file.ramfs.RamFileSystem()
fs: scalax.file.ramfs.RamFileSystem = Ram File System
scala> val ramTmp = fs("/tmp/ensime")
ramTmp: scalax.file.Path = RamPath(/tmp/ensime)
scala> ramTmp.exists
res9: Boolean = false