Skip to content

Conversation

@byroot
Copy link
Member

@byroot byroot commented Nov 4, 2025

Closes: #888

  • Mark it as inline.
  • Use RSTRING_GETMEM, instead of RSTRING_LEN and RSTRING_PTR.
  • Use an inlinable version of memcmp.
== Parsing activitypub.json (58160 bytes)
ruby 3.4.6 (2025-09-16 revision dbd83256b1) +YJIT +PRISM [arm64-darwin24]
Comparison:
              before:    11766.6 i/s
               after:    12272.1 i/s - 1.04x  faster

== Parsing twitter.json (567916 bytes)
ruby 3.4.6 (2025-09-16 revision dbd83256b1) +YJIT +PRISM [arm64-darwin24]
Comparison:
              before:     1333.2 i/s
               after:     1422.0 i/s - 1.07x  faster

== Parsing citm_catalog.json (1727030 bytes)
ruby 3.4.6 (2025-09-16 revision dbd83256b1) +YJIT +PRISM [arm64-darwin24]
Comparison:
              before:      656.3 i/s
               after:      673.1 i/s - 1.03x  faster

== Parsing float parsing (2251051 bytes)
ruby 3.4.6 (2025-09-16 revision dbd83256b1) +YJIT +PRISM [arm64-darwin24]
Comparison:
              before:      276.8 i/s
               after:      276.4 i/s - same-ish: difference falls within error

byroot and others added 2 commits November 4, 2025 09:03
Only apply these definitions on 64 bits archs, as it's unclear
if they have performance benefits or compatibility issues on
32bit archs.
Closes: ruby#888

- Mark it as `inline`.
- Use `RSTRING_GETMEM`, instead of `RSTRING_LEN` and `RSTRING_PTR`.
- Use an inlinable version of `memcmp`.

```
== Parsing activitypub.json (58160 bytes)
ruby 3.4.6 (2025-09-16 revision dbd83256b1) +YJIT +PRISM [arm64-darwin24]
Comparison:
              before:    11766.6 i/s
               after:    12272.1 i/s - 1.04x  faster

== Parsing twitter.json (567916 bytes)
ruby 3.4.6 (2025-09-16 revision dbd83256b1) +YJIT +PRISM [arm64-darwin24]
Comparison:
              before:     1333.2 i/s
               after:     1422.0 i/s - 1.07x  faster

== Parsing citm_catalog.json (1727030 bytes)
ruby 3.4.6 (2025-09-16 revision dbd83256b1) +YJIT +PRISM [arm64-darwin24]
Comparison:
              before:      656.3 i/s
               after:      673.1 i/s - 1.03x  faster

== Parsing float parsing (2251051 bytes)
ruby 3.4.6 (2025-09-16 revision dbd83256b1) +YJIT +PRISM [arm64-darwin24]
Comparison:
              before:      276.8 i/s
               after:      276.4 i/s - same-ish: difference falls within error
```

Co-Authored-By: Scott Myron <[email protected]>
@byroot byroot changed the title Micro-optimize rstring_cache_fetch Micro-optimize rstring_cache_fetch Nov 4, 2025
@byroot byroot merged commit a67d1a1 into ruby:master Nov 4, 2025
37 checks passed
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

Successfully merging this pull request may close these issues.

1 participant