Git Product home page Git Product logo

Comments (11)

lemire avatar lemire commented on May 8, 2024 1

Indeed:

#[inline]. This suggests that the function should be inlined, including across crate boundaries.

from simdutf8.

hkratz avatar hkratz commented on May 8, 2024

@lemire That is what I thought but benchmarks proved me otherwise. I will dig up the branch, run the benchmark again and post the comparison here.

from simdutf8.

lemire avatar lemire commented on May 8, 2024

Note also that you could just fallback on a scalar implementation when the platform is not supported. :-)

from simdutf8.

hkratz avatar hkratz commented on May 8, 2024

Note also that you could just fallback on a scalar implementation when the platform is not supported. :-)

That is what it does already. It works similar to simdjson as far as I understand it. The function pointer is initialized to the get_fastest() function in validate_utf8_basic(). On the first invocation it checks what CPU features are supported and then replaces the function pointer to itself with the fastest available implementation for further invocations.

On architectures for which there currently is no SIMD implementation (e.g. ARM right now), the fallback method is compiled in.

from simdutf8.

lemire avatar lemire commented on May 8, 2024

So the following advice might not be needed...

If there is no native implementation for your platform (yet), use the standard library instead.

from simdutf8.

hkratz avatar hkratz commented on May 8, 2024

So the following advice might not be needed...

If there is no native implementation for your platform (yet), use the standard library instead.

Correct, though there is a slight performance penalty with the default LTO setting as Rust does not inline function calls across crate boundaries while it does inline functions calls to the std library.

from simdutf8.

lemire avatar lemire commented on May 8, 2024

Ah. So that explains why you would see weak performance on short strings.

Any way to lift this 'no inlining' limitation? It seems quite substantial.

from simdutf8.

hkratz avatar hkratz commented on May 8, 2024

Compiling with lto=full or lto=thin enables cross-crate inlining. It is just not the default.

I will benchmark delegating the validation of byte sequences shorter than 64 bytes to the std library again with LTO enabled.

from simdutf8.

CJP10 avatar CJP10 commented on May 8, 2024

You might be able to get away with just slapping a #[inline] on the pub fns to hint on inlining across crate boundaries.

from simdutf8.

hkratz avatar hkratz commented on May 8, 2024

You might be able to get away with just slapping a #[inline] on the pub fns to hint on inlining across crate boundaries.

You are both right of course, not sure how I missed that. I have added the #[inline] attribute and will benchmark that and calling std::str::from_utf8() for small strings next.

from simdutf8.

hkratz avatar hkratz commented on May 8, 2024

Fixed in v0.1.1.

from simdutf8.

Related Issues (20)

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.