nqminhuit / gis

Java Command Line Application which extends Git for supporting git-modules
1 stars 0 forks source link

Will switching to Java 21's "Virtual Thread" have any benefit over VertX? #71

Closed nqminhuit closed 2 weeks ago

nqminhuit commented 8 months ago
nqminhuit commented 2 weeks ago

Virtual Threads (VT) are only strong at thousands of concurrent request, our gis does not use that much of IO requests. One benefit of VT I can see now is that it provides the sequential code order, which is handy when we need to print status to stdout. Using asynchronous from Vertx is complex but it make the program lighter and still fast, however, it's difficult to write unit tests.

VT Pros:

VT Cons:

Vertx Pros:

Vertx Cons:

We to test performance of VT and Vertx first, if VT faster or similar to Vertx, then it's worth the switch. Otherwise we need to evaluate more. For that to work, we need to finish these 2 issues first: #13 and #15

nqminhuit commented 2 weeks ago

Performance: 1.1.4 with VertX:

| Command          | Mean [ms]       | Min [ms] | Max [ms] | Relative |
|------------------+-----------------+----------+----------+----------|
| gis              | 98.4 ± 5.9      |     89.0 |    110.9 |     1.00 |
| gis branches -nn | 73.4 ± 3.1      |     65.6 |     82.8 |     1.00 |
| gis branches     | 74.2 ± 3.0      |     66.3 |     79.2 |     1.00 |
| gis co br_tst_1  | 4344.0 ± 2407.7 |   1264.6 |   7656.9 |     1.00 |
| gis fetch        | 5095.3 ± 1722.7 |   3494.3 |   8454.7 |     1.00 |
| gis files        | 3578.6 ± 50.8   |   3535.7 |   3715.6 |     1.00 |
| gis status       | 98.6 ± 4.6      |     88.8 |    107.8 |     1.00 |

2.0.0-dev with Virtual Threads:

| Command          | Mean [ms]       | Min [ms] | Max [ms] | Relative |
|------------------+-----------------+----------+----------+----------|
| gis              | 150.6 ± 18.0    |    114.0 |    175.9 |     1.00 |
| gis branches -nn | 151.3 ± 26.9    |     73.3 |    190.1 |     1.00 |
| gis branches     | 147.8 ± 30.1    |     82.5 |    204.5 |     1.00 |
| gis co br_tst_1  | 2478.8 ± 2192.4 |   1096.8 |   8047.5 |     1.00 |
| gis fetch        | 5665.2 ± 1504.6 |   4200.7 |   8196.0 |     1.00 |
| gis files        | 3470.3 ± 45.2   |   3412.6 |   3556.2 |     1.00 |
| gis status       | 161.6 ± 17.2    |    123.1 |    190.5 |     1.00 |
nqminhuit commented 2 weeks ago

With Virtual threads we can write maintanable code and facilitate built-in java without extra dependencies. It's worth the switch.