Skip to content

Repository files navigation

Socket Programming in C

Performance Analysis and Optimization of a Single-Threaded TCP Server Using Linux Perf Monitoring Tools

Roll Number: 2022052 & 2022054

Stars Badge Forks Badge Pull Requests Badge Issues Badge GitHub contributors License Badge

Bind Already in Use Error

-Find the PID which is runinng on the port p using

$ sudo lsof -i :8080

This command will result in the PID (PID) time and name of the server that is runnning.

Now kill the process using the command:

$ sudo kill -9 <PID>

perf tool permission denied error

perf_event_paranoid is working fine with value 3 which can be changed by:

$ sysctl kernel.perf_event_paranoid=3

Running the Programs

For single threaded server

$ make single-threaded

$ sudo perf stat -e cycles,instructions,cache-references,cache-misses,context-switches,cpu-migrations,page-faults ./single-threaded-server

  • Run the following command on the second terminal.
$ sh n_seq_clients.sh 10 ./single-threaded-client
  • Observe the results in output.txt

  • NOTE: Ensure that commands are run in the aforementioned order for successful compilation!

For concurrent server using pthreads

$ make concurrent-thread

$ sudo perf stat -e cycles,instructions,cache-references,cache-misses,context-switches,cpu-migrations,page-faults ./concurrent-server-thread 10

  • Run the following command on the second terminal.
$ ./concurrent-client 10
  • Observe the results in output.txt

For TCP-Client server using select() system call

$ sudo perf stat -e cycles,instructions,cache-references,cache-misses,context-switches,cpu-migrations,page-faults ./select-server
  • Run the following command on the second terminal.
$ sh n_con_clients.sh 10 ./single-threaded-client

Contact

If you have any questions or feedback, you can reach out to Akshat Raj Saxena

Acknowledgements

Special thanks to the creators of JavaFX and the contributor to this project Akshat Karnwal.

Reference

https://man7.org/linux/man-pages/man1/perf-stat.1.html

andrewrk/poop#17

About

Setting up a TCP Client connection using single threaded, mutli-threaded and "select" command in C language

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages