Understanding String Table Size in HotSpot
In JDK-6962930[2], it requested that string table size be configurable. The resolved date of that bug was on 04/25/2011 and it's available in JDK 7. In another JDK bug[3], it has requested the default size (i.e. 1009) of string table be increased.
In this article, we will examine the following topics:
- What string table is
- How to find the number of interned strings in your applications
- The tradeoff between memory footprint and lookup cost
String Table
In Java, string interning[1] is a method of storing only one copy of each distinct string value, which must be immutable. Interning strings makes some string processing tasks more time- or space-efficient at the cost of requiring more time when the string is created or interned. The distinct values are stored in a string intern pool, which is the string table in HotSpot.
The size of the string table (i.e., a chained hash table) is configurable in JDK 7. When the overflow chains become long, performance can degrade. The current default size of string table is 1009 (or 1009 buckets), which is too small for applications that stress the string table. Note that the string table itself is allocated in native memory but the strings are java objects.
Increasing the size improves performance (i..e, reducing look-up cost) but increases the StringTable size by 16 bytes on 64-bit systems, 8 bytes on 32-bit systems for every additional entry. For example, changing the default size to 60013 increases the String Table size by 460K on 32 bit systems.
Finding Number of Interned Strings in the Applications
In HotSpot, it provides a product level option named PrintStringTableStatistics which can be used to print hash table statistics[4]. For example, using one of our applications (hereafter will be referred as JavaApp), it prints out the following information:
Number of buckets : 60013
Average bucket size : 5
Variance of bucket size : 5
Std. dev. of bucket size: 2
Maximum bucket size : 17
You can find the above output from your manged server's log file in the WebLogic domain. Note that we have set the following option:
- -XX:StringTableSize=60013
So, there are 60013 buckets in the hash table (or string table).
In JDK, there is also a tool named jmap which can be used to find out number of interned strings in your application. For example, we have found the following information using:
$ jdk-hs/bin/jmap -heap 18974
Attaching to process ID 18974, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.0-b43
using thread-local object allocation.
Parallel GC with 18 thread(s)
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 2147483648 (2048.0MB)
NewSize = 1310720 (1.25MB)
MaxNewSize = 17592186044415 MB
OldSize = 5439488 (5.1875MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 402653184 (384.0MB)
MaxPermSize = 402653184 (384.0MB)
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
PS Young Generation
<deleted for brevity>
Tradeoff Between Memory Footprint and Lookup Cost
Based on curiosity, we have tried to set the string table size to be 277331 (a prime number) to see how JavaApp performs. Here are our findings:
- Average Response Time: +0.75%
- 90% Response Time: +0.56%
However, the memory footprint has increased:
- Total Memory Footprint: -1.03%
Finally, here is the hash table statistics based on the new size (i.e., 277331):
StringTable statistics:
Number of buckets : 277331
Average bucket size : 1
Variance of bucket size : 1
Std. dev. of bucket size: 1
Maximum bucket size : 8
The conclusion is that increasing string table size from 60013 to 277331 helps JavaApp's performance a little bit at the expense of larger memory footprint. In this case, the benefit is minimal, keeping string table size to be 60013 is good enough.
References
Understanding String Table Size in HotSpot的更多相关文章
- MYSQL 遭遇 THE TOTAL NUMBER OF LOCKS EXCEEDS THE LOCK TABLE SIZE
今天进行MySql 一个表数据的清理,经过漫长等待后出现 The total number of locks exceeds the lock table size 提示.以为是table_cache ...
- mysql:The total number of locks exceeds the lock table size
使用mysql InnoDB存储引擎进行大量数据的更新,删除的时候容易引发”The total number of locks exceeds the lock table size”问题,解决方法之 ...
- 【转】ArrayList的toArray,也就是list.toArray[new String[list.size()]];,即List转为数组
[转]ArrayList的toArray ArrayList提供了一个将List转为数组的一个非常方便的方法toArray.toArray有两个重载的方法: 1.list.toArray(); 2.l ...
- MySQL配置文件路径及‘The total number of locks exceeds the lock table size’问题
在删除mysql中的数据时,遇到报错: ERROR 1206 (HY000): The total number of locks exceeds the lock table size 查了查,发现 ...
- mysql报错"ERROR 1206 (HY000): The total number of locks exceeds the lock table size"的解决方法
1. 问题背景 InnoDB是新版MySQL(v5.5及以后)默认的存储引擎,之前版本的默认引擎为MyISAM,因此,低于5.5版本的mysql配置文件.my.cnf中,关于InnoD ...
- 我眼中的 Nginx(二):HTTP/2 dynamic table size update
张超:又拍云系统开发高级工程师,负责又拍云 CDN 平台相关组件的更新及维护.Github ID: tokers,活跃于 OpenResty 社区和 Nginx 邮件列表等开源社区,专注于服务端技术的 ...
- Mysql_解决The total number of locks exceeds the lock table size错误
在操作mysql数据库表时出现以下错误. 网上google搜索相关问题,发现一位外国牛人这么解释: If you're running an operation on a large number o ...
- C# 调用存储过程出错:String[3]: Size 属性具有无效大小值 0
存储过程如下 Create PROCEDURE [dbo].[Test] @FundId int, @vchStrategyToken nvarchar(), @ErrorMessage nvarch ...
- MySQL解决[Err] 1206 - The total number of locks exceeds the lock table size问题
MySQL解决[Err] 1206 - The total number of locks exceeds the lock table size问题 查看MySQL版本:mysql>show ...
随机推荐
- load/domContentLoaded事件、异步/延迟Js 与DOM解析
一.DOMContentLoaded 与 load事件 关于load和DOMContentLoaded事件,mdn对于它们是这样描述的: DOMContentLoaded mdn文档地址:https: ...
- Redis队列——PHP操作简单示例
入队操作 <?php $redis = new Redis(); $redis->connect('127.0.0.1',6379); while(True){ try{ $value = ...
- scrollTop、offsetHeight和offsetTop等属性用法详解--转转转
scrollTop.offsetHeight和offsetTop等属性用法详解: 标题中的几个相关相关属性在网页中有这大量的应用,尤其是在运动框架中,但是由于有些属性相互之间的概念比较混杂或者浏览器兼 ...
- Spark系列(二) Spark Shell各种操作及详细说明
并行化scala集合(Parallelize) //加载数据1~10 val num=sc.parallelize(1 to 10) //每个数据项乘以2,注意 _*2记为一个函数(fun) val ...
- [saiku] schema文件分析
上一篇讲到了如何在管理台配置数据源 [ http://www.cnblogs.com/avivaye/p/4877767.html ] 这次来说明下shema文件里面是怎样配置Cube和角色权限的 通 ...
- MySQL 5.7 免安装版配置
MySQL5.7免安装版配置 Mysql是一个比较流行且很好用的一款数据库软件,如下记录了我学习总结的mysql免安装版的配置经验. 一. 软件下载 5.7 32位https://dev.mysq ...
- 带参数setTimeout
/* 功能:修改 window.setTimeout,使之可以传递参数和对象参数 使用方法: window.setTimeout(回调函数,时间,参数1,,参数n) ...
- centos7 ping www.baidu.com ping 不通。
centos7 ping www.baidu.com ping 不通. 记录下,在搭建NodeJS服务器遇到的坑:centos7 ping www.baidu.com ping 不通. 1. 配置网卡 ...
- 怎样给oracle数据库的用户解锁
找到并进入运行窗口:(可以用windows+r快捷键哦)输入sqlplus命令:如图 进入新窗口后使用scott/tiger用户和密码进行登录会发现登录不成功:如图 这时我们可以使用syste ...
- 【322】python控制键盘鼠标:pynput
参考:python实战===python控制键盘鼠标:pynput 参考:[Python Study Notes]pynput实现对鼠标控制 参考:pynput doc 参考:pynput Packa ...