Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve function call performance #159

Merged
merged 1 commit into from
Sep 7, 2023
Merged

Conversation

ksh8281
Copy link
Collaborator

@ksh8281 ksh8281 commented Sep 6, 2023

  • Divide function into user-defined function and user-defined function /w try-catch
  • Non try-catch user-defined function should not use c++ try-catch
  • Reduce parameter count of Interpreter::interpret

* Divide function into user-defined function and user-defined function /w try-catch
* Non try-catch user-defined function should not use c++ try-catch
* Reduce parameter count of Interpreter::interpret

Signed-off-by: Seonghyun Kim <[email protected]>
@ksh8281
Copy link
Collaborator Author

ksh8281 commented Sep 6, 2023

test ./work/walrus [s] origin/walrus [s]
change 3.024 (1.000x) 3.148 (1.041x)
factorial 3.072 (1.000x) 3.296 (1.073x)
fannkuch 2.546 (1.000x) 2.677 (1.051x)
fibonacci 4.335 (1.000x) 4.864 (1.122x)
gregory 3.404 (1.000x) 3.470 (1.019x)
hanoi 3.939 (1.000x) 4.132 (1.049x)
heapsort 2.887 (1.000x) 3.062 (1.060x)
huffman 4.248 (1.000x) 4.035 (0.950x)
k_nucleotide 3.339 (1.000x) 3.356 (1.005x)
mandelbrot 4.450 (1.000x) 4.676 (1.051x)
nbody 3.711 (1.000x) 3.716 (1.001x)
nqueens 3.608 (1.000x) 3.595 (0.997x)
prime 3.921 (1.000x) 4.029 (1.028x)
quick_sort 3.169 (1.000x) 3.093 (0.976x)
red-black 4.139 (1.000x) 4.222 (1.020x)
salesman 3.792 (1.000x) 3.664 (0.966x)

{
Memory** memories = reinterpret_cast<Memory**>(reinterpret_cast<uintptr_t>(instance) + Instance::alignedSize());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you initialize memories as instance->m_memories?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And is it enough to initialize local memories only?
Other structures like tables, globals don't need local variables since they are not accessed frequently like memories, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you initialize memories as instance->m_memories?
-> I tested two way of init memories.
. access instance->m_memories -> needs memory access
. computing address(reinterpret_cast<Memory**>(reinterpret_cast<uintptr_t>(instance) + Instance::alignedSize())) -> needs ALU on CPU

the second way shows better performance when I tested

And is it enough to initialize local memories only?
-> Yes. only memories is used frequently when I tested
but globals and tables are don't. but it needs a space on stack

Copy link
Collaborator

@clover2123 clover2123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@clover2123 clover2123 merged commit 451a31e into Samsung:interp Sep 7, 2023
12 checks passed
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