This project implements a highly efficient algorithm for counting unique IP addresses in very large files using the HyperLogLog data structure. The program is written in Go and optimized for concurrent data processing, enabling fast processing of large volumes of information. Before running the main code (main.go
), you need to create a test file with IP addresses using the generator.py
script.
main.go
— the main Go file that implements the logic for processing and counting unique IP addresses.generator.py
— an auxiliary Python script that generates a file with IP addresses for testing.execution.log
— a log file automatically created when running themain.go
program (this file is in.gitignore
and not tracked in the repository).
Before running the main program, you need to create a test file with IP addresses:
-
Open the
generator.py
file and, if necessary, modify the desired file size:TARGET_SIZE = 100 * 1024 * 1024 * 1024 # Change this value to the desired size (in bytes)
-
Run the generator to create the test file:
python3 generator.py
After running this command, a file named
ip_addresses
with the specified size will appear in the current directory.
Once the file with IP addresses is created, you can run the Go program to count the unique IP addresses:
source .env
go run cmd/ip-counter/main.go
After the profiles are created, you can visualize them using the pprof
tool. To do this, run the following commands:
go tool pprof -http=:8080 cpu_profile.prof
This report will help visually analyze performance bottlenecks and optimize CPU usage.
If you have any questions or suggestions for improving the code, feel free to make changes or create Issues on GitHub.