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

perf: write utf8 bytes directly into destination. #128

Merged

Conversation

RokasBalevicius
Copy link
Contributor

@RokasBalevicius RokasBalevicius commented Jun 28, 2024

Change:
Encoding.UTF8.GetBytes allows writing bytes into the destination with offset directly, where is no need for intermediary buffer allocation and extra copy operation.

Performance benchmarks:

BenchmarkDotNet v0.13.12, macOS Sonoma 14.4.1 (23E224) [Darwin 23.4.0]
Intel Core i7-1068NG7 CPU 2.30GHz, 1 CPU, 8 logical and 4 physical cores
.NET SDK 8.0.100
  [Host]     : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
  DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2


| Method | Mean      | Error     | StdDev    | Gen0   | Allocated |
|------- |----------:|----------:|----------:|-------:|----------:|
| OldWay | 21.933 ns | 0.4508 ns | 0.7406 ns | 0.0076 |      32 B |
| NewWay |  8.698 ns | 0.0364 ns | 0.0304 ns |      - |         - |

Value used for testing -> "test1"

@shannonklaus
Copy link
Collaborator

Thank you for your pull request. It will be included in my next release, which is happening by the end of the week.

@shannonklaus shannonklaus changed the base branch from master to stage July 25, 2024 15:23
@shannonklaus shannonklaus merged commit 35b1d6c into aerospike:stage Jul 25, 2024
4 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.

2 participants