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

Introduce context helpers API #8134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

PerfectSlayer
Copy link
Contributor

@PerfectSlayer PerfectSlayer commented Dec 30, 2024

What Does This Do

This PR introduces few helper methods to help manipulate context and carrier collections.

Motivation

This should help with Context adoption and make its usage simpler while not enriching Context interface itself.

Additional Notes

The helper API comes from the Context API scratchpad discussions and are open to feedback.
The more we get, the best they will be.

Contributor Checklist

Jira ticket: LANGPLAT-39

@pr-commenter
Copy link

pr-commenter bot commented Dec 30, 2024

Benchmarks

Startup

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master bbujon/context-helper
git_commit_date 1735696685 1735809864
git_commit_sha e8df8a0 d1483fa
release_version 1.45.0-SNAPSHOT~e8df8a0d00 1.45.0-SNAPSHOT~d1483fa14b
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1735812231 1735812231
ci_job_id 752162954 752162954
ci_pipeline_id 51986718 51986718
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
module Agent Agent
parent None None
variant iast iast

Summary

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

Startup time reports for petclinic
gantt
    title petclinic - global startup overhead: candidate=1.45.0-SNAPSHOT~d1483fa14b, baseline=1.45.0-SNAPSHOT~e8df8a0d00

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.05 s) : 0, 1050457
Total [baseline] (10.414 s) : 0, 10414393
Agent [candidate] (1.06 s) : 0, 1059931
Total [candidate] (10.487 s) : 0, 10486700
section appsec
Agent [baseline] (1.187 s) : 0, 1187089
Total [baseline] (10.696 s) : 0, 10695577
Agent [candidate] (1.186 s) : 0, 1186263
Total [candidate] (10.724 s) : 0, 10724165
section iast
Agent [baseline] (1.188 s) : 0, 1187506
Total [baseline] (10.99 s) : 0, 10990294
Agent [candidate] (1.18 s) : 0, 1180358
Total [candidate] (10.992 s) : 0, 10992091
section profiling
Agent [baseline] (1.276 s) : 0, 1275836
Total [baseline] (10.897 s) : 0, 10897268
Agent [candidate] (1.285 s) : 0, 1284864
Total [candidate] (10.867 s) : 0, 10867390
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.05 s -
Agent appsec 1.187 s 136.632 ms (13.0%)
Agent iast 1.188 s 137.049 ms (13.0%)
Agent profiling 1.276 s 225.379 ms (21.5%)
Total tracing 10.414 s -
Total appsec 10.696 s 281.183 ms (2.7%)
Total iast 10.99 s 575.901 ms (5.5%)
Total profiling 10.897 s 482.875 ms (4.6%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.06 s -
Agent appsec 1.186 s 126.332 ms (11.9%)
Agent iast 1.18 s 120.427 ms (11.4%)
Agent profiling 1.285 s 224.933 ms (21.2%)
Total tracing 10.487 s -
Total appsec 10.724 s 237.466 ms (2.3%)
Total iast 10.992 s 505.392 ms (4.8%)
Total profiling 10.867 s 380.691 ms (3.6%)
gantt
    title petclinic - break down per module: candidate=1.45.0-SNAPSHOT~d1483fa14b, baseline=1.45.0-SNAPSHOT~e8df8a0d00

    dateFormat X
    axisFormat %s
section tracing
BytebuddyAgent [baseline] (712.647 ms) : 0, 712647
BytebuddyAgent [candidate] (718.044 ms) : 0, 718044
GlobalTracer [baseline] (256.352 ms) : 0, 256352
GlobalTracer [candidate] (258.855 ms) : 0, 258855
AppSec [baseline] (55.112 ms) : 0, 55112
AppSec [candidate] (55.589 ms) : 0, 55589
Remote Config [baseline] (718.521 µs) : 0, 719
Remote Config [candidate] (735.456 µs) : 0, 735
Telemetry [baseline] (10.613 ms) : 0, 10613
Telemetry [candidate] (11.488 ms) : 0, 11488
section appsec
BytebuddyAgent [baseline] (729.413 ms) : 0, 729413
BytebuddyAgent [candidate] (728.452 ms) : 0, 728452
GlobalTracer [baseline] (253.327 ms) : 0, 253327
GlobalTracer [candidate] (253.567 ms) : 0, 253567
AppSec [baseline] (170.912 ms) : 0, 170912
AppSec [candidate] (170.485 ms) : 0, 170485
Remote Config [baseline] (665.111 µs) : 0, 665
Remote Config [candidate] (657.559 µs) : 0, 658
Telemetry [baseline] (8.062 ms) : 0, 8062
Telemetry [candidate] (8.01 ms) : 0, 8010
IAST [baseline] (19.454 ms) : 0, 19454
IAST [candidate] (20.033 ms) : 0, 20033
section iast
BytebuddyAgent [baseline] (835.28 ms) : 0, 835280
BytebuddyAgent [candidate] (829.369 ms) : 0, 829369
GlobalTracer [baseline] (248.359 ms) : 0, 248359
GlobalTracer [candidate] (247.013 ms) : 0, 247013
AppSec [baseline] (58.086 ms) : 0, 58086
AppSec [candidate] (58.359 ms) : 0, 58359
Remote Config [baseline] (653.798 µs) : 0, 654
Remote Config [candidate] (672.719 µs) : 0, 673
Telemetry [baseline] (8.639 ms) : 0, 8639
Telemetry [candidate] (8.591 ms) : 0, 8591
IAST [baseline] (21.421 ms) : 0, 21421
IAST [candidate] (21.267 ms) : 0, 21267
section profiling
BytebuddyAgent [baseline] (702.913 ms) : 0, 702913
BytebuddyAgent [candidate] (707.453 ms) : 0, 707453
GlobalTracer [baseline] (372.332 ms) : 0, 372332
GlobalTracer [candidate] (376.509 ms) : 0, 376509
AppSec [baseline] (54.033 ms) : 0, 54033
AppSec [candidate] (53.968 ms) : 0, 53968
Remote Config [baseline] (689.623 µs) : 0, 690
Remote Config [candidate] (676.814 µs) : 0, 677
Telemetry [baseline] (7.958 ms) : 0, 7958
Telemetry [candidate] (7.805 ms) : 0, 7805
ProfilingAgent [baseline] (96.031 ms) : 0, 96031
ProfilingAgent [candidate] (96.315 ms) : 0, 96315
Profiling [baseline] (96.055 ms) : 0, 96055
Profiling [candidate] (96.339 ms) : 0, 96339
Loading
Startup time reports for insecure-bank
gantt
    title insecure-bank - global startup overhead: candidate=1.45.0-SNAPSHOT~d1483fa14b, baseline=1.45.0-SNAPSHOT~e8df8a0d00

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.052 s) : 0, 1051702
Total [baseline] (8.641 s) : 0, 8640906
Agent [candidate] (1.051 s) : 0, 1051260
Total [candidate] (8.604 s) : 0, 8603712
section iast
Agent [baseline] (1.178 s) : 0, 1177824
Total [baseline] (9.249 s) : 0, 9248770
Agent [candidate] (1.18 s) : 0, 1179800
Total [candidate] (9.2 s) : 0, 9199569
section iast_HARDCODED_SECRET_DISABLED
Agent [baseline] (1.187 s) : 0, 1186727
Total [baseline] (9.22 s) : 0, 9219904
Agent [candidate] (1.179 s) : 0, 1178530
Total [candidate] (9.19 s) : 0, 9189913
section iast_TELEMETRY_OFF
Agent [baseline] (1.18 s) : 0, 1179860
Total [baseline] (9.239 s) : 0, 9239067
Agent [candidate] (1.179 s) : 0, 1179143
Total [candidate] (9.248 s) : 0, 9248479
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.052 s -
Agent iast 1.178 s 126.123 ms (12.0%)
Agent iast_HARDCODED_SECRET_DISABLED 1.187 s 135.025 ms (12.8%)
Agent iast_TELEMETRY_OFF 1.18 s 128.158 ms (12.2%)
Total tracing 8.641 s -
Total iast 9.249 s 607.864 ms (7.0%)
Total iast_HARDCODED_SECRET_DISABLED 9.22 s 578.998 ms (6.7%)
Total iast_TELEMETRY_OFF 9.239 s 598.161 ms (6.9%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.051 s -
Agent iast 1.18 s 128.54 ms (12.2%)
Agent iast_HARDCODED_SECRET_DISABLED 1.179 s 127.27 ms (12.1%)
Agent iast_TELEMETRY_OFF 1.179 s 127.883 ms (12.2%)
Total tracing 8.604 s -
Total iast 9.2 s 595.857 ms (6.9%)
Total iast_HARDCODED_SECRET_DISABLED 9.19 s 586.201 ms (6.8%)
Total iast_TELEMETRY_OFF 9.248 s 644.767 ms (7.5%)
gantt
    title insecure-bank - break down per module: candidate=1.45.0-SNAPSHOT~d1483fa14b, baseline=1.45.0-SNAPSHOT~e8df8a0d00

    dateFormat X
    axisFormat %s
section tracing
BytebuddyAgent [baseline] (711.929 ms) : 0, 711929
BytebuddyAgent [candidate] (712.207 ms) : 0, 712207
GlobalTracer [baseline] (256.29 ms) : 0, 256290
GlobalTracer [candidate] (256.794 ms) : 0, 256794
AppSec [baseline] (55.07 ms) : 0, 55070
AppSec [candidate] (55.215 ms) : 0, 55215
Remote Config [baseline] (710.684 µs) : 0, 711
Remote Config [candidate] (720.76 µs) : 0, 721
Telemetry [baseline] (12.686 ms) : 0, 12686
Telemetry [candidate] (11.288 ms) : 0, 11288
section iast
BytebuddyAgent [baseline] (828.054 ms) : 0, 828054
BytebuddyAgent [candidate] (828.843 ms) : 0, 828843
GlobalTracer [baseline] (246.275 ms) : 0, 246275
GlobalTracer [candidate] (246.956 ms) : 0, 246956
AppSec [baseline] (57.713 ms) : 0, 57713
AppSec [candidate] (58.261 ms) : 0, 58261
IAST [baseline] (21.624 ms) : 0, 21624
IAST [candidate] (21.443 ms) : 0, 21443
Remote Config [baseline] (682.889 µs) : 0, 683
Remote Config [candidate] (660.708 µs) : 0, 661
Telemetry [baseline] (8.572 ms) : 0, 8572
Telemetry [candidate] (8.509 ms) : 0, 8509
section iast_HARDCODED_SECRET_DISABLED
BytebuddyAgent [baseline] (834.269 ms) : 0, 834269
BytebuddyAgent [candidate] (827.23 ms) : 0, 827230
GlobalTracer [baseline] (247.793 ms) : 0, 247793
GlobalTracer [candidate] (247.186 ms) : 0, 247186
AppSec [baseline] (58.669 ms) : 0, 58669
AppSec [candidate] (58.319 ms) : 0, 58319
IAST [baseline] (21.626 ms) : 0, 21626
IAST [candidate] (21.601 ms) : 0, 21601
Remote Config [baseline] (668.025 µs) : 0, 668
Remote Config [candidate] (658.55 µs) : 0, 659
Telemetry [baseline] (8.622 ms) : 0, 8622
Telemetry [candidate] (8.501 ms) : 0, 8501
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (827.775 ms) : 0, 827775
BytebuddyAgent [candidate] (829.075 ms) : 0, 829075
GlobalTracer [baseline] (248.089 ms) : 0, 248089
GlobalTracer [candidate] (247.523 ms) : 0, 247523
AppSec [baseline] (58.562 ms) : 0, 58562
AppSec [candidate] (57.578 ms) : 0, 57578
IAST [baseline] (21.262 ms) : 0, 21262
IAST [candidate] (20.823 ms) : 0, 20823
Remote Config [baseline] (680.4 µs) : 0, 680
Remote Config [candidate] (642.824 µs) : 0, 643
Telemetry [baseline] (8.559 ms) : 0, 8559
Telemetry [candidate] (8.342 ms) : 0, 8342
Loading

Load

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
end_time 2025-01-02T09:36:22 2025-01-02T09:43:21
git_branch master bbujon/context-helper
git_commit_date 1735696685 1735809864
git_commit_sha e8df8a0 d1483fa
release_version 1.45.0-SNAPSHOT~e8df8a0d00 1.45.0-SNAPSHOT~d1483fa14b
start_time 2025-01-02T09:36:08 2025-01-02T09:43:08
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1735811355 1735811355
ci_job_id 752162958 752162958
ci_pipeline_id 51986718 51986718
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
variant iast iast

Summary

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

Request duration reports for insecure-bank
gantt
    title insecure-bank - request duration [CI 0.99] : candidate=1.45.0-SNAPSHOT~d1483fa14b, baseline=1.45.0-SNAPSHOT~e8df8a0d00
    dateFormat X
    axisFormat %s
section baseline
no_agent (380.021 µs) : 360, 400
.   : milestone, 380,
iast (490.555 µs) : 469, 512
.   : milestone, 491,
iast_FULL (649.814 µs) : 628, 671
.   : milestone, 650,
iast_GLOBAL (524.961 µs) : 503, 547
.   : milestone, 525,
iast_HARDCODED_SECRET_DISABLED (489.421 µs) : 468, 511
.   : milestone, 489,
iast_INACTIVE (453.204 µs) : 432, 475
.   : milestone, 453,
iast_TELEMETRY_OFF (482.971 µs) : 461, 505
.   : milestone, 483,
tracing (443.44 µs) : 423, 464
.   : milestone, 443,
section candidate
no_agent (376.63 µs) : 357, 396
.   : milestone, 377,
iast (494.069 µs) : 473, 516
.   : milestone, 494,
iast_FULL (655.015 µs) : 633, 677
.   : milestone, 655,
iast_GLOBAL (522.045 µs) : 500, 544
.   : milestone, 522,
iast_HARDCODED_SECRET_DISABLED (492.276 µs) : 471, 514
.   : milestone, 492,
iast_INACTIVE (464.03 µs) : 442, 486
.   : milestone, 464,
iast_TELEMETRY_OFF (485.851 µs) : 463, 508
.   : milestone, 486,
tracing (446.362 µs) : 426, 467
.   : milestone, 446,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 380.021 µs [359.774 µs, 400.268 µs] -
iast 490.555 µs [469.03 µs, 512.079 µs] 110.533 µs (29.1%)
iast_FULL 649.814 µs [628.219 µs, 671.41 µs] 269.793 µs (71.0%)
iast_GLOBAL 524.961 µs [502.568 µs, 547.354 µs] 144.94 µs (38.1%)
iast_HARDCODED_SECRET_DISABLED 489.421 µs [467.942 µs, 510.899 µs] 109.399 µs (28.8%)
iast_INACTIVE 453.204 µs [431.666 µs, 474.742 µs] 73.183 µs (19.3%)
iast_TELEMETRY_OFF 482.971 µs [460.729 µs, 505.212 µs] 102.949 µs (27.1%)
tracing 443.44 µs [423.012 µs, 463.869 µs] 63.419 µs (16.7%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 376.63 µs [357.11 µs, 396.15 µs] -
iast 494.069 µs [472.504 µs, 515.634 µs] 117.439 µs (31.2%)
iast_FULL 655.015 µs [633.495 µs, 676.535 µs] 278.385 µs (73.9%)
iast_GLOBAL 522.045 µs [499.882 µs, 544.209 µs] 145.415 µs (38.6%)
iast_HARDCODED_SECRET_DISABLED 492.276 µs [470.797 µs, 513.755 µs] 115.646 µs (30.7%)
iast_INACTIVE 464.03 µs [442.405 µs, 485.655 µs] 87.4 µs (23.2%)
iast_TELEMETRY_OFF 485.851 µs [463.291 µs, 508.412 µs] 109.221 µs (29.0%)
tracing 446.362 µs [425.846 µs, 466.877 µs] 69.732 µs (18.5%)
Request duration reports for petclinic
gantt
    title petclinic - request duration [CI 0.99] : candidate=1.45.0-SNAPSHOT~d1483fa14b, baseline=1.45.0-SNAPSHOT~e8df8a0d00
    dateFormat X
    axisFormat %s
section baseline
no_agent (1.358 ms) : 1339, 1378
.   : milestone, 1358,
appsec (1.754 ms) : 1731, 1778
.   : milestone, 1754,
appsec_no_iast (1.753 ms) : 1728, 1779
.   : milestone, 1753,
iast (1.514 ms) : 1491, 1537
.   : milestone, 1514,
profiling (1.565 ms) : 1541, 1589
.   : milestone, 1565,
tracing (1.495 ms) : 1470, 1519
.   : milestone, 1495,
section candidate
no_agent (1.36 ms) : 1340, 1380
.   : milestone, 1360,
appsec (1.769 ms) : 1746, 1793
.   : milestone, 1769,
appsec_no_iast (1.754 ms) : 1729, 1778
.   : milestone, 1754,
iast (1.502 ms) : 1479, 1526
.   : milestone, 1502,
profiling (1.548 ms) : 1522, 1573
.   : milestone, 1548,
tracing (1.473 ms) : 1448, 1498
.   : milestone, 1473,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 1.358 ms [1.339 ms, 1.378 ms] -
appsec 1.754 ms [1.731 ms, 1.778 ms] 395.95 µs (29.1%)
appsec_no_iast 1.753 ms [1.728 ms, 1.779 ms] 394.939 µs (29.1%)
iast 1.514 ms [1.491 ms, 1.537 ms] 155.896 µs (11.5%)
profiling 1.565 ms [1.541 ms, 1.589 ms] 206.446 µs (15.2%)
tracing 1.495 ms [1.47 ms, 1.519 ms] 136.172 µs (10.0%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 1.36 ms [1.34 ms, 1.38 ms] -
appsec 1.769 ms [1.746 ms, 1.793 ms] 409.052 µs (30.1%)
appsec_no_iast 1.754 ms [1.729 ms, 1.778 ms] 393.623 µs (28.9%)
iast 1.502 ms [1.479 ms, 1.526 ms] 142.193 µs (10.5%)
profiling 1.548 ms [1.522 ms, 1.573 ms] 187.329 µs (13.8%)
tracing 1.473 ms [1.448 ms, 1.498 ms] 112.39 µs (8.3%)

Dacapo

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master bbujon/context-helper
git_commit_date 1735696685 1735809864
git_commit_sha e8df8a0 d1483fa
release_version 1.45.0-SNAPSHOT~e8df8a0d00 1.45.0-SNAPSHOT~d1483fa14b
See matching parameters
Baseline Candidate
application biojava biojava
ci_job_date 1735811805 1735811805
ci_job_id 752162962 752162962
ci_pipeline_id 51986718 51986718
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
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 biojava
gantt
    title biojava - execution time [CI 0.99] : candidate=1.45.0-SNAPSHOT~d1483fa14b, baseline=1.45.0-SNAPSHOT~e8df8a0d00
    dateFormat X
    axisFormat %s
section baseline
no_agent (14.904 s) : 14904000, 14904000
.   : milestone, 14904000,
appsec (15.208 s) : 15208000, 15208000
.   : milestone, 15208000,
iast (18.835 s) : 18835000, 18835000
.   : milestone, 18835000,
iast_GLOBAL (17.758 s) : 17758000, 17758000
.   : milestone, 17758000,
profiling (14.915 s) : 14915000, 14915000
.   : milestone, 14915000,
tracing (14.866 s) : 14866000, 14866000
.   : milestone, 14866000,
section candidate
no_agent (14.901 s) : 14901000, 14901000
.   : milestone, 14901000,
appsec (15.012 s) : 15012000, 15012000
.   : milestone, 15012000,
iast (18.458 s) : 18458000, 18458000
.   : milestone, 18458000,
iast_GLOBAL (18.076 s) : 18076000, 18076000
.   : milestone, 18076000,
profiling (14.991 s) : 14991000, 14991000
.   : milestone, 14991000,
tracing (14.985 s) : 14985000, 14985000
.   : milestone, 14985000,
Loading
  • baseline results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 14.904 s [14.904 s, 14.904 s] -
appsec 15.208 s [15.208 s, 15.208 s] 304.0 ms (2.0%)
iast 18.835 s [18.835 s, 18.835 s] 3.931 s (26.4%)
iast_GLOBAL 17.758 s [17.758 s, 17.758 s] 2.854 s (19.1%)
profiling 14.915 s [14.915 s, 14.915 s] 11.0 ms (0.1%)
tracing 14.866 s [14.866 s, 14.866 s] -38.0 ms (-0.3%)
  • candidate results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 14.901 s [14.901 s, 14.901 s] -
appsec 15.012 s [15.012 s, 15.012 s] 111.0 ms (0.7%)
iast 18.458 s [18.458 s, 18.458 s] 3.557 s (23.9%)
iast_GLOBAL 18.076 s [18.076 s, 18.076 s] 3.175 s (21.3%)
profiling 14.991 s [14.991 s, 14.991 s] 90.0 ms (0.6%)
tracing 14.985 s [14.985 s, 14.985 s] 84.0 ms (0.6%)
Execution time for tomcat
gantt
    title tomcat - execution time [CI 0.99] : candidate=1.45.0-SNAPSHOT~d1483fa14b, baseline=1.45.0-SNAPSHOT~e8df8a0d00
    dateFormat X
    axisFormat %s
section baseline
no_agent (1.465 ms) : 1454, 1476
.   : milestone, 1465,
appsec (2.344 ms) : 2302, 2386
.   : milestone, 2344,
iast (2.082 ms) : 2029, 2135
.   : milestone, 2082,
iast_GLOBAL (2.129 ms) : 2076, 2183
.   : milestone, 2129,
profiling (1.973 ms) : 1930, 2017
.   : milestone, 1973,
tracing (1.939 ms) : 1898, 1980
.   : milestone, 1939,
section candidate
no_agent (1.467 ms) : 1455, 1478
.   : milestone, 1467,
appsec (2.346 ms) : 2304, 2387
.   : milestone, 2346,
iast (2.082 ms) : 2029, 2135
.   : milestone, 2082,
iast_GLOBAL (2.129 ms) : 2076, 2182
.   : milestone, 2129,
profiling (1.975 ms) : 1932, 2018
.   : milestone, 1975,
tracing (1.929 ms) : 1888, 1969
.   : milestone, 1929,
Loading
  • baseline results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 1.465 ms [1.454 ms, 1.476 ms] -
appsec 2.344 ms [2.302 ms, 2.386 ms] 878.988 µs (60.0%)
iast 2.082 ms [2.029 ms, 2.135 ms] 617.421 µs (42.1%)
iast_GLOBAL 2.129 ms [2.076 ms, 2.183 ms] 664.229 µs (45.3%)
profiling 1.973 ms [1.93 ms, 2.017 ms] 508.254 µs (34.7%)
tracing 1.939 ms [1.898 ms, 1.98 ms] 473.711 µs (32.3%)
  • candidate results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 1.467 ms [1.455 ms, 1.478 ms] -
appsec 2.346 ms [2.304 ms, 2.387 ms] 879.071 µs (59.9%)
iast 2.082 ms [2.029 ms, 2.135 ms] 615.728 µs (42.0%)
iast_GLOBAL 2.129 ms [2.076 ms, 2.182 ms] 662.474 µs (45.2%)
profiling 1.975 ms [1.932 ms, 2.018 ms] 508.417 µs (34.7%)
tracing 1.929 ms [1.888 ms, 1.969 ms] 462.145 µs (31.5%)

if (store[nextSingleton.index] == null) {
store[nextSingleton.index] = nextSingleton.value;
}
return new IndexedContext(store);
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor improvement: we can save an array allocation if we check whether we have a value for the index first:

      SingletonContext nextSingleton = (SingletonContext) next;
      if (nextSingleton.index < currentIndexed.store.length && currentIndexed.store[nextSingleton.index] != null) {
        return current;
      }
      Object[] store =
          copyOfRange(
              currentIndexed.store, 0, max(currentIndexed.store.length, nextSingleton.index + 1));
      store[nextSingleton.index] = nextSingleton.value;
      return new IndexedContext(store);

store[i] = nextValue;
}
}
return new IndexedContext(store);
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise here we could iterate over nextIndexed and only create a new store if either nextIndexed.store has more elements or it has a non-null element that is null in the currentIndexed.store. It should be possible to do this in a single pass.

Copy link
Contributor Author

@PerfectSlayer PerfectSlayer Jan 2, 2025

Choose a reason for hiding this comment

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

Thanks for the feedback. The original implementation used to support every merge possible between all three implementations (so 9 different cases) and I did not dare doing too many optimizations as it was a nightmare to get them fully covered by test.

As I simplified the overall merge by using a 0-length IndexedContext as original input, I end up with only 3 merges to support, and they are now worth optimization. Thanks for catching it! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants