Skip to content

Improve FT.INFO complexity to O(1)#2153

Merged
ashtul merged 5 commits intomasterfrom
ft.info-complexity
Aug 2, 2021
Merged

Improve FT.INFO complexity to O(1)#2153
ashtul merged 5 commits intomasterfrom
ft.info-complexity

Conversation

@ashtul
Copy link
Copy Markdown
Contributor

@ashtul ashtul commented Aug 1, 2021

Fixes #2116

The previous function iterated recursively over the whole trie and collected the size of each node including the string which defines the node ID. This operation has the complexity of O(n) and presents the lower bound of memory allocation since the memory allocated for the struct would be padded to 8 bytes (since the struct contains void * ptr).

The calculation in this PR is based on the cardinality of the trie. It multiplies it by the size of the struct, the point and char held by its parent, and a constant of 8 bytes, to compensate for the memory which is padded out.

@ashtul ashtul requested review from MeirShpilraien and rafie August 1, 2021 07:26
rafie
rafie previously approved these changes Aug 1, 2021
@codecov
Copy link
Copy Markdown

codecov bot commented Aug 1, 2021

Codecov Report

Merging #2153 (0d9bee7) into master (e1c2660) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2153   +/-   ##
=======================================
  Coverage   80.42%   80.42%           
=======================================
  Files         150      150           
  Lines       21997    21997           
=======================================
  Hits        17691    17691           
  Misses       4306     4306           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1c2660...0d9bee7. Read the comment docs.

Copy link
Copy Markdown

@MeirShpilraien MeirShpilraien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comments, looks very good 👍

@ashtul ashtul requested a review from MeirShpilraien August 2, 2021 10:23
Copy link
Copy Markdown

@MeirShpilraien MeirShpilraien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ashtul ashtul merged commit e1a8af5 into master Aug 2, 2021
@ashtul ashtul deleted the ft.info-complexity branch August 2, 2021 10:47
ashtul pushed a commit that referenced this pull request Aug 2, 2021
* Improve FT.INFO complexity to O(1)

* split cardinality and size for MemUsage

* Per meir's review

* per review

(cherry picked from commit e1a8af5)
ashtul pushed a commit that referenced this pull request Aug 23, 2021
* Improve FT.INFO complexity to O(1)

* split cardinality and size for MemUsage

* Per meir's review

* per review

(cherry picked from commit e1a8af5)
ashtul pushed a commit that referenced this pull request Aug 24, 2021
…xity to O(1) (#2153) (#2201)

* Add UNF flag for SORTABLE fields (#2188)

* Add UNF flag for SORTABLE fields

* add test

(cherry picked from commit aa9808d)

* Document SORTABLE UNF

* Improve FT.INFO complexity to O(1) (#2153)

* Improve FT.INFO complexity to O(1)

* split cardinality and size for MemUsage

* Per meir's review

* per review

(cherry picked from commit e1a8af5)

* remove json test

Co-authored-by: Emmanuel Keller <emmanuel.keller@redislabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove TrieMap_MemUsage from FT.INFO

3 participants