简体   繁体   English

Java中的I / O优先级

[英]I/O prioritization in Java

I'd like to use of the Vista+ feature of I/O prioritization . 我想使用I / O优先级的Vista +功能。 Is there a platform independent way of setting I/O priority on an operation in Java (eg a library, in Java 7) or should I revert to a sleeping-filter or JNx solution? 是否存在独立于平台的方式来设置Java(例如Java 7中的库)中的操作的I / O优先级,还是应该恢复为睡眠过滤器或JNx解决方案? Do other platforms have a similar feature? 其他平台是否具有类似功能?

If you really need to use this feature and you really want to do this in Java, you can always use Java JNI to hook the JVM into your own, custom C/C++ implementation of an I/O handler. 如果您确实需要使用此功能,并且确实要在Java中执行此操作,则始终可以使用Java JNI将JVM挂钩到您自己的I / O处理程序的自定义C / C ++实现中。 It allows you to write native (OS specific) code and call it from a Java application. 它允许您编写本机(特定于OS的)代码并从Java应用程序中调用它。

From a google search it does not seem that Java supports IO Prioritization yet. 从谷歌搜索看来,Java似乎还不支持IO优先级。

Windows Vista does but I don't know anything about it. Windows Vista可以,但我对此一无所知。 Is it per process or more fine-grained? 是每个进程或更细粒度的吗?

Linux since 2.6.13 supports ionice(1), which will set IO priority on a per process basis. 从2.6.13开始的Linux支持ionice(1),它将基于每个进程设置IO优先级。

This is the kind of thing that is difficult for Java to support because it depends heavily on the capabilities of the underlying operating system. Java很难支持这种情况,因为它很大程度上取决于基础操作系统的功能。 Java tries very hard to offer APIs that work the same across multiple platform. Java尽力提供跨多个平台使用相同功能的API。 (It doesn't always succeed, but that's a different topic.) (它并不总是成功,但这是一个不同的主题。)

In this case, a Java API would need to be implementable across multiple versions of Windows, multiple versions of Linux, Solaris, and various other third party platforms. 在这种情况下,Java API必须能够在Windows的多个版本,Linux,Solaris的多个版本以及其他各种第三方平台上实现。 Coming up with a platform independent model of IO prioritization that can be mapped to the functionality of the range of OS platforms would be hard. 想出一个可以映射到OS平台范围功能的,与平台无关的IO优先级模型。

For a now, I suggest that you look for a platform specific solution that goes outside of Java to make the necessary tuning adjustments; 现在,我建议您寻找Java之外的平台特定解决方案,以进行必要的调整。 eg use Process et al to run an external command, or do the work in a wrapper script before starting your JVM. 例如,使用Process等运行外部命令,或者在启动JVM之前在包装脚本中完成工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM