Skip to content

Conversation

eduherminio
Copy link
Member

Implement a no-regex solution, which is faster and allocates less.
Of course, this will get translated in ~0 elo

BenchmarkDotNet v0.14.0, Ubuntu 22.04.4 LTS (Jammy Jellyfish)
AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores
.NET SDK 8.0.401
  [Host]     : .NET 8.0.8 (8.0.824.36612), X64 RyuJIT AVX2
  DefaultJob : .NET 8.0.8 (8.0.824.36612), X64 RyuJIT AVX2

| Method          | command              | Mean       | Error     | StdDev    | Median     | Ratio | RatioSD | Gen0   | Allocated | Alloc Ratio |
|---------------- |--------------------- |-----------:|----------:|----------:|-----------:|------:|--------:|-------:|----------:|------------:|
| Sequential      | go infinite          | 1,889.8 ns |  22.33 ns |  19.80 ns | 1,883.3 ns |  1.00 |    0.01 |      - |     272 B |        1.00 |
| Parallel        | go infinite          | 3,257.4 ns |  63.33 ns | 132.20 ns | 3,232.4 ns |  1.72 |    0.07 | 0.0191 |    1826 B |        6.71 |
| CapturingGroups | go infinite          | 1,577.6 ns |   5.56 ns |   4.34 ns | 1,577.9 ns |  0.83 |    0.01 | 0.0172 |    1504 B |        5.53 |
| NoRegex         | go infinite          |   868.0 ns |  10.13 ns |   9.47 ns |   864.2 ns |  0.46 |    0.01 | 0.0029 |     272 B |        1.00 |
|                 |                      |            |           |           |            |       |         |        |           |             |
| Sequential      | go wt(...)c 500 [42] | 4,330.4 ns |  52.75 ns |  49.34 ns | 4,327.7 ns |  1.00 |    0.02 | 0.0076 |    1248 B |        1.00 |
| Parallel        | go wt(...)c 500 [42] | 4,263.0 ns |  82.61 ns | 234.34 ns | 4,185.8 ns |  0.98 |    0.05 | 0.0305 |    2808 B |        2.25 |
| CapturingGroups | go wt(...)c 500 [42] | 3,883.5 ns |  22.45 ns |  21.00 ns | 3,885.4 ns |  0.90 |    0.01 | 0.0534 |    4800 B |        3.85 |
| NoRegex         | go wt(...)c 500 [42] | 1,011.2 ns |   6.44 ns |   6.02 ns | 1,010.5 ns |  0.23 |    0.00 | 0.0019 |     272 B |        0.22 |
|                 |                      |            |           |           |            |       |         |        |           |             |
| Sequential      | go wt(...)00000 [78] | 5,401.7 ns | 101.28 ns |  94.74 ns | 5,400.7 ns |  1.00 |    0.02 | 0.0153 |    1728 B |        1.00 |
| Parallel        | go wt(...)00000 [78] | 5,129.1 ns | 101.88 ns | 125.11 ns | 5,122.6 ns |  0.95 |    0.03 | 0.0381 |    3288 B |        1.90 |
| CapturingGroups | go wt(...)00000 [78] | 5,515.9 ns | 105.29 ns | 103.41 ns | 5,489.9 ns |  1.02 |    0.03 | 0.0839 |    7064 B |        4.09 |
| NoRegex         | go wt(...)00000 [78] | 1,179.3 ns |  10.16 ns |   9.01 ns | 1,179.2 ns |  0.22 |    0.00 | 0.0019 |     272 B |        0.16 |
|                 |                      |            |           |           |            |       |         |        |           |             |
| Sequential      | go wt(...)go 40 [62] | 5,020.1 ns |  67.46 ns |  63.10 ns | 5,036.3 ns |  1.00 |    0.02 | 0.0153 |    1488 B |        1.00 |
| Parallel        | go wt(...)go 40 [62] | 4,559.2 ns |  90.55 ns | 190.99 ns | 4,537.0 ns |  0.91 |    0.04 | 0.0305 |    3048 B |        2.05 |
| CapturingGroups | go wt(...)go 40 [62] | 5,236.4 ns |  62.20 ns |  55.14 ns | 5,242.3 ns |  1.04 |    0.02 | 0.0839 |    7032 B |        4.73 |
| NoRegex         | go wt(...)go 40 [62] | 1,089.1 ns |   4.17 ns |   3.90 ns | 1,088.7 ns |  0.22 |    0.00 | 0.0019 |     272 B |        0.18 |

Just ouf of curiosity, 500 games:

Test  | perf/go-parsing
Elo   | -6.95 +- 19.86 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=32MB
LLR   | -0.17 (-2.25, 2.89) [-5.00, 0.00]
Games | 500: +133 -143 =224
Penta | [16, 55, 110, 61, 8]
https://openbench.lynx-chess.com/test/716/

@eduherminio eduherminio marked this pull request as ready for review September 13, 2024 15:30
@eduherminio eduherminio enabled auto-merge (squash) September 13, 2024 15:30
@eduherminio eduherminio merged commit b9467ee into main Sep 13, 2024
27 checks passed
@eduherminio eduherminio deleted the perf/go-parsing branch September 13, 2024 15:31
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