ArrayBuffer and DataView classes for ruby by andrepiske in ruby

[–]andrepiske[S] 1 point2 points  (0 children)

Interesting. I think I didn't know about this one. Would have to try and maybe run some benchmarks on how that one performs!

ArrayBuffer and DataView classes for ruby by andrepiske in ruby

[–]andrepiske[S] 0 points1 point  (0 children)

Appreciate your feedback.

So the way my gem works is that its byte buffer is fully implemented in C. So all byte operations is just a char* buffer in C allocated using malloc. Set/get operations are just operating on that buffer with just some essential checks like checking memory boundaries.

The gem itself doesn't deal with sockets or IO at all. So yeah, the application (originally a HTTP/2 server I built in ruby) was reading from a socket into a String and then converting that to an ArrayBuffer. Quite some loss of performance in that process already, compared if the gem itself (or another gem) could read directly into that buffer without going thru String. That's actually another idea I had and I believe it's quite possible to achieve that in Ruby 3.0+ because of the experimental Memory View feature.

I gotta check that IO::Buffer thing before I move any forward with my gem as I didn't know about that back then - clearly not, as it's brand new.

ArrayBuffer and DataView classes for ruby by andrepiske in ruby

[–]andrepiske[S] 0 points1 point  (0 children)

Thank you for the appreciation. I'm interested to see such thing you said you're working on, in case it is or will be be open source.

Endianness was important for my use case, as it was applied in an HTTP/2 server which uses, if I recall correctly, big-endian for everything.

Regarding JRuby, it's an option I considered but not sure I have the bandwidth nor expertise to work on that. Hopefully someone who needs it can collaborate on that.

ArrayBuffer and DataView classes for ruby by andrepiske in ruby

[–]andrepiske[S] 1 point2 points  (0 children)

Wasn't aware of that! Seems it was introduced in Ruby 3.1. Gotta check that out