Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend NonBlockingSemaphore and make release for 1-permit case atomic #8446

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

smola
Copy link
Member

@smola smola commented Feb 25, 2025

What Does This Do

  • Move NonBlockingSemaphore to internal-api.
  • Extend its tests.
  • Make release for the boolean semaphore truly atomic. By definition, a release there always leads to 1 available. While first releasing and then getting the available count will return 0 or 1 inconsistently.

Motivation

NonBlockingSemaphore was written originally for IAST, but we plan to reuse it in AppSec (#8178), and it may be useful for others.

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@smola smola added tag: no release notes Changes to exclude from release notes type: refactoring labels Feb 25, 2025
@pr-commenter
Copy link

pr-commenter bot commented Feb 25, 2025

Benchmarks

Startup

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master smola/nonblocking-semaphore-internal-api
git_commit_date 1740507766 1740561704
git_commit_sha 5a2c959 153aaec
release_version 1.47.0-SNAPSHOT~5a2c959566 1.47.0-SNAPSHOT~153aaecf0f
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1740564200 1740564200
ci_job_id 823432362 823432362
ci_pipeline_id 57003857 57003857
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
kernel_version Linux runner-vukjvz2m-project-304-concurrent-0-e3jnekk9 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:50:46 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux Linux runner-vukjvz2m-project-304-concurrent-0-e3jnekk9 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:50:46 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
module Agent Agent
parent None None
variant iast iast

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 58 metrics, 5 unstable metrics.

Startup time reports for insecure-bank
gantt
    title insecure-bank - global startup overhead: candidate=1.47.0-SNAPSHOT~153aaecf0f, baseline=1.47.0-SNAPSHOT~5a2c959566

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.041 s) : 0, 1040507
Total [baseline] (8.695 s) : 0, 8695283
Agent [candidate] (1.043 s) : 0, 1043207
Total [candidate] (8.699 s) : 0, 8699053
section iast
Agent [baseline] (1.178 s) : 0, 1178442
Total [baseline] (9.284 s) : 0, 9283979
Agent [candidate] (1.177 s) : 0, 1176527
Total [candidate] (9.309 s) : 0, 9309496
section iast_HARDCODED_SECRET_DISABLED
Agent [baseline] (1.179 s) : 0, 1178632
Total [baseline] (9.215 s) : 0, 9214877
Agent [candidate] (1.171 s) : 0, 1171226
Total [candidate] (9.207 s) : 0, 9207079
section iast_TELEMETRY_OFF
Agent [baseline] (1.165 s) : 0, 1165081
Total [baseline] (9.205 s) : 0, 9205079
Agent [candidate] (1.167 s) : 0, 1167191
Total [candidate] (9.229 s) : 0, 9228771
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.041 s -
Agent iast 1.178 s 137.934 ms (13.3%)
Agent iast_HARDCODED_SECRET_DISABLED 1.179 s 138.125 ms (13.3%)
Agent iast_TELEMETRY_OFF 1.165 s 124.574 ms (12.0%)
Total tracing 8.695 s -
Total iast 9.284 s 588.696 ms (6.8%)
Total iast_HARDCODED_SECRET_DISABLED 9.215 s 519.594 ms (6.0%)
Total iast_TELEMETRY_OFF 9.205 s 509.796 ms (5.9%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.043 s -
Agent iast 1.177 s 133.32 ms (12.8%)
Agent iast_HARDCODED_SECRET_DISABLED 1.171 s 128.019 ms (12.3%)
Agent iast_TELEMETRY_OFF 1.167 s 123.984 ms (11.9%)
Total tracing 8.699 s -
Total iast 9.309 s 610.443 ms (7.0%)
Total iast_HARDCODED_SECRET_DISABLED 9.207 s 508.025 ms (5.8%)
Total iast_TELEMETRY_OFF 9.229 s 529.718 ms (6.1%)
gantt
    title insecure-bank - break down per module: candidate=1.47.0-SNAPSHOT~153aaecf0f, baseline=1.47.0-SNAPSHOT~5a2c959566

    dateFormat X
    axisFormat %s
section tracing
BytebuddyAgent [baseline] (718.069 ms) : 0, 718069
BytebuddyAgent [candidate] (721.27 ms) : 0, 721270
GlobalTracer [baseline] (239.048 ms) : 0, 239048
GlobalTracer [candidate] (240.744 ms) : 0, 240744
AppSec [baseline] (55.669 ms) : 0, 55669
AppSec [candidate] (56.131 ms) : 0, 56131
Remote Config [baseline] (696.674 µs) : 0, 697
Remote Config [candidate] (710.223 µs) : 0, 710
Telemetry [baseline] (12.148 ms) : 0, 12148
Telemetry [candidate] (9.364 ms) : 0, 9364
section iast
BytebuddyAgent [baseline] (842.137 ms) : 0, 842137
BytebuddyAgent [candidate] (840.675 ms) : 0, 840675
GlobalTracer [baseline] (231.044 ms) : 0, 231044
GlobalTracer [candidate] (231.052 ms) : 0, 231052
AppSec [baseline] (57.608 ms) : 0, 57608
AppSec [candidate] (57.443 ms) : 0, 57443
Remote Config [baseline] (632.013 µs) : 0, 632
Remote Config [candidate] (628.971 µs) : 0, 629
Telemetry [baseline] (8.84 ms) : 0, 8840
Telemetry [candidate] (8.779 ms) : 0, 8779
IAST [baseline] (23.126 ms) : 0, 23126
IAST [candidate] (22.9 ms) : 0, 22900
section iast_HARDCODED_SECRET_DISABLED
BytebuddyAgent [baseline] (842.884 ms) : 0, 842884
BytebuddyAgent [candidate] (836.86 ms) : 0, 836860
GlobalTracer [baseline] (231.071 ms) : 0, 231071
GlobalTracer [candidate] (230.315 ms) : 0, 230315
AppSec [baseline] (57.133 ms) : 0, 57133
AppSec [candidate] (56.906 ms) : 0, 56906
Remote Config [baseline] (627.033 µs) : 0, 627
Remote Config [candidate] (608.083 µs) : 0, 608
Telemetry [baseline] (8.731 ms) : 0, 8731
Telemetry [candidate] (8.722 ms) : 0, 8722
IAST [baseline] (23.083 ms) : 0, 23083
IAST [candidate] (22.854 ms) : 0, 22854
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (832.213 ms) : 0, 832213
BytebuddyAgent [candidate] (833.436 ms) : 0, 833436
GlobalTracer [baseline] (229.181 ms) : 0, 229181
GlobalTracer [candidate] (230.091 ms) : 0, 230091
AppSec [baseline] (54.605 ms) : 0, 54605
AppSec [candidate] (55.589 ms) : 0, 55589
Remote Config [baseline] (616.982 µs) : 0, 617
Remote Config [candidate] (608.498 µs) : 0, 608
Telemetry [baseline] (8.735 ms) : 0, 8735
Telemetry [candidate] (8.627 ms) : 0, 8627
IAST [baseline] (24.798 ms) : 0, 24798
IAST [candidate] (23.828 ms) : 0, 23828
Loading
Startup time reports for petclinic
gantt
    title petclinic - global startup overhead: candidate=1.47.0-SNAPSHOT~153aaecf0f, baseline=1.47.0-SNAPSHOT~5a2c959566

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.037 s) : 0, 1036828
Total [baseline] (10.384 s) : 0, 10384238
Agent [candidate] (1.045 s) : 0, 1045053
Total [candidate] (10.451 s) : 0, 10450876
section appsec
Agent [baseline] (1.187 s) : 0, 1186616
Total [baseline] (10.784 s) : 0, 10784028
Agent [candidate] (1.183 s) : 0, 1182681
Total [candidate] (10.735 s) : 0, 10735049
section iast
Agent [baseline] (1.176 s) : 0, 1176396
Total [baseline] (11.075 s) : 0, 11075482
Agent [candidate] (1.171 s) : 0, 1170711
Total [candidate] (10.963 s) : 0, 10963146
section profiling
Agent [baseline] (1.259 s) : 0, 1258799
Total [baseline] (10.854 s) : 0, 10853785
Agent [candidate] (1.264 s) : 0, 1263647
Total [candidate] (10.884 s) : 0, 10883506
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.037 s -
Agent appsec 1.187 s 149.789 ms (14.4%)
Agent iast 1.176 s 139.568 ms (13.5%)
Agent profiling 1.259 s 221.972 ms (21.4%)
Total tracing 10.384 s -
Total appsec 10.784 s 399.79 ms (3.8%)
Total iast 11.075 s 691.243 ms (6.7%)
Total profiling 10.854 s 469.547 ms (4.5%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.045 s -
Agent appsec 1.183 s 137.628 ms (13.2%)
Agent iast 1.171 s 125.659 ms (12.0%)
Agent profiling 1.264 s 218.594 ms (20.9%)
Total tracing 10.451 s -
Total appsec 10.735 s 284.173 ms (2.7%)
Total iast 10.963 s 512.27 ms (4.9%)
Total profiling 10.884 s 432.63 ms (4.1%)
gantt
    title petclinic - break down per module: candidate=1.47.0-SNAPSHOT~153aaecf0f, baseline=1.47.0-SNAPSHOT~5a2c959566

    dateFormat X
    axisFormat %s
section tracing
BytebuddyAgent [baseline] (715.188 ms) : 0, 715188
BytebuddyAgent [candidate] (721.175 ms) : 0, 721175
GlobalTracer [baseline] (238.159 ms) : 0, 238159
GlobalTracer [candidate] (240.081 ms) : 0, 240081
AppSec [baseline] (55.578 ms) : 0, 55578
AppSec [candidate] (55.833 ms) : 0, 55833
Remote Config [baseline] (685.059 µs) : 0, 685
Remote Config [candidate] (702.454 µs) : 0, 702
Telemetry [baseline] (12.323 ms) : 0, 12323
Telemetry [candidate] (12.271 ms) : 0, 12271
section appsec
BytebuddyAgent [baseline] (737.495 ms) : 0, 737495
BytebuddyAgent [candidate] (735.338 ms) : 0, 735338
GlobalTracer [baseline] (237.094 ms) : 0, 237094
GlobalTracer [candidate] (235.868 ms) : 0, 235868
AppSec [baseline] (177.292 ms) : 0, 177292
AppSec [candidate] (176.951 ms) : 0, 176951
Remote Config [baseline] (659.782 µs) : 0, 660
Remote Config [candidate] (658.765 µs) : 0, 659
Telemetry [baseline] (8.343 ms) : 0, 8343
Telemetry [candidate] (8.271 ms) : 0, 8271
IAST [baseline] (21.556 ms) : 0, 21556
IAST [candidate] (21.418 ms) : 0, 21418
section iast
BytebuddyAgent [baseline] (840.576 ms) : 0, 840576
BytebuddyAgent [candidate] (836.105 ms) : 0, 836105
GlobalTracer [baseline] (230.895 ms) : 0, 230895
GlobalTracer [candidate] (230.183 ms) : 0, 230183
AppSec [baseline] (57.519 ms) : 0, 57519
AppSec [candidate] (57.303 ms) : 0, 57303
Remote Config [baseline] (617.944 µs) : 0, 618
Remote Config [candidate] (604.673 µs) : 0, 605
Telemetry [baseline] (8.754 ms) : 0, 8754
Telemetry [candidate] (8.7 ms) : 0, 8700
IAST [baseline] (23.031 ms) : 0, 23031
IAST [candidate] (22.843 ms) : 0, 22843
section profiling
ProfilingAgent [baseline] (96.522 ms) : 0, 96522
ProfilingAgent [candidate] (96.814 ms) : 0, 96814
BytebuddyAgent [baseline] (707.154 ms) : 0, 707154
BytebuddyAgent [candidate] (710.845 ms) : 0, 710845
GlobalTracer [baseline] (350.086 ms) : 0, 350086
GlobalTracer [candidate] (351.189 ms) : 0, 351189
AppSec [baseline] (55.208 ms) : 0, 55208
AppSec [candidate] (54.776 ms) : 0, 54776
Remote Config [baseline] (666.287 µs) : 0, 666
Remote Config [candidate] (677.796 µs) : 0, 678
Telemetry [baseline] (8.88 ms) : 0, 8880
Telemetry [candidate] (8.961 ms) : 0, 8961
Profiling [baseline] (96.545 ms) : 0, 96545
Profiling [candidate] (96.838 ms) : 0, 96838
Loading

Load

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
end_time 2025-02-26T09:33:26 2025-02-26T09:41:11
git_branch master smola/nonblocking-semaphore-internal-api
git_commit_date 1740507766 1740561704
git_commit_sha 5a2c959 153aaec
release_version 1.47.0-SNAPSHOT~5a2c959566 1.47.0-SNAPSHOT~153aaecf0f
start_time 2025-02-26T09:33:12 2025-02-26T09:40:57
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1740563270 1740563270
ci_job_id 823432363 823432363
ci_pipeline_id 57003857 57003857
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
kernel_version Linux runner-jnferfes-project-304-concurrent-0-qhfftp55 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:50:46 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux Linux runner-jnferfes-project-304-concurrent-0-qhfftp55 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:50:46 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
variant iast iast

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 13 metrics, 17 unstable metrics.

Request duration reports for petclinic
gantt
    title petclinic - request duration [CI 0.99] : candidate=1.47.0-SNAPSHOT~153aaecf0f, baseline=1.47.0-SNAPSHOT~5a2c959566
    dateFormat X
    axisFormat %s
section baseline
no_agent (1.364 ms) : 1343, 1385
.   : milestone, 1364,
appsec (1.748 ms) : 1725, 1772
.   : milestone, 1748,
appsec_no_iast (1.772 ms) : 1747, 1796
.   : milestone, 1772,
code_origins (1.703 ms) : 1670, 1735
.   : milestone, 1703,
iast (1.516 ms) : 1492, 1539
.   : milestone, 1516,
profiling (1.519 ms) : 1495, 1543
.   : milestone, 1519,
tracing (1.477 ms) : 1453, 1501
.   : milestone, 1477,
section candidate
no_agent (1.353 ms) : 1333, 1373
.   : milestone, 1353,
appsec (1.748 ms) : 1724, 1772
.   : milestone, 1748,
appsec_no_iast (1.773 ms) : 1750, 1796
.   : milestone, 1773,
code_origins (1.67 ms) : 1636, 1704
.   : milestone, 1670,
iast (1.531 ms) : 1508, 1555
.   : milestone, 1531,
profiling (1.506 ms) : 1482, 1530
.   : milestone, 1506,
tracing (1.466 ms) : 1441, 1491
.   : milestone, 1466,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 1.364 ms [1.343 ms, 1.385 ms] -
appsec 1.748 ms [1.725 ms, 1.772 ms] 384.461 µs (28.2%)
appsec_no_iast 1.772 ms [1.747 ms, 1.796 ms] 407.715 µs (29.9%)
code_origins 1.703 ms [1.67 ms, 1.735 ms] 338.582 µs (24.8%)
iast 1.516 ms [1.492 ms, 1.539 ms] 151.794 µs (11.1%)
profiling 1.519 ms [1.495 ms, 1.543 ms] 154.804 µs (11.3%)
tracing 1.477 ms [1.453 ms, 1.501 ms] 113.09 µs (8.3%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 1.353 ms [1.333 ms, 1.373 ms] -
appsec 1.748 ms [1.724 ms, 1.772 ms] 395.186 µs (29.2%)
appsec_no_iast 1.773 ms [1.75 ms, 1.796 ms] 419.936 µs (31.0%)
code_origins 1.67 ms [1.636 ms, 1.704 ms] 317.014 µs (23.4%)
iast 1.531 ms [1.508 ms, 1.555 ms] 178.389 µs (13.2%)
profiling 1.506 ms [1.482 ms, 1.53 ms] 152.874 µs (11.3%)
tracing 1.466 ms [1.441 ms, 1.491 ms] 112.721 µs (8.3%)
Request duration reports for insecure-bank
gantt
    title insecure-bank - request duration [CI 0.99] : candidate=1.47.0-SNAPSHOT~153aaecf0f, baseline=1.47.0-SNAPSHOT~5a2c959566
    dateFormat X
    axisFormat %s
section baseline
no_agent (383.863 µs) : 362, 406
.   : milestone, 384,
iast (513.249 µs) : 490, 536
.   : milestone, 513,
iast_FULL (732.181 µs) : 710, 754
.   : milestone, 732,
iast_GLOBAL (555.27 µs) : 534, 577
.   : milestone, 555,
iast_HARDCODED_SECRET_DISABLED (513.202 µs) : 491, 535
.   : milestone, 513,
iast_INACTIVE (465.278 µs) : 443, 488
.   : milestone, 465,
iast_TELEMETRY_OFF (497.52 µs) : 475, 520
.   : milestone, 498,
tracing (462.568 µs) : 441, 484
.   : milestone, 463,
section candidate
no_agent (381.979 µs) : 362, 402
.   : milestone, 382,
iast (509.537 µs) : 488, 531
.   : milestone, 510,
iast_FULL (729.095 µs) : 707, 751
.   : milestone, 729,
iast_GLOBAL (563.713 µs) : 541, 587
.   : milestone, 564,
iast_HARDCODED_SECRET_DISABLED (521.202 µs) : 498, 544
.   : milestone, 521,
iast_INACTIVE (466.372 µs) : 445, 488
.   : milestone, 466,
iast_TELEMETRY_OFF (505.665 µs) : 482, 529
.   : milestone, 506,
tracing (453.152 µs) : 433, 474
.   : milestone, 453,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 383.863 µs [362.011 µs, 405.715 µs] -
iast 513.249 µs [490.355 µs, 536.144 µs] 129.386 µs (33.7%)
iast_FULL 732.181 µs [710.073 µs, 754.289 µs] 348.318 µs (90.7%)
iast_GLOBAL 555.27 µs [533.555 µs, 576.986 µs] 171.407 µs (44.7%)
iast_HARDCODED_SECRET_DISABLED 513.202 µs [491.255 µs, 535.149 µs] 129.339 µs (33.7%)
iast_INACTIVE 465.278 µs [442.657 µs, 487.9 µs] 81.415 µs (21.2%)
iast_TELEMETRY_OFF 497.52 µs [474.991 µs, 520.05 µs] 113.657 µs (29.6%)
tracing 462.568 µs [440.649 µs, 484.487 µs] 78.705 µs (20.5%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 381.979 µs [362.011 µs, 401.947 µs] -
iast 509.537 µs [487.61 µs, 531.465 µs] 127.558 µs (33.4%)
iast_FULL 729.095 µs [707.08 µs, 751.111 µs] 347.116 µs (90.9%)
iast_GLOBAL 563.713 µs [540.844 µs, 586.583 µs] 181.734 µs (47.6%)
iast_HARDCODED_SECRET_DISABLED 521.202 µs [498.086 µs, 544.318 µs] 139.223 µs (36.4%)
iast_INACTIVE 466.372 µs [445.075 µs, 487.668 µs] 84.393 µs (22.1%)
iast_TELEMETRY_OFF 505.665 µs [482.413 µs, 528.918 µs] 123.686 µs (32.4%)
tracing 453.152 µs [432.746 µs, 473.559 µs] 71.173 µs (18.6%)

Dacapo

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master smola/nonblocking-semaphore-internal-api
git_commit_date 1740507766 1740561704
git_commit_sha 5a2c959 153aaec
release_version 1.47.0-SNAPSHOT~5a2c959566 1.47.0-SNAPSHOT~153aaecf0f
See matching parameters
Baseline Candidate
application biojava biojava
ci_job_date 1740563772 1740563772
ci_job_id 823432364 823432364
ci_pipeline_id 57003857 57003857
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
kernel_version Linux runner--f9ahtzi-project-304-concurrent-0-lllqhnvh 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:50:46 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux Linux runner--f9ahtzi-project-304-concurrent-0-lllqhnvh 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:50:46 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
variant appsec appsec

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 0 unstable metrics.

Execution time for tomcat
gantt
    title tomcat - execution time [CI 0.99] : candidate=1.47.0-SNAPSHOT~153aaecf0f, baseline=1.47.0-SNAPSHOT~5a2c959566
    dateFormat X
    axisFormat %s
section baseline
no_agent (1.468 ms) : 1456, 1479
.   : milestone, 1468,
appsec (2.358 ms) : 2314, 2401
.   : milestone, 2358,
iast (2.112 ms) : 2057, 2168
.   : milestone, 2112,
iast_GLOBAL (2.152 ms) : 2097, 2208
.   : milestone, 2152,
profiling (1.969 ms) : 1924, 2014
.   : milestone, 1969,
tracing (1.934 ms) : 1892, 1977
.   : milestone, 1934,
section candidate
no_agent (1.469 ms) : 1457, 1481
.   : milestone, 1469,
appsec (2.361 ms) : 2317, 2405
.   : milestone, 2361,
iast (2.111 ms) : 2056, 2167
.   : milestone, 2111,
iast_GLOBAL (2.152 ms) : 2096, 2208
.   : milestone, 2152,
profiling (1.963 ms) : 1920, 2007
.   : milestone, 1963,
tracing (1.941 ms) : 1898, 1983
.   : milestone, 1941,
Loading
  • baseline results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 1.468 ms [1.456 ms, 1.479 ms] -
appsec 2.358 ms [2.314 ms, 2.401 ms] 890.246 µs (60.7%)
iast 2.112 ms [2.057 ms, 2.168 ms] 644.633 µs (43.9%)
iast_GLOBAL 2.152 ms [2.097 ms, 2.208 ms] 684.718 µs (46.7%)
profiling 1.969 ms [1.924 ms, 2.014 ms] 501.391 µs (34.2%)
tracing 1.934 ms [1.892 ms, 1.977 ms] 466.61 µs (31.8%)
  • candidate results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 1.469 ms [1.457 ms, 1.481 ms] -
appsec 2.361 ms [2.317 ms, 2.405 ms] 892.204 µs (60.7%)
iast 2.111 ms [2.056 ms, 2.167 ms] 642.149 µs (43.7%)
iast_GLOBAL 2.152 ms [2.096 ms, 2.208 ms] 683.457 µs (46.5%)
profiling 1.963 ms [1.92 ms, 2.007 ms] 494.272 µs (33.6%)
tracing 1.941 ms [1.898 ms, 1.983 ms] 471.503 µs (32.1%)
Execution time for biojava
gantt
    title biojava - execution time [CI 0.99] : candidate=1.47.0-SNAPSHOT~153aaecf0f, baseline=1.47.0-SNAPSHOT~5a2c959566
    dateFormat X
    axisFormat %s
section baseline
no_agent (15.552 s) : 15552000, 15552000
.   : milestone, 15552000,
appsec (15.098 s) : 15098000, 15098000
.   : milestone, 15098000,
iast (19.142 s) : 19142000, 19142000
.   : milestone, 19142000,
iast_GLOBAL (18.068 s) : 18068000, 18068000
.   : milestone, 18068000,
profiling (14.884 s) : 14884000, 14884000
.   : milestone, 14884000,
tracing (14.811 s) : 14811000, 14811000
.   : milestone, 14811000,
section candidate
no_agent (14.796 s) : 14796000, 14796000
.   : milestone, 14796000,
appsec (15.148 s) : 15148000, 15148000
.   : milestone, 15148000,
iast (18.41 s) : 18410000, 18410000
.   : milestone, 18410000,
iast_GLOBAL (18.076 s) : 18076000, 18076000
.   : milestone, 18076000,
profiling (15.196 s) : 15196000, 15196000
.   : milestone, 15196000,
tracing (15.111 s) : 15111000, 15111000
.   : milestone, 15111000,
Loading
  • baseline results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 15.552 s [15.552 s, 15.552 s] -
appsec 15.098 s [15.098 s, 15.098 s] -454.0 ms (-2.9%)
iast 19.142 s [19.142 s, 19.142 s] 3.59 s (23.1%)
iast_GLOBAL 18.068 s [18.068 s, 18.068 s] 2.516 s (16.2%)
profiling 14.884 s [14.884 s, 14.884 s] -668.0 ms (-4.3%)
tracing 14.811 s [14.811 s, 14.811 s] -741.0 ms (-4.8%)
  • candidate results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 14.796 s [14.796 s, 14.796 s] -
appsec 15.148 s [15.148 s, 15.148 s] 352.0 ms (2.4%)
iast 18.41 s [18.41 s, 18.41 s] 3.614 s (24.4%)
iast_GLOBAL 18.076 s [18.076 s, 18.076 s] 3.28 s (22.2%)
profiling 15.196 s [15.196 s, 15.196 s] 400.0 ms (2.7%)
tracing 15.111 s [15.111 s, 15.111 s] 315.0 ms (2.1%)

Copy link
Contributor

@PerfectSlayer PerfectSlayer left a comment

Choose a reason for hiding this comment

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

My 2 cents feedback would be do have Javadoc about this implementation.
What’s different from the JDK Semaphore other than being non-blocking? What’s the difference with the tryAcquire() method?
It would help with people using it 🙏

@smola smola force-pushed the smola/nonblocking-semaphore-internal-api branch from 3e615a7 to 153aaec Compare February 26, 2025 09:22
@smola smola changed the title Move NonBlockingSemaphore to internal-api Extend NonBlockingSemaphore and make release for 1-permit case atomic Feb 26, 2025
@smola
Copy link
Member Author

smola commented Feb 26, 2025

@PerfectSlayer As discussed offline, this move just inertia as this is what we were using in IAST. For IAST, we have a reset methods that allows us to forcefully replenish the permits. So, I stepped back to check the full picture, and I realized we do not need this elsewhere, and so Semaphore is just fine for our use case. Also did some quick JMH benchmarks and it's not entirely clear what implementation would be best here, but there's probably not a significant difference (e.g. ours is faster single-threaded for 1 permit, std seems to be faster when there's contention). So I modified the PR to just keep the improvements and I'll leave it where it is.

@smola smola added comp: testing Testing comp: asm iast Application Security Management (IAST) labels Feb 26, 2025
@smola smola marked this pull request as ready for review February 26, 2025 09:57
@smola smola requested a review from a team as a code owner February 26, 2025 09:57
@smola smola merged commit af30cc1 into master Feb 27, 2025
219 checks passed
@smola smola deleted the smola/nonblocking-semaphore-internal-api branch February 27, 2025 11:49
@github-actions github-actions bot added this to the 1.47.0 milestone Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: asm iast Application Security Management (IAST) comp: testing Testing tag: no release notes Changes to exclude from release notes type: refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants