Skip to content

Commit

Permalink
Improve map by re-implementing red-black tree (#144)
Browse files Browse the repository at this point in the history
The proposed map implementation demonstrates substantial improvements
compared to the original one by replacing it with a faster red-black
tree. The data provided below represents the average time of 20
experiments, each involving the insertion, finding, and deletion of
10 million randomly generated nodes in a random order. These tests were
conducted on Apple M1 Pro.

  OpType   |  Insert (ns)  | Find (ns)   | Remove (ns)
  ---------+---------------+-------------+------------
  original |  824,515,450  | 21,132,350  | 925,074,950
  proposed |  535,518,250  | 10,032,300  | 602,755,100
  ---------+---------------+-------------+------------
  improved |         35 %  |       52 %  |        35 %

Heap memory usage has also been reduced by 17%.

This map implementation has undergone extensive modifications, heavily
relying on the rb.h header file from jemalloc. The original rb.h file
served as the foundation and source of inspiration for adapting and
tailoring it specifically for this map implementation.
Therefore, credit and sincere thanks are extended to jemalloc for
their invaluable work.

Reference:
https://github.com/jemalloc/jemalloc/blob/dev/include/jemalloc/internal/rb.h
  • Loading branch information
EagleTw committed Jun 14, 2023
1 parent 3a70492 commit 434c466
Show file tree
Hide file tree
Showing 2 changed files with 546 additions and 668 deletions.

0 comments on commit 434c466

Please sign in to comment.