本次更新的一个重点:完成 JDK21 编译测试和功能单元测试。
JDK 21 虚拟线程?
在IO密集型项目中,效果很猛!有一种:天哪天哪天哪。。。的感觉
@SolonMain
public class App {
public static void main(String[] args) {
Solon.start(App.class, args, app->{
app.onEvent(HttpServerConfigure.class, e->{
e.setExecutor(Executors.newVirtualThreadPerTaskExecutor());
});
});
}
}
Solon 是什么框架?
Java 生态级应用开发框架。从零开始构建,有自己的标准规范与开放生态(历时五年,具备全球第二级别的生态规模)。与其他框架相比,解决了两个重要的痛点:启动慢,费内存。
解决痛点?
由于Solon Bean容器的独特设计,不会因为扩展依赖变多而启动很慢(开发调试时,省时、爽快)!以知名开源项目“小诺”为例:
- “snowy-spring 版” 启动 15-50秒
- “snowy-solon 版” 启动3-5秒,启动内存节省1/3(有兴趣的,欢迎拉取代码体验)
有什么可爱的特点?
- 启动快 5 ~ 10 倍。 (更快)
- qps 高 2~ 3 倍。 (更高)
- 运行时内存节省 1/3 ~ 1/2。 (更少)
- 打包可以缩小到 1/2 ~ 1/10;比如,300Mb 的变成了 23Mb。 (更小)
- 同时支持 jdk8, jdk11, jdk17, jdk21, graalvm native image
入门探索视频(用户录制):
最近更新了什么?
- 完成 JDK21 编译测试,功能单元测试(for JDK21)
- 添加 HttpServerConfigure::setExecutor 接口,用于支持虚拟线程池(for JDK21)
- 添加 PropUtil 类。把原来的属性表达式与模板解析独立出来
- 添加 ContextPathListener 类,用于控制 contentPath 对 ws,tpc 的影响
- 添加 ContextPathFilter 一个简化的构造函数
- 添加 MethodHolder::getDeclaringClz、getDeclaringClzAnnotation 接口
- 添加 yaml 多片段支持(即一文件多环境支持)
- 添加 多配置文件交差引用变量支持
- 添加 DownloadedFile(file,name) 构造函数
- 添加 Router 对 405 的支持
- 调整 RunUtil 执行器分离为 parallelExecutor + asyncExecutor(for JDK21)
- 调整 CacheService 接口(增加类型化 get)
- 调整 SessionState 接口(增加类型化 get)
- 调整 Context::session 接口(增加类型化 get)
- 调整 BeanWrap 的 rawSet 改为公有
- 调整 SolonApp::enableWebSocketMvc, enableSocketMvc, 默认为 false
- 调整 SolonApp::enableWebSocket, enableWebSocketD 分离设置,各不相关
- 调整 CloudConfig 复用主框架的属性表达式与模板解析
- 调整 Listener 去掉 @FunctionalInterface,所有方法标为 default
- 调整 ChainManager::postResult 的执行策略改为包围式(相当于倒序)
- 调整 ValHolder 标为弃用
- 调整 jdkhttp,jlhttp,smarthttp 的 contentLength 适配处理
- 调整 使用更多的 slf4j 替换 bus
- 调整 mybatis-solon-plugin 的会话提交方式,修复二级缓存控制可能失效的问题
- 调整 "solon.config.load" 支持按顺序加载
- 调整 几个特定启动参数的处理方式。改与成 Solon.cfg() 同步,再统一从 Solon.cfg() 取值
- 调整 启动参数与系统属性的同步时机
- wood 升为 1.2.1
- redisx 升为 1.5.0
- mybatis-flex 升为 1.6.5
- sqltoy 升为 5.2.66
- polaris 升为 1.14.1
- lombok 升为 1.18.28
- slf4j 升为 2.0.9
- lombok 升为 1.18.30(for JKD21)
- asm 升为 9.5 (for JDK21)
2023-09-22 10:50
虚拟线程遥遥领先,C#落后了”这种货色的言论,一个虚拟线程,被操作系统玩烂的东西,除了无知不就是蠢,你急啥?你也一样蠢么
Virtual threads support thread-local variables (ThreadLocal) and inheritable thread-local variables (InheritableThreadLocal), just like platform threads, so they can run existing code that uses thread locals. However, because virtual threads can be very numerous, use thread locals only after careful consideration. In particular, do not use thread locals to pool costly resources among multiple tasks sharing the same thread in a thread pool. Virtual threads should never be pooled since each is intended to run only a single task over its lifetime. We have removed many uses of thread locals from the JDK's java.base module in preparation for virtual threads in order to reduce memory footprint when running with millions of threads.
The system property jdk.traceVirtualThreadLocals can be used to trigger a stack trace when a virtual thread sets the value of any thread-local variable. This diagnostic output may assist with removing thread locals when migrating code to us