Skip to content

Consider finding (or writing if need be) a float32 native math library #28

Open
@UserAB1236872

Description

After writing some benchmarks today (not for this package, just dicking around with benchmarking fast inverse square root compared to Go's stdlib and such), it's become clear that the rampant type conversions are a significant performance hit. "Significant" is in relative terms, but code of the form:

float32(1.0 / math.Sqrt(float64(n)))

takes about 15.5 ns/op compared to 3.5 ns/op for float64-native. I suspected this, hence why this library generally takes a "convert as infrequently as possible" approach. However, I would consider this significant enough to be worth worrying about.

While Go's standard library is written partially in assembly, I don't think it should be too difficult to rewrite (I think most of the assembly conversions would amount to "swap a letter in the instruction names to do 32-bit operations instead"). However, I'd like to look into existing options if they exist before undertaking this.

I did find this, but the repository was deleted for some ominous reason.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions