Skip to content

🌍 #349 Gen performance enhancements#351

Merged
nth-commit merged 6 commits into
mainfrom
terra/gen-performance-check-2
Aug 7, 2022
Merged

🌍 #349 Gen performance enhancements#351
nth-commit merged 6 commits into
mainfrom
terra/gen-performance-check-2

Conversation

@nth-commit

Copy link
Copy Markdown
Owner

…ty with a readonly interface

Was using an ImmutableList but it's pretty slow for the use-case of iteratively adding to it. ImmutableArray has similar performance to List, but stutters when generating generating lists with a high count. When we simply use a List, we can allocate the capacity upfront.

Previous (ImmutableList):

```
|  Method | size |       Mean |     Error |    StdDev |     Median |
|-------- |----- |-----------:|----------:|----------:|-----------:|
| ListGen |   10 |   141.0 us |  12.04 us |  35.32 us |   138.7 us |
| ListGen |   50 |   547.0 us |  15.31 us |  44.16 us |   542.7 us |
| ListGen |  100 | 1,170.3 us |  50.84 us | 147.50 us | 1,129.4 us |
| ListGen |  500 | 6,209.3 us | 119.20 us | 117.07 us | 6,193.8 us |
```

Now (List):

```
|  Method | size |       Mean |    Error |   StdDev |      Median |
|-------- |----- |-----------:|---------:|---------:|------------:|
| ListGen |   10 |   112.0 us |  8.93 us | 26.34 us |    98.88 us |
| ListGen |   50 |   400.4 us |  7.96 us | 14.55 us |   400.79 us |
| ListGen |  100 |   775.7 us | 14.95 us | 16.00 us |   775.65 us |
| ListGen |  500 | 5,837.2 us | 73.30 us | 64.98 us | 5,823.66 us |
```

And ImmutableArray, for interest:

```
|  Method | size |       Mean |     Error |    StdDev |     Median |
|-------- |----- |-----------:|----------:|----------:|-----------:|
| ListGen |   10 |   114.9 us |   8.20 us |  24.18 us |   105.7 us |
| ListGen |   50 |   403.2 us |   8.06 us |  15.72 us |   404.6 us |
| ListGen |  100 |   790.7 us |  14.71 us |  13.76 us |   791.4 us |
| ListGen |  500 | 6,485.2 us | 128.36 us | 120.07 us | 6,467.7 us |
```
…evel

Results in about a 10% increase in performance for lists of < 100.

Also made the list gen benchmark exercise shrinks more by not declaring a constant (non-shrinking) count.

Before:

```
|  Method | size |        Mean |     Error |    StdDev |
|-------- |----- |------------:|----------:|----------:|
| ListGen |   10 |    95.34 us |  7.731 us |  22.80 us |
| ListGen |   50 |   317.55 us | 10.500 us |  30.96 us |
| ListGen |  100 |   577.27 us | 11.460 us |  30.59 us |
| ListGen |  500 | 3,969.47 us | 78.922 us | 223.89 us |
```

After:

```
|  Method | size |        Mean |     Error |    StdDev |
|-------- |----- |------------:|----------:|----------:|
| ListGen |   10 |    86.97 us |  6.249 us |  18.43 us |
| ListGen |   50 |   282.29 us |  5.469 us |  13.00 us |
| ListGen |  100 |   548.28 us | 10.949 us |  28.84 us |
| ListGen |  500 | 3,806.14 us | 75.494 us | 212.93 us |
```
About 20-25% performance increase. Affects ListGen, SetGen, InfiniteGen, and all the other gens that depend on those (i.e. StringGen, EnumGen).

Before:

```
|  Method | size |        Mean |     Error |    StdDev |
|-------- |----- |------------:|----------:|----------:|
| ListGen |   10 |    94.92 us |  7.037 us |  20.53 us |
| ListGen |   50 |   294.40 us |  5.845 us |  15.19 us |
| ListGen |  100 |   579.21 us | 11.517 us |  26.69 us |
| ListGen |  500 | 3,969.76 us | 83.782 us | 232.16 us |
```

After:

```
|  Method | size |        Mean |     Error |    StdDev |
|-------- |----- |------------:|----------:|----------:|
| ListGen |   10 |    79.05 us |  4.358 us |  12.85 us |
| ListGen |   50 |   244.06 us |  6.232 us |  17.68 us |
| ListGen |  100 |   465.13 us |  9.205 us |  24.57 us |
| ListGen |  500 | 2,656.37 us | 53.010 us | 150.38 us |
```
@nth-commit
nth-commit merged commit c8bd990 into main Aug 7, 2022
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