-
Notifications
You must be signed in to change notification settings - Fork 23
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
Avoid frequent memory allocation/deallocation by memory pool #20
Comments
After applying enable-rdtsc.patch, I got the following time-stamp numbers: *** Validating build/test_trinary ***
=== trits_from_trytes: 42320 ===
=== trytes_from_trits: 5103 ===
*** Validating build/test_curl ***
=== trits_from_trytes: 220208 ===
=== trytes_from_trits: 3171 ===
*** Validating build/test_pow_sse ***
=== trits_from_trytes: 76903 ===
=== trits_from_trytes: 32099 ===
=== trytes_from_trits: 2245 ===
=== trits_from_trytes: 33132 ===
=== trytes_from_trits: 2674 ===
=== trits_from_trytes: 2651 === |
To illustrate the memory impact, TCMalloc is used for comparisons. The following environment is Intel Xeon E5 class server with Ubuntu Linux First, prepare TCMalloc:
$ make check
*** Validating build/test_trinary ***
=== trits_from_trytes: 5460 ===
=== trytes_from_trits: 4286 ===
*** Validating build/test_curl ***
=== trits_from_trytes: 120820 ===
=== trytes_from_trits: 3940 ===
*** Validating build/test_pow_sse ***
=== trits_from_trytes: 68535 ===
=== trits_from_trytes: 61490 ===
=== trytes_from_trits: 1221 ===
=== trits_from_trytes: 31277 ===
=== trytes_from_trits: 1617 ===
=== trits_from_trytes: 2668 ===
$ LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4 make check
*** Validating build/test_trinary ***
=== trits_from_trytes: 29244 ===
=== trytes_from_trits: 3920 ===
*** Validating build/test_curl ***
=== trits_from_trytes: 108290 ===
=== trytes_from_trits: 2940 ===
*** Validating build/test_pow_sse ***
=== trits_from_trytes: 79500 ===
=== trits_from_trytes: 57566 ===
=== trytes_from_trits: 3028 ===
=== trits_from_trytes: 31777 ===
=== trytes_from_trits: 1654 ===
=== trits_from_trytes: 1980 ===
|
It is worth mentioning that heap memory which every PoW task allocates is fixed. Maybe we can implement a special memory pool for allocating trytes & trits. |
In our scenario, the memory usage every PoW task (thread) uses is "fixed" and the variables can be reused. I think we can declare all the variables in advance rather than allocating it from memory pool every time. |
The tool heaptrack can show the information of the dynamic memory allocation.
The information gives us the blueprint of the memory pool design. |
Dynamic memory allocation tends to be non-deterministic, and is it possible to elininate existing dynamic allocation inside dcurl? |
Yes, we can eliminate the dynamic allocation to once or even use a declared char array as a memory pool. |
I have implemented a memory pool mechanism and integrated it into the Here are the problems:
|
|
|
However, even if I use |
When I was using the analysis tool such as However, the suggestion to empty the |
Ouch! It is a pity. I look forward to the migration to other memory allocators. |
Since The following charts come up with running on different hardware and commenting the specific function The question and conclusion: Keep investigating. |
After #95 is resolved, we can continue memory pool engagement. |
Cc. @JulianaTa |
Current PoW internals consist of various
malloc
andfree
, which are called frequently. It is bad for performance considerations. Using memory pool is a common technique to speed up and ensure consistent execution time.I have done preliminary memory pool: https://github.com/jserv/dcurl/tree/memory-pool
NOTE: we might have to manipulate with thread-safe issues, and check out existing implementations such as philip-wernersbach/memory-pool-allocator.
The text was updated successfully, but these errors were encountered: