G1
最大的卖点在于把内存分成不同的 region,有 Young GC、MixedGC、Full GC
G1
最大的卖点在于把内存分成不同的 region,有 Young GC、MixedGC、Full GC
CMS
改进点在于。 1. stop the world,把和 GC Roots 直接相关的进行标记 2. 解除 stw,应用线程和并发的依赖标记线程一起做; 3. stop the world,把标记期间应用线程影响到的线程进行标记; 4. 解除 stw,和应用程序同时一起清除没被标记的对象。
Parallel GC
改进点在于多个线程并行进行垃圾回收,但是回收期间还是 stw。
更早的 JDK 6 则把驻留字符串放在永久代中
It is very unclear, String will be stored in PermGen in JDK 6, but PermGen is one part of Heap memory too.
So, whenever String objects will be stored in Heap.
oung GC
Young GC = Minor GC
After a Young GC, if too many objects survice, they are prompted directly to the old generation.
注册回调不代表一定会切换线程。
future.thenApply(value -> value.length());
The registration of callback function does NOT guarantee which thread (new or old) will server to do this logic.
作用域
meta annotation - Target - TYPE: class - FIELD: class's member variables - METHOD - PARAMETER
动态代理类
JDK automatic proxy
应用场景
.xml可达性分析
our objects are reachable or not. searching from GC Roots.
有哪些方式
newInstance()类型擦除不代表所有泛型信息都消失了
if we know the clazz object, we can know what we define in code in reflection mechanism. but if we only have one of the object, we can not know what is exact parameter when creating because of type erasure mechanism.
为什么需要泛型?
2 main reasons:
- code reuse, developers don't need to prepare different version of code for different types.
- compile-time checking instead of runtime checking, e,g, if we want put “123” and 123 in a list, but if this list can only store Integer? if we use generic, such as List<Integer> we can discover it on compile-time.
泛型 #
generic
实现深拷贝的三种方法是什么
clone method.赖于外部类的实例
so we should outer.new Inner() ?
六大原则
SOILD: - S for Single, every class must take 1 role. - O for Open, open for extension, close for modification - I for Interface, it should be small and specific - L for Liskov, subclass object can replace all parent class object - D for Dependency, Dependency Inverse.
哪几个方面
Polymorphism in Java: 1. overload 2. override 3. interface 4. up-casting and down-casting
编译时多态(重载)
装箱和拆箱是什么?
int \(\rightarrow\) IntegerInteger \(\rightarrow\) intjava
Integer x = 1; // boxing
int y = x; // unboxingjava
private void printInt(int x) {
System.out.println(x);
}
Integer a = 1; // boxing
printInt(a); // unboxingInteger sum = 0;
for (int i = 0; i <= 1000000; i++) {
sum += i;
}
boxing & unboxing is automatic, but need time!!!
it will create many disposable Integer objects, which will increase GC pressure.舍入规则
if we define BigDecimal a = 1, b = 3, and run a.divide(b), the target answer will be 0.333333... which can not represent in BigDecimal format, so it will throws an ArithmeticException.
If we want to fix this, we should use rounding mode, e.g. half_up (\(1.04 \rightarrow 1.0, 1.05 \rightarrow 1.1\))
equals和compareTo
equal() return true or false, means a.unscaledvalue == b.unscaledvalue && a.scale == b.scalecompareTo return number -1, 0, 1, means a < b, a == b, a > b可以使用BigDecimal.valueOf,它会通过double的字符串表示来构造
BigDecimal.valueOf(0.1) - step #1: 0.1 \(\rightarrow\) "0.1" - step #2: "0.1" $\rightarrow$ BigInteger = 1, scale = 1
资产
asserts 一般用来存储那些不变的模板
类型互转会出现什么问题吗?
we should use instanceof to judge
数据类型转换方式你知道哪些?
4 types of data conversion: 1. automatic type conversion, e.g. int to long 2. forced type conversion, e.g. long to int 3. String to Object, e.g. Integer.parseInt() 4. basic data type \(\leftrightarrow\) their wrapper class
long和int可以互转吗 ?
cpp
int a = 10;
long b = a;cpp
long c = 10L;
int d = (int) c;int和long是多少位,多少字节的?
Python和Java区别是什么?
编译型语言和解释型语言的区别?
very important trade-off: efficiency vs. platform independence - compiled language: 1. source code compiles to the target platform's bytecode, 2. run or debug. run very fast online but development and changing platform is slow. - interpreted language: 1. interpret each line of source code in each platform, it is very easy to change environment and develop but slow
jvm是什么
方法调用计数器
invocation counter: if a method is frequently invoked, it will be hotter.
for (int i = 0; i < 100_000; i++) {
calc();
}
JVM、JDK、JRE三者关系
JVM < JRE < JDK - JVM: run Java bytecode; or core engine - JRE: JVM + ClassLoader + library, providing runtime - JDK: JRE + javac + javadb + develop tools, providing development environment.
跨平台
JVM is the most key software.
优势
Java's 3 main strength: 1. Platform Independence 2. Memory Control, CC 3. strong ecosystem
several distinct trees can encode the same function
比如 \(x_1, x_2\) 先算 \(x_1\) 还是先算 \(x_2\) 导致决策树不同,但是表示函数可以是同一个。
geometry
几何空间
Penalized vs Constrained
System one models
System One Model 指的是快速判断模型,不像普通 LLM 一样生成一大堆文本,而是做快速判断(Noul)、分类(Choice)、打分(Score)
DSPy 3.4.0
DSPy 是一个用代码来优化 LLM 应用的框架。
传统的 Prompt Engineering:手写提示词、调模型、结构不好、人肉修改 Prompt
DSPy:定义任务模块、准备训练和验证样本、定义评分指标、DSPy 自动优化 Prompt 和示例