Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Add a performance spec #69

Merged
merged 6 commits into from
Apr 6, 2020
Merged

Add a performance spec #69

merged 6 commits into from
Apr 6, 2020

Conversation

mriddle
Copy link
Contributor

@mriddle mriddle commented Apr 2, 2020

There's no mention of the overhead that this gem introduces and I wanted a benchmark before adding the validation code in #63

This PR also includes some minor refactoring, more detail can be found in the associated commits.

Strip some whitespace and log the class since we're already logging the
message.

Before
`GlobalUID error:  execution expired Timed out establishing a connection to test_id_server_1`

After
`GlobalUID error: GlobalUid::ConnectionTimeoutException Timed out establishing a connection to test_id_server_1`
@mriddle mriddle added this to the 4.0.0 milestone Apr 2, 2020
@mriddle mriddle requested a review from a team as a code owner April 2, 2020 14:23
@mriddle mriddle force-pushed the mriddle-refactor branch from a89a704 to 999cf63 Compare April 2, 2020 14:24
Copy link
Member

@bquorning bquorning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff!

I was thinking, since the performance test is quite a bit slower than, and outputs a lot more than the . from all other test, if we should run it as a separate rake task? Rakefile could say e.g.

task :default => ['test', 'performance_test']

What do you think?

mriddle added 3 commits April 3, 2020 08:14
The defaults being set differed to those set by the test_helper.
Not being used yet but it will in a follow-up PR
To opt out of global ID you must set `use_global_uid` to `false` in the
migration and `disable_global_uid` on the model.

Without this, the `before_create` hook in the `ActiveRecordExtension`
will still be executed
@mriddle mriddle force-pushed the mriddle-refactor branch 5 times, most recently from 35ddc6a to c7c0f94 Compare April 3, 2020 10:08
@mriddle mriddle self-assigned this Apr 3, 2020
@mriddle mriddle force-pushed the mriddle-refactor branch from c7c0f94 to 81f28d6 Compare April 3, 2020 10:18
mriddle added 2 commits April 6, 2020 12:39
This spec highlights the overhead created by using GlobalUID. The
results will vary per run but it will give you an idea and highlight
performance issues if they're introduced.

Output from my local machine:

```
Warming up --------------------------------------
       WithGlobalUID    77.000  i/100ms
    WithoutGlobalUID   127.000  i/100ms
Calculating -------------------------------------
       WithGlobalUID    923.498  (± 8.3%) i/s -      4.620k in   5.041687s
    WithoutGlobalUID      1.330k (± 6.5%) i/s -      6.731k in   5.081601s

Comparison:
    WithoutGlobalUID:     1330.4 i/s
       WithGlobalUID:      923.5 i/s - 1.44x  slower
```

As you can see, the performance overhead is noticable but minimal. With
GlobalUID we're able to generate around 923 records per second. This is
not indicative of the performance you'll get in production, where the
databases are more powerful and there's network latency.

The assertion has been commented out due to a lot of variance between
runs, things I've tried:
 * Increase the warm-up (up to 5 sec) and time intervals (up to 20 sec)
 * Use `kalibera` with `benchmark-ips` and play with confidence levels
 * Increase the threshold to 2 seconds, it passes but it's not really
 valuable
 * Run many times and check an average or check that one has the result
 we're after, caters for outliers but also not valuable. Will miss
 upward trends

We could look at commiting the results and keeping track in source
control, that would give us visibility when/if performance issues are
introduced but I'm parking that decision for another day.
Nested files under their respective directories now that we've got a
couple tests and the support files are used in more than one place
@mriddle mriddle force-pushed the mriddle-refactor branch from 81f28d6 to 95ea2f5 Compare April 6, 2020 10:39
@mriddle mriddle merged commit 64cd2b1 into master Apr 6, 2020
@mriddle mriddle deleted the mriddle-refactor branch April 6, 2020 10:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants