Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

will xxh64 work in ebpf? #8

Open
kolinfluence opened this issue Jun 9, 2023 · 6 comments
Open

will xxh64 work in ebpf? #8

kolinfluence opened this issue Jun 9, 2023 · 6 comments

Comments

@kolinfluence
Copy link

great work!
will xxh64 work in ebpf?

otherwise, which version will work 100% in ebpf?

@easyaspi314
Copy link
Owner

easyaspi314 commented Jun 9, 2023

xxHash is portable with the basic C90+long long ISA, so it will always work.

However, whether it is performant is a different story. eBPF seems to have a lack of unaligned access so there may be a significant overhead on unaligned loads. All xxHash functions will work fine, but XXH3 will run rather inefficiently since there is no aligned path (and a lack of SIMD). XXH32 and XXH64 will run at full speed if the pointer is sufficiently aligned though.

@easyaspi314
Copy link
Owner

easyaspi314 commented Jun 9, 2023

I take that back, Clang eBPF doesn't support struct returns.

Therefore XXH3 will not work, but XXH32 and XXH64 should compile with -DXXH_NO_XXH3.

@Cyan4973 perhaps should we try to work on this? Perhaps having XXH3_NO_STRUCT_RETURN as an alternative ABI?

@easyaspi314
Copy link
Owner

Update: Clang supports returning structs with static inline __attribute__((always_inline)):

extern void XXH3_128bits_noStructReturn(XXH128_hash_t *XXH_RESTRICT output, const void *XXH_RESTRICT ptr, size_t n);

__attribute__((always_inline, unused))
static __inline__ XXH128_hash_t XXH3_128bits(const void *ptr, size_t n)
{
    XXH128_hash_t ret;
    XXH3_128bits_noStructReturn(&ret, ptr, n);
    return ret;
}

@easyaspi314
Copy link
Owner

it was at this moment I realized this was my own repo. I'm dumb.

XXH64 will definitely work, but I would recommend using Cyan4973/xxHash as that has a lot of low level optimizations.

@kolinfluence
Copy link
Author

kolinfluence commented Jun 10, 2023

@easyaspi314 thx for the prompt feedback
can you take a look at this issue and the pdf link below to confirm your comment?

Cyan4973/xxHash#808

trying to make sure ebpf will be portable. so not very sure if you can confirm this. thx
there's an article online comparing jhash and spookyhash with ebpf
https://fosdem.org/2023/schedule/event/bpf_hashing/attachments/slides/5812/export/events/attachments/bpf_hashing/slides/5812/the_talk

do hope u can come up with an ebpf compatible one. performance-wise is secondary. just need it working in ebpf

@kolinfluence
Copy link
Author

kolinfluence commented Jun 10, 2023

@easyaspi314 do you know if there's a version of yours that's available in ebpf, a lot of people will use it?
i'm checking out the license now. can you update it? it's not really one of those mainstream ones. i mean it's not like apache / bsd / mit.

waiting for your feedback!

p.s. : i have working cityhash using ebpf but it's extremely exciting if one of the xxhash line is available for use in ebpf.
pls help verify this. appreciate it.

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

No branches or pull requests

2 participants