Java Performance: the top 5 pigs

tanner2019安装教程 tanner2019安装教程 tanner安装包 软件由老师提供,但由于老师给的方法不知怎么回事无法使用就自己找了一些方法,本教程仅提供参考 链接:https://pan.baidu.com/s/1A2O6JuEF8YFbe8bPnD3J6w 提取码:ysif 复制这段内容后打开百度网盘手机App,操作更方便哦 安装过程 1.选择TannerTools_v2019.2-Win64.exe,进行安装。 2.选择安装产品 3.选择目标路径 4.确认安装 5.安装成功,退出。 获取许可过程 1.打开key压缩 阅读详情
 java antipatterns

 

Home    Books    Boards    Newsletter    Resources    About    Contacts

Java Performance: the top 5 pigs

(from September Bitter Java newsletter)

I recently completed a performance-tuning gig with a customer. The Internet message board had nothing to do with Java. Instead, it was in a language that I have rarely used, but all of the major problems were familiar to me. In general, the database was not optimized, the application did not connection pool and there was no caching. After we fixed those problems and removed some unnecessary database writes, the performance improved by a full order of magnitude. As a consultant, those problems are common to many of my customers. That prompted this article, which lists my top 5 Java performance pigs.

1. Round tripping.

The most common way to separate user interfaces is through the use of a well-known design pattern called Model/View/Controller. When the user interface and the model are distributed, there is significant potential for round-tripping. This anti-pattern occurs when we choose to iterate over a major system boundary. Figure 1 shows the iteration over user interface fields across a major interface boundary. The left hand side of the figure represents the model, and the right hand side represents the view. The underlying implementation does not matter. We could be using an applet to implement the view, or we could be using a multi-layer implementation with servlets or JSPs to render a dynamic view. Either way, the direct access of the model's fields that map onto user interface fields is a prime example of round tripping, and can significantly hinder optimal performance. Each field will require a round-trip communication between the client and server, which is not too expensive, until the cumulative effects are multiplied. EJB models that populate list boxes or tree components are especially troublesome.

Distributed tools, like EJBs, make it easy to do. A common Internet topology has the web server and servlet container, or web application server, deployed in the DMZ with EJBs deployed inside the corporate firewall. With this configuration, a common mistake is to make a distinct call to the EJB layer for every field required by the user interface. This gets extraordinarily expensive. It is much better to buffer all of the calls together, and make them in one trip. Common design patterns that accomplish this technique are the façade pattern and the distributed command bean.


A good caching model can cover up a whole lot of bad implementation. The best way to hide a bad enterprise architecture is to eliminate its use for the expected case. Caching can dramatically reduce round tripping. Caching in front of enterprise data access can turn a network communication and a database access to a simple memory read and a page build. A cache for static content can be placed upstream of an entire Internet architecture, including the dispatcher, saving an amazing amount of traffic and system load. JSP fragments can be cached, saving servlet execution time. Together, these effects are cumulative. This figure is an adaptation of the figure in an article called ScalingUp e-business Applications with Caching by Mike Conner, George Copland, and Greg Flurry, at http://service2.boulder.ibm.com/devtools/news0800/art7.htm#toc6. Caching in the network, the edge servers and throughout the dynamic application saves nearly an order of magnitude:



2. Overuse.

Object-oriented tools and models make it very easy to use complex models. Sometimes, complexity is too easy to achieve. Consider EJB development environments. In many cases, making an entire object model persistent involves just a few keystrokes. While this development style is easy to accomplish with good tools, it is difficult to make such a model perform well. A better approach is to look at the objects in a model, and see which ones make the most sense as persistent EJBs. Objects having requirements to be persistent, transactional and shared are the best candidates. Some objects may not need to be persistent at all. In other cases, tables like tax tables that rarely change can be implemented more efficiently with other means, like a stateless session bean. In other cases, special considerations may make bean managed persistence the choice over container-managed persistence. Careful, premeditated choices usually trump system-wide EJB deployments.
There are other common examples of overuse. When large teams or geographically distributed teams work together on complex problems, the number of layers can get out of control because of lack of communication. Taligent, which had many of the best object-oriented analysts in the world, may have developed a fatal case of this disease. User interfaces, which can be heavily layered, have frequently created more events than even the fastest processors could handle. Deep inheritance graphs can make code all but unreadable, and require a stiff performance tax.

3. Poor database design or integration.

This problem is definitely not unique to Java, but poor database integration has bitten this community especially hard. The ease at which modern development environments allow database access is, in some ways, alarming. I have talked to several startups with production, data driven businesses that had no DBA on the staff. It is easy to develop database models with no organizational forethought or any index structure at all. For significant deployments, a good data design, good integration between the database and application, and a strong management philosophy and execution are critical success factors. These tips can go a long way toward good integration:

  • The database model is not the same thing as an object model. Develop a strategy that will allow strong, efficient access of database data, with minimal redundancy and good performance. Also, develop a strategy for the management of mapping the object model to the database, such as the employment of a mapping layer like TopLink. If necessary, get some consulting help to build a strong data model.

  • Use Explain. Most database environments have a tool that explains the access plan for queries. The access plan is the algorithm that a database engine will use to process a query. Shorter tables may be processed quickly by loading the entire tables into memory, but watch for table scans of larger tables, which can indicate performance problems. Usually, in these cases, the use of an index is much faster.

  • Make sure that statistics are run at regular intervals, and that the database is tuned correctly. Statistics are used to help the optimizer make good decisions. Two important tuning parameters for most databases are the row buffer (which is basically a in-memory cache) and the lock list. A large row buffer will allow frequently accessed database rows to stay in memory, so that subsequent reads do not have to access the disk. A large lock list will help to avoid unnecessary lock escalation (where the database trades in many row level lock for a single table level lock, badly crippling concurrent access.)

  • Watch long units of work. They can accumulate too many locks, eat up log space, and harm concurrency.

4. Too many web objects.

Internet performance has gotten much better over time. Bandwidth has improved, especially over the last mile, or the connection between the customer and the formal internet access at the Internet service provider. Many user interface designers are using improved performance as an excuse to get sloppy. In fact, applications with a high number or very large objects can take significantly longer to load. Consider this screen shot of an application from IBM called Page Detailer:

The figure shows the objects and total load time of amazon.com. There are forty-six total items, and it takes the whole page over five seconds to load. By contrast, consider the page detail for yahoo.com:

Four items take a half of a second to load! Though there is dynamic content, the Yahoo page is lightning fast, and is a textbook example of simplicity and function in an interface. I should probably practice what I preach, because both the Bitter Java and J2Life sites have a good number of graphics, but neither yet has the traffic to demand simplification. In situations where the volume is low or other dynamic contents are very high, a relatively large number of graphics or very large objects might not matter, but in cases where relatively short load times are being improved, it makes sense to reduce the complexity of the user interfaces by decreasing the total number of graphics.

5. Concurrency control.

Java builds in features to control concurrent access to critical sections of code. Java concurrency control is done on the object level. An object having a synchronized method has a semaphore. When the method is entered, a thread requests the semaphore, and releases it when it exits the method. The synchronized keyword therefore means that only a single thread, per object, can access a particular method. It is not free, though. Synchronization can be overused, and fully synchronizing methods can be too heavy handed. These three tips can help to refactor overly restrictive code.

  • If only a portion of a method needs synchronization, use synchronized blocks around critical sections instead of synchronizing entire blocks. This is an example of a synchronized block of code, which creates an object for use as a semaphore:

    Object mutex;
    Subject mutex;
    synchronized(mutex)
    {
    // critical section
    }

  • Identify critical resources and code fragments, and surround only those critical sections with synchronized sections. Overuse of synchronized carries a performance penalty and also restricts concurrency.

  • In many instances, exclusive locks are too restrictive. For many applications, readers can share access to a resource, but writers need exclusive access. Using synchronized objects in this case is too restrictive, especially if reads are more common than writes. A good example is a hash table as a cache. Restricting access with the synchronized keyword blocks all readers if any one has access, which is much too restrictive. In this case, read/write locks can be used. There are many examples. This is one that I have used successfully: http://home.earthlink.net/~kohliaman/technical/rwlocks.html.


Honorable Mentions

Lazy or ignorant choice of algorithm or class. We have all used an o(n2) bubble sort where an o(n log n) shell sort would work better. Applications that require random access to a collection with no traversal should use an o(1) hash table rather than an o(n) array.

Poor memory management. We've all seen optimizations from the local wizard render clear code completely unintelligible for the big payoff of three bytes in an obscure block of error handling code. Granted, memory management is less important today. However, objects allocated for session state or custom connection frameworks are multiplied, so they are not the places to get complacent.

Applets. New customers to Java invariably try them, and the download times are still dog slow. It's generally much better from a performance and systems management standpoint to try to make a HTML user interface fly.

Summary

Java performance depends mainly on reducing round-trip communications, using resources wisely, and minding the performance of other systems like databases and user interfaces. In my experience, the two biggest performance boosters are the addition of a cache and effective control of round-tripping. If you would like to discuss these or others, please feel free to check out the message boards.

by Bruce A. Tate

uniapp(全端兼容) - 最新详细uniapp全平台植入使用echarts图表插件,引入 Echarts 图表及使用详细教程,提供各种图表使用示例(拒绝复杂的过程,附带详细的使用示例保姆级教程) uniapp 微信小程序 echats 图表,uni-app小程序引用echarts,niapp 微信小程序引入echats教程,uniapp 使用echats图表,uniapp开发如何在微信小程序平台使用echats图表,uniapp开发的小程序中怎么用echats,在uni-app中编译到微信小程序如何使用echarts,UNIAPP微信小程序使用Echarts,uni-app微信小程序使用echarts,Uniapp小程序端使用echarts最详细的教程,uni-app中使用Echarts绘画图表,u 阅读详情

相关推荐

ANSYS WB 网格划分详解与技巧

本文详细介绍了网格操作中的关键设置与功能选项。主要内容包括:1)网格显示风格与物理偏好设置;2)单元阶次选择对精度的影响;3)单元尺寸控制方法;4)尺寸调整功能,重点讲解了自适应尺寸调整、增长率控制和捕获曲率等选项;5)网格质量评估标准;6)四种主要划分方法(四面体、六面体主导、扫掠、多区域)的特点与适用场景;7)三种尺寸调整方式(直接调整、边缘尺寸调整、影响范围调整)的具体应用。文章强调在实际建模中需要根据模型特点合理选择网格参数,平衡计算精度与效率。

2403_87939837的博客 1697

简单的网页关键词匹配工具

简单的网页关键词匹配工具作者:Monica Pawlan2003年7月 你是否曾经使用大量的详细信息创建网页,然后希望读者可以使用一种简单的方法,根据特定于用户的关键词分析和进入相应页面?本文解释了如何使用HTML表单和JSP技术来正确地实现上述要求。即使你从没希望得到这种效果,你可能也会发现本文的演示例子和代码练习十分有用,因为这些例子和代码涵盖了如何检索请求的值,并将这些值与静态文件中

fraternity_java的专栏 2409

手把手教你用TBtools+MCScanX完成玉米基因家族共线性分析(附完整代码)

本文提供了一套完整的玉米基因家族共线性分析实战流程,详细讲解了如何从数据准备、格式处理开始,利用DIAMOND进行快速比对,再结合MCScanX进行核心共线性区块鉴定,最后通过TBtools实现从全基因组圈图到特定基因家族微共线性图的可视化。教程包含可直接运行的代码与常见问题解决方案,帮助研究者高效完成从命令行计算到图形化展示的全过程。

tech5的博客 591

使用JFreeReport生成报表

使用JFreeReport生成报表作者:肖菁文章摘要JFreeReport用于生成报表。JFreeReport的数据继承自Swing组件的TableModel接口,使用基于XML的报表格式定义文件对报表进行格式化。JFreeReport生成的报表可以分页预览、打印或者保存为多种格式的文件如pdf、Excel、html等。作者在本文中详细的介绍了如何定义报表格式定义文件、如何使用JF

fraternity_java的专栏 2144

C#精准获取Windows已安装应用清单的完整方案

Windows已安装应用识别是IT资产管理、安全合规与自动化运维的基础能力。其核心原理在于突破文件系统表象,以注册表为可信数据源,分层解析HKLM/HKCU、64位/32位视图及MSI Products路径中的元数据。技术价值体现在可验证(如过滤SystemComponent=1)、可关联(通过ProductCode绑定补丁与许可证)、可操作(启动路径二次验证+卸载命令沙箱执行)。典型应用场景包括终端合规审计、软件资产清查、静默卸载脚本开发及多版本应用聚合分析。本文聚焦C#原生实现,覆盖注册表四路采集、La

weixin_33552698的博客 634

微信PC端Multi文件夹数据库解析:语音消息导出与转换实战指南

本文提供了一份详细的微信PC端语音消息导出与转换实战指南。通过解析Multi文件夹中的MediaMSG数据库,指导用户定位、解密数据库,并利用Python脚本精准提取SILK格式语音,最终转换为通用的WAV或MP3格式,实现个人语音数据的本地备份与处理。

garlic的博客 582

Weighing in on Java native compilation

Weighing in on Java native compilationContents:Code compilation basicsAbout the test setupTest 1: Prime.java

fraternity_java的专栏 1800

适航文章汇总:知识体系全面梳理

无论您是行业新手还是经验丰富的专业人士,都可以通过本篇文章快速查找相关资料,提高对适航认证、机载系统、软件及硬件等领域的理解。本部分详细解析ARP 4754A、ARP 4761、DO-178C、DO-254等核心标准,并介绍其在机载系统开发中的应用。介绍FAA、EASA、CCAR等主要航空管理机构的适航规章体系,并说明各类飞行器(如固定翼、旋翼机、无人机等)的适航要求。本部分还探讨硬件设计、验证与确认过程中的挑战。从系统架构设计到机载设备的集成与管理,本部分介绍机载系统的研发体系及适航管理的最佳实践。

qq_41854911的博客 1450

Performance of Java versus C++

Performance of Java versus C++ On the Persistence of (Java) Performance Myths -->J.P.Lewis and Ulrich Neumann Computer Graphics and Immersive Technology Lab University of Southern Californ

fraternity_java的专栏 1705

OpenCV实战(1)——OpenCV与图像处理基础

OpenCV 是一个跨平台计算机视觉和机器学习库,实现了图像处理和计算机视觉方面的很多通用算法。本节将介绍 OpenCV 的基础知识,以及如何编译运行 OpenCV 程序,并介绍如何完成最基本的图像处理任务——读取、显示和保存图像。除此之外,鼠标事件和图形绘制也是 OpenCV 计算机视觉项目中常用的基本功能,本节介绍了如何使用这两个重要的 OpenCV 功能。

盼小辉丶的博客 12万+

万字长文:YOLOv5+RK3588 NPU多线程加速全攻略——从理论到部署的终极优化

RK3588 NPU多线程加速优化教程摘要 本教程深入讲解了如何利用线程池技术优化RK3588 NPU上的YOLO目标检测模型推理性能。RK3588内置3个NPU核心,理论算力达6TOPS,为多线程优化提供了硬件基础。教程详细解析了线程池的核心组件(任务队列、工作线程、同步机制)和实现架构,包括类设计、初始化流程、工作线程逻辑(任务获取、NPU推理、结果存储三个阶段)以及任务提交/获取机制。通过预分配模型实例、线程绑定、流量控制等优化手段,实现了从单线程28FPS到多线程120FPS的显著性能提升,为边缘A

LXY_LOVE36的博客 1101

SOA 比 Web Services 涵义更广

标题:SOA 比 Web Services 涵义更广 浏览次数: 12 时间:2004-08-31作者:Steve Wilkes无论何时在街上问一个了解点技术的普通人有关面向服务的架构(SOA)的概念,首先反应到他的头脑中的东西将是Web Services。尽管SOA已经存在一段

fraternity_java的专栏 1115

SPICE仿真软件:PSpice_(10).噪声分析

噪声分析是电路设计和优化中的一个重要工具,特别是在低噪声放大器、传感器电路和通信电路中。通过准确设置噪声源和仿真参数,合理选择频率范围,并验证仿真结果,可以有效地评估和优化电路的噪声性能。PSpice提供的噪声分析功能强大且灵活,能够帮助工程师和研究人员在多种应用场景下进行详细的噪声分析。

kkchenjj的博客 1536

Design Patterns 入門 - 職責鏈(Chain of Responsibility) [精華]

Design Patterns 入門 - 職責鏈(Chain of Responsibility) [精華] 其實職責鏈(Chain of Responsibility)的概念,即使是一個剛學程式設計的新手也會用到,一個簡單的 if...else if ... else 流程控制就有職責鏈的概念:if(/* 符合請求條件一 */) // 執行請求一el

fraternity_java的专栏 1048

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

JSP学习心得

标题:JSP学习心得 浏览次数: 1443 时间:2003-08-30作者:徐春金下面是本人在学习JSP时的一些心得: 一、JSP工作原理在一个JSP文件第一次被请求时,JSP引擎把该JSP文件转换成为一个servlet。而这个引擎本身也是一个servlet,在JSWDK

fraternity_java的专栏 1045

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

测试J2EE Web Services

标题:测试J2EE Web Services 浏览次数: 46 时间:2004-08-31作者:Abhijit Patil 和 Seetharam Param我们已经了解了很多关于Web Services开发方面的知识,而对于Web Services测试所面临的挑战却知之甚少。本

fraternity_java的专栏 1031

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

用JAVA访问共享文件系统

用JAVA访问共享文件系统作者:薛谷雨前言在Microsoft 网 络 系 统 中,SMB(Server Message Block, 服 务 信 息 块) 协 议 是Windows for Workgroup(WfWg)、Windows 95、Windows NT 和LanManager 用 来 实 现 共 享 局 域 网 上 文 件 和 打 印 机 的 协 议。 对 于 利 用

fraternity_java的专栏 926

12个最重要的J2EE最佳实践(一)

12个最重要的J2EE最佳实践(一) 作者:Kyle Brown, Keys Botzum, Ruth Willenborg 发文时间:2004.07.15为了不使问题复杂化,我们就使用——最重要的 12个 J2EE 最佳实践…… 最佳实践 1、始终使用 MVC 框架。2、在每一层都应用自动单元测试和测试管理。 3、按照规范来进行开发,而不是按照应用服务

fraternity_java的专栏 794

用jsp动态输出excel文档和中文乱码问题的解决

用jsp动态输出excel文档和中文乱码问题的解决作者:陈万飞最近在网上看到一个用java来操纵excel的open source,在weblogic上试用了一下,觉得很不错,特此向大家推荐一下。首先去http://www.andykhan.com/jexcelapi/index.html下载最新的JExcelApi,把jxl.jar置于你的classpath中。写一个ja

fraternity_java的专栏 762

J2EE 1.4 的新特性

标题:J2EE 1.4 的新特性:概述 浏览次数: 1027 时间:2004-04-29作者:Dave LandersJ2EE开发人员所需掌握的技术列表是相当冗长的。在这篇文章里,我们不会讨论J2EE技术,甚至也不会讨论新技术。我们将要探讨的是它的一些主要的新特性,然后您就会知道

fraternity_java的专栏 744

Java常见问题集锦25问:

Java常见问题集锦25问: 1、问: 如何设置Java 2(JDK1.2)的环境变量? 答: Java 2安装后,需要设置PATH和JAVA_HOME环境变量.与JDK1.1不同的是:设置好JAVA_HOME环境变量后,JVM将自动搜索系统类库以及用户的当前路径. Java 2环境变量的设置如下例所示: Solaris平台: setenv JAVA

fraternity_java的专栏 671

InnoDB 内存结构总览:Change Buffer、AHI 与 Log Buffer

本文系统梳理InnoDB内存结构中的ChangeBuffer、Adaptive Hash Index(AHI)与LogBuffer。ChangeBuffer缓存二级索引页不在内存时的变更,减少随机IO,仅在页加载时合并;聚簇索引修改立即执行,因数据本身不可延后。AHI基于高频等值查询自动构建哈希索引,加速定位,仅支持等值操作。LogBuffer为redo log内存缓冲,配合磁盘日志实现崩溃恢复。三者均服务于性能优化,其中ChangeBuffer与AHI共享BufferPool空间,而LogBuffer独立

bksczm的博客 68

Spring AI + GPT-5.5 + Ollama 配置教程:Base URL、超时与流式调用

由于不同 Spring AI、Spring Boot 小版本之间仍可能存在差异,创建项目时应检查 Spring Initializr、Spring AI BOM 和官方兼容矩阵,不要直接复制旧教程中的 Starter 名称和版本号。多人项目最好隔离不同客户端,并在脱敏前提下记录最终 URL、状态码、请求耗时、请求 ID 和模型 ID。Spring AI 接入模型 API,至少要同时确认 Starter、Base URL、请求路径、API Key、模型 ID、连接超时、读取超时和流式客户端这 8 项。

2601_95893075的博客 226

V8 机制、手写核心函数与 TypeScript 类型体操

或固定初始化(如数组先定长、对象先给全字段)保持类型与形状稳定;这些都比"换框架"更基础。只能处理纯数据(丢函数、Date、RegExp、循环引用报错)。生产级深拷贝要处理:原始值短路、循环引用、V8(Chrome / Node 的 JS 引擎)不是"解释一行跑一行"那么简单,它用。图:V8 执行流程——解释执行 + 热点优化,优化失败会 Deopt 回退。JS 内存自动管理,但"自动"不等于"不会漏"。是"固定间隔最多执行一次"。手写 Promise 是"懂异步"的试金石。是"停下后才执行最后一次",

qq_38468358的博客 334

Java EE 进阶:8.MyBatis 操作数据库(入门)(第一弹)

Java EE 进阶:8.MyBatis 操作数据库(入门)(第一弹)

要努力去发光,而不是被照亮~ 123

Spring Boot 数据源与 MyBatis(-Plus) 自定义配置详解

本文详解 Spring Boot 中单数据源环境下 HikariCP 与 MyBatis-Plus 的自定义配置。通过手动声明 SqlSessionFactory,实现下划线转驼峰、日志输出、一级缓存策略等精细化控制。结合 HikariCP 核心参数调优(如最大连接数、连接生命周期),确保高性能与稳定性。适用于仅需访问单一数据库的场景,避免多数据源复杂性,兼顾性能与可维护性。

BADAO_LIUMANG_QIZHI的博客 196
上一篇: Performance of Java versus C++
下一篇: 图像合成
fraternity_java
博客等级 码龄22年 1粉丝 30原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值