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

test scalability for json lib #556

Closed
wants to merge 1 commit into from
Closed

test scalability for json lib #556

wants to merge 1 commit into from

Conversation

AsterDY
Copy link
Collaborator

@AsterDY AsterDY commented Nov 14, 2023

Case

  • Repeatedly marshal the same object and unmarshal outcome json into a new object, for N times
  • Create T number of threads (or processes) to execute above task.
  • Adjust T and N meanwhile, ensuring total works always equal to T*N

Environment

goos: darwin
goarch: amd64
cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz

Result

It's very clear that for JSON lib, its processability doesn't grow linearly with the number of CPUs. And there is a abvious threshold once paralleled threads (or processes) number goes above half of the CPU cores

=== RUN   TestScalability_Process
=== RUN   TestScalability_Process/sonic
single-process
1 processes total cost: 169785us
1/4-processes
4 processes total cost: 73421us
half-processes
8 processes total cost: 72286us
3/4-processes
12 processes total cost: 85187us
full-processes
16 processes total cost: 100788us
full-processes-1
15 processes total cost: 99805us
=== RUN   TestScalability_Process/std
single-process
1 processes total cost: 315315us
1/4-processes
4 processes total cost: 105815us
half-processes
8 processes total cost: 90710us
3/4-processes
12 processes total cost: 107567us
full-processes
16 processes total cost: 115681us
full-processes-1
15 processes total cost: 117348us
--- PASS: TestScalability_Process (1.45s)
    --- PASS: TestScalability_Process/sonic (0.60s)
    --- PASS: TestScalability_Process/std (0.85s)
=== RUN   TestScalability_Thread
num cpu: 16
=== RUN   TestScalability_Thread/sonic
single-thread
1 threads total cost: 150786us
1/4-threads
4 threads total cost: 51560us
half-threads
8 threads total cost: 37515us
3/4-threads
12 threads total cost: 36387us
full-threads
16 threads total cost: 39338us
full-threads-1
15 threads total cost: 40201us
=== RUN   TestScalability_Thread/std
single-thread
1 threads total cost: 287707us
1/4-threads
4 threads total cost: 96182us
half-threads
8 threads total cost: 88373us
3/4-threads
12 threads total cost: 96573us
full-threads
16 threads total cost: 115144us
full-threads-1
15 threads total cost: 110567us

@AsterDY AsterDY marked this pull request as draft November 14, 2023 09:05
@AsterDY AsterDY closed this Jan 24, 2024
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.

None yet

1 participant