mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
进行第一阶段的调试修复
- 添加 DebugMonitor 加了一个较为无用的线程,打上断点用于获取即时模块信息 - 调整 MemoryGraph 中临时切片前后序生成容器与日期索引分离,日期索引将存储 localDate 和 memoryId - 修复了几个 MemoryGraph 用到的类对于序列化的实现 - 将 MemoryManager 中维护的 activatedMemorySlice 同样作为主题提取的依据,并调整了提示词 - 因 主题提取LLM 效果不稳定,故添加了必要的异常处理机制 - MemorySlice 中前后序机制存在循环引用问题,排除 toString 的调用 - 移除了提示词中过多的示例,仅保留一份 - 记忆自动更新线程调整:在 SessionManager 中维护 lastUpdatedTime ,用于标识最近聊天时间; 计数当前对话数量,如果只有系统提示词则不进行记忆更新 - MemoryGraph 获取主题树时将标识记忆节点数量,供主题提取模型识别,减少空主题节点作为目标节点的情况 - 在 PreprocessExecutor 执行时将先判断是否存在memoryId, 除此之外,memoryId也将在记忆自动更新线程执行后刷新 - 将 SessionManager 添加了序列化机制,添加了程序停止时自动序列化保存的钩子 - 当主题提取模型指定了不包含记忆节点的主题节点时,MemoryResult 的空属性将会使其跳过无效的切片评估 待解决问题: - MemoryGraph 在进行记忆更新时有时会出现错误,出现条件不明 - MemorySelector 拿到的List<EvaluatedSlice> 总是为空,原因不明 - 切片评估线程似乎没有运行,原因不明
This commit is contained in:
@@ -1,34 +1,30 @@
|
||||
package memory;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ThreadPoolTest {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
testExecutor(Executors.newVirtualThreadPerTaskExecutor());
|
||||
|
||||
// Thread.sleep(2000); // 等待系统输出稳定
|
||||
|
||||
// testExecutor("普通线程池", Executors.newFixedThreadPool(100));
|
||||
}
|
||||
|
||||
private static void testExecutor(ExecutorService es) throws InterruptedException {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
es.submit(() -> {
|
||||
Thread.sleep(1000);
|
||||
return 0;
|
||||
@Test
|
||||
public void testExecutor() throws InterruptedException {
|
||||
List<Callable<Void>> tasks = new ArrayList<>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
int finalI = i;
|
||||
tasks.add(() -> {
|
||||
System.out.println("开始: " + finalI);
|
||||
Thread.sleep(5000);
|
||||
System.out.println("结束: " + finalI);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
es.shutdown();
|
||||
if (es.awaitTermination(5, TimeUnit.MINUTES)) {
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println("虚拟线程" + "耗时:" + (end - start));
|
||||
} else {
|
||||
System.err.println("虚拟线程" + "未能在规定时间内完成所有任务");
|
||||
}
|
||||
Executors.newVirtualThreadPerTaskExecutor().invokeAll(tasks, 10, TimeUnit.SECONDS);
|
||||
|
||||
System.out.println("hello");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user