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

Zig contribution and Benchmarking on Github actions runner #30

Merged
merged 14 commits into from
Sep 28, 2023
Merged

Zig contribution and Benchmarking on Github actions runner #30

merged 14 commits into from
Sep 28, 2023

Conversation

akhildevelops
Copy link
Contributor

@akhildevelops akhildevelops commented Sep 28, 2023

This Pr provides contribution based on Zig language.

It also has a githubactions workflow file that generates benchmarks on the fly for every PR to main.

@jinyus jinyus merged commit 131f5ca into jinyus:main Sep 28, 2023
@jinyus
Copy link
Owner

jinyus commented Sep 28, 2023

Hey, thanks for the PR, Zig has very slow I/O on my machine (5s in total, 80ms on processing). Is that normal?

@akhildevelops
Copy link
Contributor Author

It shudn't take 5s.

@jinyus
Copy link
Owner

jinyus commented Sep 29, 2023

These are the results from the github workflow:

Zig:

    Benchmark 1: ./main
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms

    Time (mean ± σ):      2.205 s ±  0.008 s    [User: 0.719 s, System: 1.484 s]
    Range (min … max):    2.198 s …  2.228 s    10 runs

@akhildevelops
Copy link
Contributor Author

These are the results from the github workflow:

Zig:

    Benchmark 1: ./main
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms
    Processing time (w/o IO): 176ms

    Time (mean ± σ):      2.205 s ±  0.008 s    [User: 0.719 s, System: 1.484 s]
    Range (min … max):    2.198 s …  2.228 s    10 runs

This is fine generally total time is 10x compared to w/o IO. My system also gives me similar multiplier value.

~ $ ./run.sh zig
Running Zig
Benchmark 1: ./main
Processing time (w/o IO): 133ms
Processing time (w/o IO): 133ms
Processing time (w/o IO): 131ms
Processing time (w/o IO): 133ms
Processing time (w/o IO): 131ms
Processing time (w/o IO): 135ms
Processing time (w/o IO): 131ms
Processing time (w/o IO): 130ms
Processing time (w/o IO): 132ms
Processing time (w/o IO): 132ms
Processing time (w/o IO): 137ms
Processing time (w/o IO): 140ms
Processing time (w/o IO): 135ms
  Time (mean ± σ):      1.065 s ±  0.025 s    [User: 0.229 s, System: 0.834 s]
  Range (min … max):    1.031 s …  1.119 s    10 runs
 
Checking output
Output file: related_posts_zig.json is valid!

@jinyus
Copy link
Owner

jinyus commented Sep 29, 2023

Alright, looks like it might be a bug with my processor/os.

Processing time (w/o IO): 80ms
Processing time (w/o IO): 84ms
Processing time (w/o IO): 90ms
Processing time (w/o IO): 90ms
Processing time (w/o IO): 89ms
  Time (mean ± σ):      6.134 s ±  0.190 s    [User: 0.251 s, System: 5.880 s]
  Range (min … max):    5.813 s …  6.488 s    10 runs

@akhildevelops
Copy link
Contributor Author

akhildevelops commented Sep 29, 2023

System time is very high i.e, 5.88secs. This is the time spent by app in sys calls i.e, memory allocation, file reading etc..,. How about other lang implementation system times ? Are they also high as zig i.e, 20x compared to user time ?

@jinyus
Copy link
Owner

jinyus commented Sep 29, 2023

I just merged a fix : #31

Running Zig
Benchmark 1: ./main
Processing time (w/o IO): 80ms
Processing time (w/o IO): 80ms
Processing time (w/o IO): 82ms
Processing time (w/o IO): 80ms
Processing time (w/o IO): 81ms
Processing time (w/o IO): 81ms
Processing time (w/o IO): 82ms
Processing time (w/o IO): 81ms
Processing time (w/o IO): 79ms
Processing time (w/o IO): 81ms
Processing time (w/o IO): 80ms
Processing time (w/o IO): 82ms
Processing time (w/o IO): 82ms
  Time (mean ± σ):     111.7 ms ±   1.7 ms    [User: 99.2 ms, System: 12.4 ms]
  Range (min … max):   109.2 ms … 113.4 ms    10 runs

@akhildevelops
Copy link
Contributor Author

Are these from ur local system ?

@jinyus
Copy link
Owner

jinyus commented Sep 29, 2023

Yes, the workflow also got a boost: https://github.com/jinyus/related_post_gen#updated-results-from-github-workflow-raw-data

@akhildevelops
Copy link
Contributor Author

I'm working on automatic publishing of benchmarking results (from GitHub runner) in Readme. I'll give a separate PR once it's done.

@jinyus
Copy link
Owner

jinyus commented Sep 29, 2023

I wrote a crystal script to extract the results from the workflow log:
https://github.com/jinyus/related_post_gen/blob/main/extract/extract.cr

it prints the new table for the readme and update the raw_results.md file. I should probably rewrite it in python/dart so it can be ran without compiling.

I currently do it manually, but it should be of help

@akhildevelops
Copy link
Contributor Author

Cool, I can direct my efforts on optimizing zig.

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