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

Use String.split() instead of NSString.components() #287

Merged
merged 2 commits into from
Jan 29, 2019

Conversation

ianpartridge
Copy link
Collaborator

Description

Remove the usage of NSString.components() and replace it with String.split().

Motivation and Context

In Swift 5, bridging from String to NSString involves a conversion from UTF-8 to UTF-16. So we want to avoid NSString as much as possible.

How Has This Been Tested?

Ran Kitura-net test suite.

@djones6
Copy link
Contributor

djones6 commented Jan 24, 2019

Performance evaluation on Ubuntu 16.04 with a simple query params echo benchmark:

               | Throughput (req/s)      | CPU (%) | Mem (kb)     | Latency (ms)                   | good
Implementation | Average    | Max        | Average | Avg peak RSS | Average  | 99%      | Max      | iters
---------------|------------|------------|---------|--------------|----------|----------|----------|-------
      base_421 |    30848.1 |    31443.5 |    98.2 |        25354 |      4.1 |      4.8 |    201.6 |    10
     split_421 |    31812.4 |    32536.3 |    98.5 |        25715 |      4.0 |      4.8 |    202.6 |    10
       base_50 |    29572.5 |    30033.1 |    98.7 |        26017 |      4.3 |      5.0 |    204.3 |    10
      split_50 |    30675.2 |    31403.9 |    98.3 |        26116 |      4.1 |      4.8 |     50.2 |    10

There's a ~3% improvement to the overall performance with this change. Swift 5 came out behind in this workload however, which implies there may be other NSString usage in the query parameters codepaths to eliminate.

@ianpartridge ianpartridge merged commit f5aba72 into Kitura:master Jan 29, 2019
@ianpartridge ianpartridge deleted the string-components branch January 29, 2019 00:19
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