GithubHelp home page GithubHelp logo

fastdictionarytest's People

Contributors

cannero avatar dadhi avatar matthewcrews avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fastdictionarytest's Issues

Robin Hood - bug when inserting into tombstones

Hey there!

I'm trying to implement hash dicts in Elm based on your repo and videos (and the awesome C++Now 2018 talk by Malte).

I've just got round to Robin Hood, and I have a property based test suite set up checking that outwardly my dict behaves exactly the same as the "known to be correct" stdlib Dict.

The test suite has found an issue with your approach to inserting an item into a Tombstone. Consider this scenario:

  1. Start with empty table (4 buckets)
  2. Insert "A" (let's say it hashes to bucket index 3) -> will end up in bucket 3 with offset 0
  3. Insert "B" (hashes to bucket index 3) -> will end up in bucket 0 with offset 1
  4. Remove "A" -> now bucket 3 is a Tombstone
  5. Insert "B" -> it sees a tombstone in bucket 3, and gets inserted there
  6. Convert to list -> you get two Bs instead of just one!

That's because after step 5 the array looks like:

idx offset key
0 1 "B"
1 -1 Empty
2 -1 Empty
3 0 "B"

instead of

idx offset key
0 1 "B"
1 -1 Empty
2 -1 Empty
3 0 Tombstone

On the other hand, if in step 5 you continued to the next index after seeing a tombstone, you'd find the B in bucket 0 and would replace its value / end there.

AccessViolationException in stringComparer

Hi, Matthew. First, thanks for doing this. I've sped up a lot of code with your work.

I don't have a whole lot of information to share about this issue, but here's what I know. In a recent project, I've really ramped up usage of dictionaries -- based on ByteListRobinHoodVec128. I have about 7 of them, some with about 50k elements, some with about half a million.

On my first "big" test run, I received a System.AccessViolationException in the implementation of GetHashCode for the stringComparer. (function startes line 68 in ByteListRobinHoodVec128.fs)

I don't have a lot more information than that. I can tell you that the dictionary had about 50k elements, that the keys were all string representations of int64 values, and the values were structs of about 1k each. I'm not sure any of that is relevant :)

I've stared at the GetHashCode implementation for a long while and I'll be darned if I can see a problem. If I replace it with one of the StringComparer implementations in System the problem disappears. The exception does say that "this is often and indication that other memory is corrupt", but I'm not sure where that would be. All the rest of the code is either standard .NET 6.0 stuff or MongoDB queries.

If you have any insight, I'd love to hear it.

Infinite loop when dictionary is empty

I started using the implementation in ByteListRobinHoodInline.fs per your suggestion in the previous issue I raised.

When the dictionary is empty, Bucket.IsLast never seems to evaluate to true. As a result, lookups in an empty dictionary cause an infinite loop.

I added a check for count = 0 where it checks IsLast in the main body of the Item function and that seems to have sorted it. But obviously that adds another CMP instruction and that's not optimal, is it? :) I was wondering if you knew of another way to do it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.