Comments (7)
Sorry, my bad, I open 4 working threads for writing logs to test my program, but actually, I only have 4 cpus in my testing environment, so, one use to fetcher, only last 3 cpus for 4 working threads, that lead to one thread can not work.
So, I adjust my testing program, only open 3 working threads, finally, I got a better result:
single thread: 638269 msg/s
multithread(3 working threads, 1 fetcher thread): 2242930 msg/s
Btw, the testing program in https://github.com/finaldie/final_test , find in "log" folder
So next, find out the hotspot in code, do some deep optimization. Action items:
- hotspot
- branch predict
- hold time string within one second
...
from final_libs.
I have updated the testing program in https://github.com/finaldie/final_test
I tested it through 4 ways:
- sync mode, single thread writing
- sync mode, multithread writing
- async mode, single thread writing
- async mode, multithread wrting
My environment of testing machine is:
- CPU: Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz * 4
- DISK: 120G, BuffSize=14111kB
- MEMORY: 4G
Program setting:
- Flush interval: 2 seconds
- Buffer Size per-thread: 10M
- 3 threads in multithread mode
Testing Result:
- Sync mode, single thread: [ 1089947 msg/s ]
- Sync mode, multithread: [ 2688969 msg/s ]
- Async mode, single thread: [ 619730 msg/s ]
- Async mode, multithread: [ 2229928 msg/s ]
from final_libs.
The testing result above is only for testing ability of writing.
The call time per-interface has not started.
I have finished draw a call graph, the hotspot at "snprintf".
So next, find out the hotspot in code, do some deep optimization. Action items:
- hotspot
- branch predict
- hold time string within one second
...
from final_libs.
When I testing on a 24 cores machine, I found it better than my local 4 cores machine.
The async interface much faster than sync interface ( improvement 100% )
from final_libs.
I have updated the testing program in https://github.com/finaldie/final_test and testing the last commit of final_libs (443e13b)
I tested it through 4 ways:
- sync mode, single thread writing
- sync mode, multithread writing
- async mode, single thread writing
- async mode, multithread wrting
My environment of testing machine is:
- CPU: Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz * 4
- DISK: 120G, BuffSize=14111kB
- MEMORY: 4G
Program setting:
- Flush interval: 2 seconds
- Buffer Size per-thread: 10M
- 3 threads in multithread mode
Testing Result call interface time (3000000 msg total):
- sync mode, single thread: 510193 microseconds
- sync mode, multithread: 1037439 microseconds
- async mode, single thread: 1513447 microseconds
- async mode, multithread: 470537 microseconds
The last version call interface time (3000000 msg total):
- sync mode, single thread: 2663160 microseconds
- sync mode, multithread: 1140176 microseconds
- async mode, single thread: 4867738 microseconds
- async mode, multithread: 1351146 microseconds
from final_libs.
Almost done~ Has a great improvement.
from final_libs.
The some environment above, the last testing result: ( run ftest/log/test: ./test 1000000 3 )
startup mode = 4 ..
log system init complete
[SYNC]start single testing...
writing thread id = 47059976517376 startup
tid=47059976517376, max_num_per_group:5000, group:200, last_miss_count:0, sleep_step:5000
tid=47059976517376, call interface time cost (usec):605103, writen msg:1000000, final:1652611.208340 count/s
pid=1168, tid=47059966025888, call interface time cost (usec):605475 write_msg:1000000 miss_msg:0 miss_rate:0.000000 final:1651595.854494 count/s
[SYNC]end single testing
[SYNC]start multip testing ( totally, we start 3 threads for testing)...
writing thread id = 47059976517376 startup
tid=47059976517376, max_num_per_group:5000, group:66, last_miss_count:0, sleep_step:5000
writing thread id = 47059999762176 startup
tid=47059999762176, max_num_per_group:5000, group:66, last_miss_count:0, sleep_step:5000
writing thread id = 47059989272320 startup
tid=47059989272320, max_num_per_group:5000, group:66, last_miss_count:0, sleep_step:5000
tid=47059976517376, call interface time cost (usec):699984, writen msg:333333, final:476200.884592 count/s
tid=47059999762176, call interface time cost (usec):700692, writen msg:333333, final:475719.717080 count/s
tid=47059989272320, call interface time cost (usec):703390, writen msg:333333, final:473894.994242 count/s
pid=1168, tid=47059966025888, call interface time cost (usec):703670 write_msg:1000000 miss_msg:0 miss_rate:0.000000 final:1421120.695781 count/s
[SYNC]end multip testing
[ASYNC]start single testing...
current buffer size per-thread = 209715200
log work thread start
writing thread id = 47059989272320 startup
tid=47059989272320, max_num_per_group:5000, group:200, last_miss_count:0, sleep_step:5000
tid=47059989272320, call interface time cost (usec):503826, writen msg:1000000, final:1984812.216916 count/s
pid=1168, tid=47059966025888, call interface time cost (usec):503942 write_msg:1000000 miss_msg:0 miss_rate:0.000000 final:1984355.342480 count/s
get_log_event(tid=47059999762176): event_id=2
[ASYNC]end single testing
[ASYNC]start multip testing ( totally, we start 3 threads for testing)...
current buffer size per-thread = 209715200
writing thread id = 47059989272320 startup
tid=47059989272320, max_num_per_group:5000, group:66, last_miss_count:0, sleep_step:5000
writing thread id = 47060101367552 startup
tid=47060101367552, max_num_per_group:5000, group:66, last_miss_count:0, sleep_step:5000
writing thread id = 47059976517376 startup
tid=47059976517376, max_num_per_group:5000, group:66, last_miss_count:0, sleep_step:5000
tid=47060101367552, call interface time cost (usec):213521, writen msg:333333, final:1561125.135233 count/s
tid=47059989272320, call interface time cost (usec):215646, writen msg:333333, final:1545741.632119 count/s
tid=47059976517376, call interface time cost (usec):217472, writen msg:333333, final:1532762.838434 count/s
pid=1168, tid=47059966025888, call interface time cost (usec):219598 write_msg:1000000 miss_msg:0 miss_rate:0.000000 final:4553775.535296 count/s
get_log_event(tid=47059999762176): event_id=2
get_log_event(tid=47059999762176): event_id=2
get_log_event(tid=47059999762176): event_id=2
[ASYNC]end multip testing
So, we can see the result of async writing is much better than before.
congratulations!
from final_libs.
Related Issues (20)
- [FCO] C coroutine support HOT 1
- [FNET] UDP Support
- [FLOG] Dead loop when no space on disk HOT 1
- [FLIBS] Refine all filenames or function prefix to fxx HOT 2
- [FEV] Async connection need a new timer mechanism instead of timerfd HOT 2
- Http parser handler support HOT 1
- [MBUF] False Sharing issue HOT 1
- complie error based on "ubuntu 10.04 32bit" HOT 3
- [FNET] Support writev
- database interfaces support HOT 3
- [FHASH] FNV Support HOT 1
- [FPCAP] Hash rules is not very suitable for tcp 4 elements
- [FNET] Fix the checking return code issue for fnet_get_peerip and fnet_get_localip
- [FCONF] Auto configuration support HOT 3
- [FLOG] Log system need disable other low priority levels HOT 1
- [FLOG] Improve Log library HOT 9
- [FLOG] User Thread quit HOT 1
- [FCACHE]Cache Library HOT 1
- [FLOG] Analysis with perf/systemtap HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from final_libs.