Skip to content

Significant performance degradation in super_diff 0.8 #139

Open

Description

@hedgesky

Hi @mcmire,
thank you a lot for an amazing gem! It removed a lot of pain from working with some of the specs we have in the codebase.

I noticed that after upgrading super_diff to 0.8 our test suite slowed down by 4x (from ≈30s to 2m). Downgrading to 0.7 resolves the issue.

I ran some profiling and tried to analyse execution path, and it looks like the issue appeared after merging #91. Profiling showed that majority of the time is spent in SuperDiff::ObjectInspection::InspectionTree#render_to_string.

I tried to understand what's going on and how it would be possible to avoid that, but wasn't able to, unfortunately.

Attaching the profiling screenshot:
Screenshot 2021-06-23 at 11 57 50

Activity

  1. mcmire commented on Dec 29, 2022

    @mcmire
    Collaborator

    Hi @hedgesky,

    Sorry for taking so long to reply to this issue. It initially surprised me to hear that the gem decreased performance because it really should only kick in when a test fails, but after looking at your screenshot, I'm realizing that the gem monkeypatches the description for each built-in RSpec matcher, so every time RSpec accesses a description it'll go through some logic here in the gem. I would imagine that some simple tricks can be applied to the inspection logic to fix the performance issue. Anyway, thank you for reporting this. I admit that I've been lax in tending to this gem lately due to life, but I will try to make an effort to take a closer look at this soon.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions