Open kolinfluence opened 1 year ago
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.
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?
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;
}
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.
@easyaspi314 thx for the prompt feedback can you take a look at this issue and the pdf link below to confirm your comment?
https://github.com/Cyan4973/xxHash/issues/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
@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.
great work! will xxh64 work in ebpf?
otherwise, which version will work 100% in ebpf?