Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 335653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:10:08+00:00 2026-05-12T10:10:08+00:00

From Wikipedia : The main disadvantages are greater overall space usage and slower indexing,

  • 0

From Wikipedia:

The main disadvantages are greater
overall space usage and slower
indexing, both of which become more
severe as the tree structure becomes
larger and deeper. However, many
practical applications of indexing
involve only iteration over the
string, which remains fast as long as
the leaf nodes are large enough to
benefit from cache effects.

I’m implementing a sort of compromise between ropes and strings. Basically it’s just ropes, except that I’m flattening concatenation objects into strings when the concatenated strings are short. There are a few reasons for this:

  1. The benefits of concatenation objects are minimal when the concatenated strings are short (it doesn’t take too long to concatenate two strings in their normal form).
  2. Doing this reduces the largeness/depth of the tree (reducing the downsides of ropes).
  3. Doing this increases the size of the leaf nodes (to take better advantage of cache).

However, as length gets longer, the advantages of the ropes also decrease, so I’d like to find some compromise. The “sweet spot” logically seems to be around where “the leaf nodes are large enough to benefit from cache effects”. The problem is, I don’t know how large that is.

EDIT: While I was writing this, it occurred to me that the ideal size would be the size of a cache page, because then the rope only causes cache misses when they would happen anyway in a string. So my second question is, is this reasoning correct? And is there a cross-platform way to detect the size of a cache page?

My target language is C++.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:10:09+00:00Added an answer on May 12, 2026 at 10:10 am

    The limit case for a rope-like string would be built on top of a std::list<char>. That obviously isn’t very effective. When iterating, you are likely to have have one cache miss per “leaf”/char. As the number of characters per leaf goes up, the average number of misses goes down, with a discontinuity as soon as your leaf allocation exceeds a single cache line.

    It might still be a good idea to have larger leafs; memory transfers in cache hierarchies might have different granularities at different levels. Also, when targetting a mixed set of CPUs (i.e. consumer PCs) a leaf size which is a higher power of two will be an integral multiple of the cache line size on more machines. E.g. if you’re addressing CPUs with 16 and 32 byte cache lines, 32 bytes would be the better choice, as it’s an always integral number of cache lines. Wasting half a cache line is a shame.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From wikipedia : During each sprint, typically a two to four week period (with
From Wikipedia: The complexity of the algorithm is O(n(logn)(loglogn)) bit operations. How do you
From wikipedia: The Web Services Description Language (WSDL, pronounced 'wiz-dəl') is an XML-based language
Quote from Wikipedia : A public key token. This is a 64-bit hash of
I know from wikipedia for example that exception handling is used in an application
I have the following JSON string (from wikipedia http://en.wikipedia.org/wiki/JSON ) { name:Product, properties: {
I am reading XOR linked list (from Wikipedia).But I am having some problems in
In 2 complements I read from wikipedia, the range is from -128 to 127.
i have tried to copy euro symbol from Wikipedia...and echo it (in my parent
here's a definition of marshaling from Wikipedia: In computer science, marshalling (similar to serialization)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.