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

Optimize interning #53

Merged
merged 4 commits into from
Jun 5, 2024
Merged

Optimize interning #53

merged 4 commits into from
Jun 5, 2024

Conversation

Hartigan
Copy link
Contributor

@Hartigan Hartigan commented Mar 16, 2024

Trying to reduce allocations and copies

Copy link

codecov bot commented Mar 16, 2024

Codecov Report

Attention: Patch coverage is 88.49765% with 49 lines in your changes missing coverage. Please review.

Project coverage is 54.7%. Comparing base (56a6f45) to head (0eb899b).
Report is 11 commits behind head on main.

Current head 0eb899b differs from pull request most recent head a108a2d

Please upload reports for the commit a108a2d to get more accurate results.

Files Patch % Lines
opentelemetry-datadog/src/exporter/intern.rs 88.2% 43 Missing ⚠️
opentelemetry-datadog/src/exporter/mod.rs 77.7% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main     #53     +/-   ##
=======================================
+ Coverage   52.3%   54.7%   +2.4%     
=======================================
  Files         38      38             
  Lines       4967    5339    +372     
=======================================
+ Hits        2598    2923    +325     
- Misses      2369    2416     +47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@TommyCpp TommyCpp left a comment

Choose a reason for hiding this comment

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

Just a suggestion I'd recommend include a benchmark to demostrate the performance improvement

@Hartigan
Copy link
Contributor Author

@TommyCpp I introduced benchmark in separate pull request

@Hartigan
Copy link
Contributor Author

Setup:
Hardware: Dell Latitude 7390, Intel Core i5-8250U, 16gb with power delivery
Configuration: Disabled Intel Turbo Boost and Hyper Threading
OS: Manjaro linux with latest updates(21.03.2024) and kernel 6.6.19-1
Rust: rustc 1.77.0 (aedd173a2 2024-03-17)

Output of lscpu:

Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         39 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  4
  On-line CPU(s) list:   0-3
Vendor ID:               GenuineIntel
  Model name:            Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
    CPU family:          6
    Model:               142
    Thread(s) per core:  1
    Core(s) per socket:  4
    Socket(s):           1
    Stepping:            10
    CPU(s) scaling MHz:  52%
    CPU max MHz:         1600.0000
    CPU min MHz:         400.0000
    BogoMIPS:            3601.00
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts
                         rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer
                          aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid m
                         px rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm arat pln pts hwp hwp_notify hwp_act_window hwp_epp vnmi md_clear flush_l1d arch_capabilities
Virtualization features:
  Virtualization:        VT-x
Caches (sum of all):
  L1d:                   128 KiB (4 instances)
  L1i:                   128 KiB (4 instances)
  L2:                    1 MiB (4 instances)
  L3:                    6 MiB (1 instance)
NUMA:
  NUMA node(s):          1
  NUMA node0 CPU(s):     0-3
Vulnerabilities:
  Gather data sampling:  Mitigation; Microcode
  Itlb multihit:         KVM: Mitigation: VMX disabled
  L1tf:                  Mitigation; PTE Inversion; VMX conditional cache flushes, SMT disabled
  Mds:                   Mitigation; Clear CPU buffers; SMT disabled
  Meltdown:              Mitigation; PTI
  Mmio stale data:       Mitigation; Clear CPU buffers; SMT disabled
  Retbleed:              Mitigation; IBRS
  Spec rstack overflow:  Not affected
  Spec store bypass:     Mitigation; Speculative Store Bypass disabled via prctl
  Spectre v1:            Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:            Mitigation; IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS Not affected
  Srbds:                 Mitigation; Microcode
  Tsx async abort:       Not affected

Results of main branch:

export 128 traces with 4 spans
                        time:   [6.6217 ms 6.6268 ms 6.6330 ms]
Found 8 outliers among 100 measurements (8.00%)
  6 (6.00%) high mild
  2 (2.00%) high severe

export 256 traces with 4 spans
                        time:   [13.562 ms 13.587 ms 13.614 ms]
Found 16 outliers among 100 measurements (16.00%)
  7 (7.00%) high mild
  9 (9.00%) high severe

export 512 traces with 4 spans
                        time:   [28.069 ms 28.102 ms 28.141 ms]
Found 5 outliers among 100 measurements (5.00%)
  3 (3.00%) high mild
  2 (2.00%) high severe

export 512 traces with 2 spans
                        time:   [13.853 ms 13.900 ms 13.957 ms]
Found 15 outliers among 100 measurements (15.00%)
  5 (5.00%) high mild
  10 (10.00%) high severe

export 512 traces with 1 spans
                        time:   [6.9199 ms 6.9277 ms 6.9375 ms]
Found 8 outliers among 100 measurements (8.00%)
  4 (4.00%) high mild
  4 (4.00%) high severe

Results of pull request:

export 128 traces with 4 spans
                        time:   [3.9107 ms 3.9230 ms 3.9381 ms]
Found 21 outliers among 100 measurements (21.00%)
  1 (1.00%) high mild
  20 (20.00%) high severe

export 256 traces with 4 spans
                        time:   [8.2452 ms 8.2609 ms 8.2786 ms]
Found 16 outliers among 100 measurements (16.00%)
  2 (2.00%) high mild
  14 (14.00%) high severe

export 512 traces with 4 spans
                        time:   [18.049 ms 18.117 ms 18.198 ms]
Found 18 outliers among 100 measurements (18.00%)
  3 (3.00%) high mild
  15 (15.00%) high severe

export 512 traces with 2 spans
                        time:   [8.3135 ms 8.3241 ms 8.3370 ms]
Found 10 outliers among 100 measurements (10.00%)
  6 (6.00%) high mild
  4 (4.00%) high severe

export 512 traces with 1 spans
                        time:   [4.0655 ms 4.0826 ms 4.1021 ms]
Found 18 outliers among 100 measurements (18.00%)
  4 (4.00%) high mild
  14 (14.00%) high severe

@Hartigan Hartigan marked this pull request as ready for review March 22, 2024 14:35
@Hartigan Hartigan requested a review from a team March 22, 2024 14:35
@cijothomas
Copy link
Member

@Hartigan could you resolve the CI failures?

@Hartigan
Copy link
Contributor Author

@cijothomas Looks like it's broken in main branch. Should I create separate pull request for fixes in main?

error[E0308]: `?` operator has incompatible types
   --> opentelemetry-stackdriver/src/lib.rs:417:28
    |
417 |             authenticator: authenticator.build().await?,
    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `HttpsConnector<HttpConnector>`, found a different `HttpsConnector<HttpConnector>`
    |
    = note: `?` operator cannot convert from `Authenticator<yup_oauth2::hyper_rustls::HttpsConnector<HttpConnector>>` to `Authenticator<hyper_rustls::HttpsConnector<HttpConnector>>`
    = note: `HttpsConnector<HttpConnector>` and `HttpsConnector<HttpConnector>` have similar names, but are actually distinct types
note: `HttpsConnector<HttpConnector>` is defined in crate `hyper_rustls`
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hyper-rustls-0.25.0/src/connector.rs:22:1
    |
22  | pub struct HttpsConnector<T> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `HttpsConnector<HttpConnector>` is defined in crate `hyper_rustls`
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hyper-rustls-0.24.2/src/connector.rs:19:1
    |
19  | pub struct HttpsConnector<T> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `hyper_rustls` are being used?

@cijothomas
Copy link
Member

@cijothomas Looks like it's broken in main branch. Should I create separate pull request for fixes in main?

error[E0308]: `?` operator has incompatible types
   --> opentelemetry-stackdriver/src/lib.rs:417:28
    |
417 |             authenticator: authenticator.build().await?,
    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `HttpsConnector<HttpConnector>`, found a different `HttpsConnector<HttpConnector>`
    |
    = note: `?` operator cannot convert from `Authenticator<yup_oauth2::hyper_rustls::HttpsConnector<HttpConnector>>` to `Authenticator<hyper_rustls::HttpsConnector<HttpConnector>>`
    = note: `HttpsConnector<HttpConnector>` and `HttpsConnector<HttpConnector>` have similar names, but are actually distinct types
note: `HttpsConnector<HttpConnector>` is defined in crate `hyper_rustls`
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hyper-rustls-0.25.0/src/connector.rs:22:1
    |
22  | pub struct HttpsConnector<T> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `HttpsConnector<HttpConnector>` is defined in crate `hyper_rustls`
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hyper-rustls-0.24.2/src/connector.rs:19:1
    |
19  | pub struct HttpsConnector<T> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `hyper_rustls` are being used?

Oops! Sorry, looks like main is broken #57 (comment)

pub(crate) struct StringInterner {
data: IndexSet<String>,
#[cfg(any(
feature = "intern-ahash",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: A OR (A AND B)
Let's reduce complexity here.

@Hartigan
Copy link
Contributor Author

Hartigan commented Apr 5, 2024

tests in main broken:

failures:

---- generated_code_is_fresh stdout ----
cargo:rerun-if-changed=google/devtools/cloudtrace/v2/tracing.proto
cargo:rerun-if-changed=google/devtools/cloudtrace/v2/trace.proto
cargo:rerun-if-changed=google/logging/type/http_request.proto
cargo:rerun-if-changed=google/logging/v2/log_entry.proto
cargo:rerun-if-changed=google/logging/v2/logging.proto
cargo:rerun-if-changed=google/rpc/status.proto
cargo:rerun-if-changed=proto
thread 'generated_code_is_fresh' panicked at opentelemetry-stackdriver/tests/generate.rs:231:41:
called `Result::unwrap()` on an `Err` value: Os { code: 18, kind: CrossesDevices, message: "Invalid cross-device link" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    generated_code_is_fresh

test result: FAILED. 0 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out; finished in 1.82s

@hdost
Copy link
Contributor

hdost commented Apr 6, 2024

@cijothomas these tests are unaltered to this PR i don't see a blocker here.

@cijothomas cijothomas closed this Apr 9, 2024
@cijothomas cijothomas reopened this Apr 9, 2024
@cijothomas
Copy link
Member

@cijothomas these tests are unaltered to this PR i don't see a blocker here.

Yes I didn't mean to block this PR! But is main itself broken?

@Hartigan
Copy link
Contributor Author

@cijothomas I think, main broken because of some of dependencies was updated without backward compatibility. And usually rust libs don't contains Cargo.lock file(only executables contain it).

@lalitb
Copy link
Member

lalitb commented Jun 5, 2024

@Hartigan Seems this was somehow missed, and is still good to go. Can you please resolve the conflicts?

@Hartigan
Copy link
Contributor Author

Hartigan commented Jun 5, 2024

@lalitb I'll be without a computer for a few more weeks. I gave access to @mstyura, he will resolve conflicts

@mstyura
Copy link
Contributor

mstyura commented Jun 5, 2024

Hello @lalitb. I've rebased 3 commits of @Hartigan on top of latest main branch. There was one conflict in Cargo.toml due to both main and intern branches introduced new crate features. Locally code compiles, tests run without errors.

@cijothomas
Copy link
Member

@mstyura Can you fix the lint issues that is causing CI to red?

Copy link

linux-foundation-easycla bot commented Jun 5, 2024

CLA Signed


The committers listed above are authorized under a signed CLA.

@mstyura
Copy link
Contributor

mstyura commented Jun 5, 2024

@mstyura Can you fix the lint issues that is causing CI to red?

@cijothomas could you please approve new CI run?

@mstyura
Copy link
Contributor

mstyura commented Jun 5, 2024

CI failure is now unrelated to code itself and fails due to rate limiting of GitHub API:

==> Running command '/home/runner/work/_actions/codecov/codecov-action/v4/dist/codecov create-commit'
/home/runner/work/_actions/codecov/codecov-action/v4/dist/codecov create-commit --git-service github -C a108a2dd5a8af6954ae5e9281994127c11f22dec -Z
info - 2024-06-05 16:41:22,375 -- ci service found: github-actions
info - 2024-06-05 16:41:22,714 -- The PR is happening in a forked repo. Using tokenless upload.
info - 2024-06-05 16:41:23,263 -- Process Commit creating complete
error - 2024-06-05 16:41:23,264 -- Commit creating failed: {"detail":"Tokenless has reached GitHub rate limit. Please upload using a token: https://docs.codecov.com/docs/adding-the-codecov-token. Expected available in 661 seconds."}
Error: Codecov: Failed to properly create commit: The process '/home/runner/work/_actions/codecov/codecov-action/v4/dist/codecov' failed with exit code 1

@cijothomas cijothomas merged commit 6245c63 into open-telemetry:main Jun 5, 2024
6 of 7 checks passed
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.

6 participants