Skip to content

jit feature spec compare (only arithmetic)#9

Draft
ewlkkf wants to merge 6 commits intomainfrom
feature/x64_interface
Draft

jit feature spec compare (only arithmetic)#9
ewlkkf wants to merge 6 commits intomainfrom
feature/x64_interface

Conversation

@ewlkkf
Copy link
Collaborator

@ewlkkf ewlkkf commented Nov 9, 2025

벤치마크 실행 결과

$ go test -run="-" -bench="SimpleArithmetic" -benchmem "./jit"
goos: linux
goarch: amd64
pkg: github.com/siyul-park/minivm/jit
cpu: Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz

BenchmarkSimpleArithmetic/Interpreter-6 200377 5644 ns/op 20928 B/op 16 allocs/op
BenchmarkSimpleArithmetic/JIT-6 86763 13689 ns/op 396 B/op 7 allocs/op
PASS
ok github.com/siyul-park/minivm/jit 2.327ssh

$ go test -run="-" -bench="SumArithmetic" -benchmem "./jit"
goos: linux
goarch: amd64
pkg: github.com/siyul-park/minivm/jit
cpu: Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz

BenchmarkSumArithmetic/Interpreter-6 34125 34801 ns/op 77748 B/op 514 allocs/op
BenchmarkSumArithmetic/JIT-6 38337 31050 ns/op 24716 B/op 15 allocs/op
PASS
ok github.com/siyul-park/minivm/jit 2.386s


벤치마크 결과 분석

1. BenchmarkSimpleArithmetic (단순 산술 연산)

항목 Interpreter JIT 차이
실행 시간 5,644 ns/op 13,689 ns/op JIT가 2.43배 느림
메모리 사용 20,928 B/op 396 B/op JIT가 52.8배 적게 사용
할당 횟수 16 allocs/op 7 allocs/op JIT가 2.3배 적게 할당

결론: 단순 연산에서는 Interpreter가 더 빠르지만, JIT는 메모리와 할당이 훨씬 적음.

2. BenchmarkSumArithmetic (합산 연산)

항목 Interpreter JIT 차이
실행 시간 34,801 ns/op 31,050 ns/op JIT가 11% 빠름
메모리 사용 77,748 B/op 24,716 B/op JIT가 3.15배 적게 사용
할당 횟수 514 allocs/op 15 allocs/op JIT가 34.3배 적게 할당

결론: 반복/합산 연산에서는 JIT가 더 빠르고, 메모리와 할당이 훨씬 적음.

종합 분석

  • 단순 연산: Interpreter가 빠름 (JIT 컴파일 오버헤드)
  • 반복 연산: JIT가 더 빠름 (컴파일 비용 대비 실행 이득)
  • 메모리 효율: JIT가 두 경우 모두 우수
  • 할당 효율: JIT가 두 경우 모두 우수 (특히 반복 연산에서 현저)

시사점: JIT는 반복 실행이 많은 워크로드에서 유리하며, 메모리 효율이 전반적으로 우수함.

@ewlkkf
Copy link
Collaborator Author

ewlkkf commented Nov 9, 2025

BenchmarkSimpleArithmetic (단순 산술 연산)

방식 실행 시간 메모리 할당 할당 횟수 성능 비교
Interpreter 206.1 ns/op 0 B/op 0 allocs/op -
JIT 317.1 ns/op 4 B/op 1 allocs/op 약 54.0% 느림

BenchmarkSumArithmetic (합산 연산)

방식 실행 시간 메모리 할당 할당 횟수 성능 비교
Interpreter 4597 ns/op 0 B/op 0 allocs/op -
JIT 993.6 ns/op 4 B/op 1 allocs/op 약 78.4% 빠름

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments