Skip to content

Surprising accessor performance for ARec  #150

Description

@Philonous

The accessors benchmark suggests that ARec field access should be only slightly worse than Rec field access for fields in the front and stay constant for fields with higher indices while Rec fields become increasingly more expensive to access. For example, on my machine, access to Rec takes 6.1ns for index 0 up to 12.4ns for index 15, for an average of ~9.2ns. On the other hand, access time ARec fields is constant with ~7.5 ns. (See included figure)

This would suggest that for access patterns that exercise all fields equally, ARec should outperform Rec. However, I added a new benchmark simulating random read access where I retrieve all elements once and calculate their sum: Link to gist

Here, ARec fares significantly worse than Rec with 68 vs 55 ns!

image

I find this discrepancy surprising. Is there perhaps a problem in the way the benchmark is written?

Metadata

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