Skip to content

dispatch-log: use unbuffered channels, detect rotation via fs events - #120

Closed
Bogdanp wants to merge 1 commit into
racket:masterfrom
Bogdanp:master
Closed

Bogdanp wants to merge 1 commit into
racket:masterfrom
Bogdanp:master

Conversation

@Bogdanp

@Bogdanp Bogdanp commented Jun 13, 2022

Copy link
Copy Markdown
Contributor

Prompted by the discussion in #119. This is only a slight improvement, so feel free to ignore if you don't think the change is worth it. I benchmarked the change by hitting this minimal app running on a basic Digital Ocean droplet at 1k RPS for two minutes against Racket 8.5. The logs were written to an attached block storage volume and the attacking script rotated the log file once every 30 seconds. Aside from the small performance improvement, the change to use an unbuffered channel should make logging a little safer under load since logs can't pile up in the queue if storage is slow (though I don't have sufficiently slow storage to test this with, so this point might be moot).

Master branch without logging:

Requests      [total, rate, throughput]         120000, 1000.01, 1000.00
Duration      [total, attack, wait]             2m0s, 2m0s, 692.047µs
Latencies     [min, mean, 50, 90, 95, 99, max]  374.864µs, 828.88µs, 580.348µs, 779.622µs, 1.331ms, 7.143ms, 65.443ms
Bytes In      [total, mean]                     600000, 5.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:120000
Error Set:

Master branch with dispatch-log:

Requests      [total, rate, throughput]         120000, 1000.02, 1000.00
Duration      [total, attack, wait]             2m0s, 2m0s, 1.285ms
Latencies     [min, mean, 50, 90, 95, 99, max]  355.839µs, 7.235ms, 638.343µs, 6.947ms, 16.195ms, 265.735ms, 572.065ms
Bytes In      [total, mean]                     600000, 5.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:120000
Error Set:

This branch with dispatch-log:

Requests      [total, rate, throughput]         120000, 1000.03, 1000.02
Duration      [total, attack, wait]             2m0s, 2m0s, 622.42µs
Latencies     [min, mean, 50, 90, 95, 99, max]  343.949µs, 982.759µs, 598.051µs, 1.088ms, 1.988ms, 6.797ms, 182.496ms
Bytes In      [total, mean]                     600000, 5.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:120000
Error Set:

Memory use is about the same between the two versions:

Screenshot 2022-06-13 at 10 40 56

(the y axis is milliseconds since program start, the "updated" line is cut short because there were no more GC logs beyond that point)

Baseline @ 2.5K requests/second for 2 minutes:

    Requests      [total, rate, throughput]         300000, 2500.01, 2500.00
    Duration      [total, attack, wait]             2m0s, 2m0s, 633.693µs
    Latencies     [min, mean, 50, 90, 95, 99, max]  228.976µs, 2.808ms, 360.599µs, 808.569µs, 1.1ms, 99.642ms, 340.486ms
    Bytes In      [total, mean]                     1500000, 5.00
    Bytes Out     [total, mean]                     0, 0.00
    Success       [ratio]                           100.00%
    Status Codes  [code:count]                      200:300000
    Error Set:

After this change:

    Requests      [total, rate, throughput]         300000, 2500.01, 2500.00
    Duration      [total, attack, wait]             2m0s, 2m0s, 660.098µs
    Latencies     [min, mean, 50, 90, 95, 99, max]  221.044µs, 666.861µs, 328.204µs, 635.192µs, 794.381µs, 6.891ms, 132.629ms
    Bytes In      [total, mean]                     1500000, 5.00
    Bytes Out     [total, mean]                     0, 0.00
    Success       [ratio]                           100.00%
    Status Codes  [code:count]                      200:300000
    Error Set:

Memory use is the same between this and the master branch on my
machine, but I suspect my machine's IO is just too fast.  If I were to
try this on a cloud machine, I suspect there would be a significant
improvement with this change.
@samth

samth commented Jun 13, 2022

Copy link
Copy Markdown
Member

The improvement to the distribution of response times seems quite significant. 6x better at p90!

@jeapostrophe

Copy link
Copy Markdown
Contributor

I think it is worth it

@Bogdanp

Bogdanp commented Jun 28, 2022

Copy link
Copy Markdown
Contributor Author

This was superseded by #121, closing.

@Bogdanp Bogdanp closed this Jun 28, 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.

3 participants