Async Logger 是一款 Minecraft 模组,可将日志记录操作异步化。
在原版中,日志记录器并非异步运行。这意味着实际的日志记录操作(包括 I/O 操作)都在日志线程上执行。本模组将日志记录改为异步处理,以提升性能。
当大量消息被记录以及/或启用了调试日志(Forge / NeoForge 默认为启用状态)时,这尤其有用。
基准测试
| 项目 | Vanilla | AsyncLogger |
|---|---|---|
| 简单消息 (10k) | 6146.1ms | 141.2ms |
| 含占位符的消息 (10k) | 6413.2ms | 96.6ms |
| 含异常堆栈的消息 (1.5k) | 19572.4ms | 9.0ms |
你可以通过在配置文件中启用 testPerformance 自行进行这些测试。启用此选项后,模组会在设置异步日志记录器前后分别记录大量消息。你可以在日志中看到测试结果。
过滤
从 2.0.0 版本开始,AsyncLogger 支持日志过滤。过滤操作在专用的异步日志线程上进行,确保调用方不会产生额外开销。
使用方法很简单:只需在配置中将 filtering.enabled 设置为 true,然后编辑一个或多个过滤器即可。支持按日志记录器名称、级别和消息内容(匹配子字符串或正则表达式)进行过滤。
技术细节
Async Logger is a Minecraft mod that makes logging operations asynchronous.
In vanilla, loggers are not asynchronous. This means the actual logging operations, including I/O operations, happen on the logging thread. This mod changes logging to be asynchronous for better performance.
This can be especially useful when large amounts of messages are being logged and/or debug logging is enabled (default on Forge / NeoForge).
Benchmarks
| Item | Vanilla | AsyncLogger |
|---|---|---|
| Simple Messages (10k) | 6146.1ms | 141.2ms |
| Messages with Placeholders (10k) | 6413.2ms | 96.6ms |
| Messages with Throwable (1.5k) | 19572.4ms | 9.0ms |
You can do these tests yourself by enabling testPerformance in the config. When this option is enabled, the mod will log a large number of messages both before and after setting up async loggers. You can see the test results in the log.
Filtering
Starting from version 2.0.0, AsyncLogger supports log filtering. The filtering happens on the dedicated, async logger thread, ensuring there is no overhead for the caller.
To use, simply set filtering.enabled to true in the config, and edit one or more of the filters. Filtering by logger name, level, and message (match substring or regexps) is supported.
Technical Details
- Asynchronous loggers are used, in favor of Asynchronous appenders. The former is newer, faster and lighter on allocation rate.
- Asynchronous loggers require LMAX Disruptor, a lock-free inter-thread communication library. The mod will load the library onto the system classloader when it is not present. This mod redistributes LMAX Disruptor under the Apache-2.0 License.
- The config file allows easy control of some log4j2 settings.
System.outandSystem.errcan be redirected to loggers.
下载 Async Logger
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Async Logger
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Async Logger
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Async Logger
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Async Logger
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Async Logger
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Async Logger
下载 Async Logger
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Async Logger
下载 Async Logger
- 为 26.3 NeoForge 兼容性实现了
EarlyBootstrapper - 修复了 Mixin 兼容级别
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
缓冲的原始输入和线程化的事件轮询
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
原版世界生成优化模组
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
查看物品与配方
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
评论 0
登录后参与评分
还没有评论,来抢沙发吧