Freelancer needed for a function (pay $80)

Hello everyone!

I'm looking for one freelancer to help me with a small function in Rust.
i'm paying $80, it's about 20 lines of code.

PM me if interested.
For moderators, sorry if it's the wrong section, didn't know where to post.

Thank you.

Hello! Welcome to the Rust Users Forum.

What kind of function is this? If it's something like an implementation of a sorting algorithm, alot of people here would be fine with helping on that, but if it's working with proprietary (Non-releasable) code, then a public forum is not the place to go for help of this kind.

1 Like

I'm tied up with an NDA which is why :slight_smile:
It's mostly sorting yeah.

Well, the best I can offer is browsing what the community has to offer in regards to libraries that sort things, but there are alot of different kinds of sorting adapters, algorithms, etc. These can be browsed under crates.io:
https://crates.io/keywords/sorting
But a very specific algorithm would probably need some more specialized work than a public library (IE, an algorithm for sorting specific patterns in some data)

1 Like

Can you tell us what you can, for example, what data structure you are trying to sort or what are the performance requirements?

2 Likes

Thank you guys!

i've annoymized some of the functions.

type Key = [u8; 32];

type Data = Vec<[u8; 32]>;

#[derive(Debug)]
struct Value {
    data: Data,
    // other fields...
}

fn extract(map: BTreeMap<Key, Value>) -> Vec<[u8; 32]> {
    map.into_par_iter()
        .flat_map(|(_, v)| v.data)
        .collect()
}

Is that the fastest I can do? (it's using rayon)

So you want to get the values out of a BTreeMap? Do you need to collect them, could you just return the iterator instead of collecting them?

The values are in the Vec in each Struct.

Is your input always a BTreeMap?

Yeah, It's always a BTreemap, about 20M keys and 10 entries in each value (in the Vec)

Then this is probably the fastest you will get it. Based on what we can see.

Ok, was about the Vec, I tried replacing it with SmallVec but I can't make it work with Rayon :confused:

SmallVec inside the BTreeMap? You can use rayon::iter::ParallelBridge to convert from a normal Iterator into a ParallelIterator.

use rayon::iter::ParallelBridge;
map.into_par_iter()
        .flat_map(|(_, v)| v.data.into_iter().par_bridge())
        .collect()

That is smarter to use SmallVec (about 10 values) inside the Vec?

Yes, you can use SmallVec, this will prevent allocations if you select your buffer carefully. With 20M elements, this is probably good.

1 Like

Awesome! Thanks for the help

1 Like

No problem

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.