Java 中的快速内存操作?

发布于 2024-12-13 07:32:09 字数 1221 浏览 1 评论 0 原文

我是 Java 的新手(之前在嵌入式平台上使用过 C),所以如果这个问题非常微不足道,请原谅我。

我需要用Java实现一些信号处理算法。我知道 Java 可能不是执行此操作的最佳语言 [1],但提出 Java 要求主要是因为我团队的其他成员根本不熟悉 C。

我们需要做的就是读取一些包含视频帧的文件,处理它们(收集有关它们的一些统计数据),然后将它们写回磁盘。处理过程将涉及读取几 kB 的数据并以某种方式解析它们,可能会进行某种转换。即我预计我们需要进行大量字节寻址随机内存访问。我需要每秒执行大约 30 帧,每帧需要执行数万次此类操作(因此每秒可能执行 100 或 1000 次操作)

我不太了解 Java 的“内部结构”,但从什么角度了解 Java 的“内部结构”?我读到我相信 Java 看到的内存与操作系统本身提供的实际虚拟内存相距甚远[2]。

我应该使用哪些缓冲区管理库才能获得最佳性能?我见过一些(NIO [3]、Java 2d [4] 等),但我无法找到哪个更快,或者是否还有我缺少的其他选项。你们对我有什么建议或指示吗[5]?

我还将进行大量算术运算,那么是否有任何库可以进行“更快”的算术运算?我来自一个可以在硬件上加速几乎所有内容的世界,但现在我需要在 PC 上运行它,所以我不确定是否有任何此类选项可用。

如果你们能提供任何其他建议或帮助,我们将不胜感激!

I am a bit of a newbie to Java (prior experience with C on embedded platforms), so please forgive me if this question is very trivial.

I need to implement some signal processing algorithms in Java. I know Java is probably not the best language to do this [1], but the Java requirement has come in primarily because the rest of my team is not comfortable with C at all.

What we need to do at a high level is to read some files containing video frames, process them (gather some statistics about them) and then write them back to disk. The processing will involve reading in a few kB of data and parsing them somehow, possibly with some kind of transforms. i.e. I expect we will need to do a lot of byte-addressed random memory accesses. And I'll need to do about 30 frames per second and a few tens of thousands of such operations every frame (so possibly 100s of 1000s of ops per second)

I do not know the 'internals' of Java very well, but from what I read I believe the memory that Java sees is far abstracted from the actual virtual memory that the OS itself provides [2].

What buffer management libraries should I use so that I can get the best possible performance? I've seen a few (NIO [3], Java 2d [4], etc) but I am not able to find which is faster, or if there are any other options that I am missing. Do you guys have any suggestions or pointers [5] for me?

I will also be doing lots of arithmetic, so are there any libraries that do 'faster' arithmetic? I come from a world where I could accelerate almost everything on the hardware but now I need to run this on a PC so I am not sure if there are any such options available.

Any other suggestions or help you guys could provide will be much appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文