使用jbcrypt时性能可变且性能下降 [英] Variable and degrading performance when using jbcrypt

查看:148
本文介绍了使用jbcrypt时性能可变且性能下降的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jbcrypt来哈希项目中的密码。在我正在使用的硬件上验证密码时,性能大约为500毫秒(log_rounds设置为12)。
然而,经过一段时间的常规使用后,表演时间突然下降到惊人的15秒。下降非常突然,没有累积,并且在重新启动过程之前保持不变。

I'm using jbcrypt to hash passwords in a project. Performance is about 500 ms when validating passwords on the hardware I am using (log_rounds set to 12). However, after a while with regular use the performance time suddenly drops to a whopping 15 seconds. The drop is very sudden with no buildup and stays constant until the process is restarted.

分析显示在密钥(..)方法中使用了额外的时间。

Profiling shows that the extra time is used in the key(..) method.

来源:< a href =http://jbcrypt.googlecode.com/svn/tags/jbcrypt-0.3m/src/main/java/org/mindrot/jbcrypt/BCrypt.java =noreferrer> http:// jbcrypt .googlecode.com / svn / tags / jbcrypt-0.3m / src / main / java / org / mindrot / jbcrypt / BCrypt.java

此方法仅使用xor,and,shift等基本函数计算哈希值。没有对象分配,外部资源的使用,随机数生成等。

This method only calculates the hash using basic functions like xor, and, shift etc. There is no object assignments, usage of external resources, random number generation etc.

性能不会下降用于同一过程中的其他功能。内存分配稳定且低。不涉及完整的GC。

Performance does not drop for other functionality in the same process. Memory allocation is stable and low. Full GC is not involved.

有没有人见过这个或为什么会发生这种情况的任何线索?我可以理解在某种程度上取决于其他情况的可变性能,但这是从大约500ms的非常突然和稳定的下降。大约15000毫秒。

Has anyone seen this before or any clue to why this happens? I could understand a variable performance that to some degree was dependent on other circumstances, but this is a very sudden and stable drop from about 500ms. to about 15000 ms.

推荐答案

事实证明这与类加载有关。该库加载了许多不同的类加载器。当我们在系统类加载器中加载库时,问题就消失了。

It turned out that this had something to do with classloading. The library was loaded in many different classloaders. The problem disappeared when we loaded the library in the system classloader.

这篇关于使用jbcrypt时性能可变且性能下降的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆