15 comments

  • antirez3 hours ago
    For par condicio: I worked at a similar optimization for Redis using different techniques (when I submitted the PR my colleagues informed me that ValKey and another Redis team was working at it, I was not aware: the amoung the three implementation we picked mine after extensive benchmarks) reaching memory savings that sometimes can be tens of percentage of less RAM compared to this ValKey optimization. So if you are exited for less memory for sorted Sets you should try both the implementations. We also got a lot more speed in many use cases compared to the skiplist.
    • hawk_1 hour ago
      Is your implementation also a B+ tree? If so how does it use tens of percentage less memory? less metadata?
      • antirez1 hour ago
        It uses two techniques: B+ tree instead of sorted sets, but also the hash table side, the dictionary, is specialized for sorted sets and stores several items per allocation. The B+ tree leaves hold all the members and scores (also in clusters of many elements, 96 max or 4k: that&#x27;s a big part of the win), rank lookup can skip many children because of meta data, which is part of the ability to go as fast or faster than Redis <i>even</i> if the memory is so much smaller. The hash table points to leaves in the B+ tree, does not have elements at all, and is heavily optimized to do just the minimum, a single byte tag is used as a speed optimization to optimized lookups in an optimistic way. Basically it is the sum of many different techniques conceived during the years and never adopted for fear of complexity (today no longer a problem), and newely discovered techniques.<p>P.S. I tried several variants with different representations, so this specific implementation is the Pareto frontier in speed&#x2F;size of many, many attempts.
  • hinkley8 hours ago
    I have to say I was always on the fence about Bill Pugh (Mr Skiplist).<p>Some of his concurrency ideas were pretty good but Skip Lists were about the same time I was realizing that theoretical and practical design for performance had diverged and skip lists were a huge cache miss liability.<p>It didn&#x27;t hurt that a few people I was aware had tried them had gone back to something else due to live performance analysis being negative or inconclusive (If you can&#x27;t prove one thing is better than the other, you use the simpler one, and skiplists are not simple)
    • bob10295 minutes ago
      If cache misses are a huge concern and we have a highly skewed distribution (mostly touching newer records), the splay tree starts to look interesting.<p>We don&#x27;t like the O(n) worst case, but we really like that magical amortization property. There are some simple ways to avoid getting into a linear hot path.
    • infamouscow8 hours ago
      B+tree were designed around optimized IO in the era of magnetic storage, they&#x27;re inherently cache-friendly. Skiplists are the same thing as a b+tree but the structure is inverted, which makes skiplists more to concurrent writer-friendly than b+trees. Different tradeoffs.
      • fpoling2 hours ago
        The data structure is not a pure B+tree. They also strip common key prefix for node elements and store 4 bytes of remaining key data together with a pointer to the children to avoid key lookup in many cases. Plus they tune node sizes to match jemalloc allocation classes to minimize allocation overhead. I am not sure with such focus on cache friendliness the advantage of skip lists for writes still holds as they will still have more cache misses even on inserts.
      • hinkley8 hours ago
        But more cache misses, due to the variable pointer length structure.<p>That cost varies from chip generation to generation, but it does seem to be the case that b trees win in more generations than they lose.
      • josephg2 hours ago
        Yep. I’ve implemented b trees and skip lists a few times. I find skip lists to be a little easier to implement. But b trees seem to perform ~20% faster. I can’t think of any good reasons to use skip lists instead of b trees in high performance code.
  • tyre9 hours ago
    Tangentially related, the PR sections for the final PR in this feature is quite nice[0].<p>There is a reviewing guide with suggested reading order, clear design decisions, and scope boundaries for what is intentionally not included.<p>This is the type of thing LLMs are very good at and high ROI for human reviewers.<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;valkey-io&#x2F;valkey&#x2F;pull&#x2F;4206" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;valkey-io&#x2F;valkey&#x2F;pull&#x2F;4206</a>
    • plorkyeran6 hours ago
      This is the standard LLM wall of irrelevant garbage that always makes me groan when I see it. There&#x27;s a lot of words but it conveys very little useful information. This is exactly the type of thing that LLMs are terrible at and has negative ROI for human reviewers.
    • monkpit5 hours ago
      This is an LLM smell and, after having dealt with this sort of thing and realizing it’s usually low-signal high-noise, you end up ignoring this kind of thing outright.
    • catlifeonmars3 hours ago
      I prefer to go straight to the code when reviewing. I’ll form my own opinion, then read the PR description, then do another, more detailed pass through the code.
    • lelanthran1 hour ago
      The snr of that file is very very low.
    • pastel87399 hours ago
      You really think that LLMs are “very good” at producing useful PR descriptions? I have had a very different experience.
      • stuaxo8 hours ago
        OMG, I <i>hate</i> the LLM PR descriptions, the comments, the docstrings - anything to be read by a human that isn&#x27;t code.
        • bigstrat20033 hours ago
          The code isn&#x27;t really much better, having reviewed a decent bit of it myself.
        • what5 hours ago
          Have you read the code though?
      • darig8 hours ago
        [dead]
  • rsalus7 hours ago
    I&#x27;ve long since moved to the MultiQueue algorithm for CPQs, seems like SkipList has vanishingly few use cases now...
  • dnchdnd8 hours ago
    Is valkey the recommended redis alternative these days ?
    • TkTech8 hours ago
      Like all things, it depends. If you don&#x27;t need the latest and greatest features in upstream redis, and you don&#x27;t want license headaches, Valkey is probably a good default. It&#x27;s generally cheaper on hosting providers too - AWS will discount you ~20-35% for Valkey vs Redis.
      • nurettin6 hours ago
        I haven&#x27;t checked the newest additions, there were some updates about adding login and encryption, but the latest innovation I use from redis is xstream, and almost all clones now support it.<p>And a moderate LLM subscription can readily generate a useful portion of this project overnight, which makes me concerned about their profitability in the long run.
        • ddorian434 hours ago
          what even is `xstream` ? is that a typo for `stream` ?
          • nurettin2 hours ago
            I seem to remember it was xstream when it was first released. The commands all have a prefix X (XADD, XREAD, XTRIM) perhaps it got rebranded into just stream.
    • unddoch2 hours ago
      DragonflyDB has had this for years. You might disagree with the licensing choice but the technology is just better IMO.<p>(Disclosure, worked for them 3 years ago for a few months)
    • swingboy8 hours ago
      Yes
  • dreamcompiler5 hours ago
    &gt; Every node carries a backward pointer<p>Curious. Skiplists don&#x27;t need back pointers. You can traverse a skiplist backward almost as fast as forward if you keep the &quot;finger&quot; around. The finger is the set of nodes from level-n down to level-0 that point as close to the goal node as possible without going beyond it. The ideal place to keep these nodes is on the stack. To traverse backwards, you do a conventional search for the starting node but every time you go down a pointer level, you push the last pointer on the stack first. Then back traversal becomes stack pops together with appropriate forward recursive calls when you pop back to a pointer that was too far to the left.<p>It&#x27;s easier to convey the idea with code than english but I&#x27;m not typing the algorithm with my thumbs into my phone.
  • snissn9 hours ago
    Do they provide their benchmark code?
  • reconditerose3 days ago
    Redis historically used a skiplist to keep a sorted index. Valkey showed its inefficient and slow on modern hardware, migrating to a B+ tree instead.
    • hinkley8 hours ago
      It all ends up back at B trees. Why does it always end up back at B trees?<p>At this point have we optimized hardware to assume B trees in a sort of self-fulfilling prophesy?
      • alfiedotwtf7 hours ago
        B trees are more friendly to being cache oblivious
      • crest8 hours ago
        Binary trees have worse cache locality. The cost of accessing memory has grown so much compared to computation that supposedly slower &quot;heavy weight&quot; data structures are worth it now (as in the last 10-20 years).
        • eventualcomp8 hours ago
          A b-tree isn&#x27;t a binary tree. B doesn&#x27;t officially stand for binary either, see History[0].<p>[0] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;B-tree" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;B-tree</a>
          • jjmarr8 hours ago
            I&#x27;m guessing their point is unlike binary trees which have two children per node, B trees can have as many children per node is best for cache locality&#x2F;SIMD&#x2F;etc. Which despite being &quot;heavyweight&quot; (wasted space if not all children per node are occupied) is faster in practice because it&#x27;s cheaper to preload large unused blocks to cache rather than only access memory when it is needed.
            • entrope7 hours ago
              Every node in a binary tree needs a value and two child pointers, though. That&#x27;s asymptotically almost twice as many child pointers per value as a B-tree has.
              • hinkley6 hours ago
                It’s a good thing this article isn’t about binary trees then.
      • wrs8 hours ago
        Yes, that hardware is called &quot;the memory cache&quot;. B-trees were invented because disk reads were very expensive. Now, memory cache fills are very expensive.
    • tyre9 hours ago
      Is this AI? Why do we need a summary of the actual article in a comment?
      • bertonvv9 hours ago
        From what I&#x27;ve seen on here many commenters didn&#x27;t read the article, only the title (I&#x27;ve been guilty of this too). OP is maybe just adapting to HN culture.
        • hinkley8 hours ago
          There aren&#x27;t many commenters at the time you posted this. Which makes this conversation feel even more artificial...
          • bertonvv7 hours ago
            I meant in general on this site. Dislike the insinuation that I&#x27;m generative AI.
      • WD-429 hours ago
        The actual article is AI too so this is just saving you time.
        • hinkley8 hours ago
          <a href="https:&#x2F;&#x2F;github.com&#x2F;valkey-io&#x2F;valkey-io.github.io&#x2F;pull&#x2F;665&#x2F;commits" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;valkey-io&#x2F;valkey-io.github.io&#x2F;pull&#x2F;665&#x2F;co...</a><p>The PR for the article. I&#x27;m not convinced it&#x27;s AI, but I didn&#x27;t do a deep dive on the commit tree just poked around a bit.
  • jauntywundrkind4 hours ago
    Thanks Bill Pugh for skiplists, worked great for so long. Go terps. <a href="https:&#x2F;&#x2F;dl.acm.org&#x2F;doi&#x2F;10.1145&#x2F;78973.78977" rel="nofollow">https:&#x2F;&#x2F;dl.acm.org&#x2F;doi&#x2F;10.1145&#x2F;78973.78977</a>
  • vivzkestrel7 hours ago
    - valkey vs redis vs dragonfly 2027?
  • WD-429 hours ago
    As a coding exercise I implemented a redis that utilized skiplists. I was excited to read this article. Turns out it&#x27;s ai slop. Seriously people, stop it. This hurts to read.
    • tyre9 hours ago
      The PR (<a href="https:&#x2F;&#x2F;github.com&#x2F;valkey-io&#x2F;valkey&#x2F;pull&#x2F;4206" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;valkey-io&#x2F;valkey&#x2F;pull&#x2F;4206</a>) is much better.
      • hinkley8 hours ago
        Can I convince you to post this as a top level?
  • charlie2agent5 hours ago
    [flagged]
  • yoy07216 hours ago
    [flagged]
  • laruss53 hours ago
    [flagged]
  • dropdropteam9 hours ago
    [flagged]