Speed comparisons

All results are in seconds, lower is better. Device was prevented from suspending or entering lower power modes with

   1  echo benchmark >/sys/power/wake_lock
   2  cd /sys/devices/system/cpu/cpu0/cpufreq
   3  echo userspace >scaling_governor
   4  echo 1700000 >scaling_max_freq
   5  echo 1700000 >scaling_min_freq
   6  echo 1700000 >scaling_setspeed

WiFi, Bluetooth etc. were all turned off.

Cortex-A15 (Exynos, Nexus 10)

AOSP master 2014/02/15 without cortex-strings

Test

Run 1

Run 2

Run 3

Run 4

Run 5

Average

10000000 * memset 15000*'a'

11.247292

11.234409

11.230756

11.338973

11.217467

11.2537794

500000000 * strlen(15*a)

8.553449

8.553183

8.567585

8.588892

8.553336

8.563289

1000000 * strlen(15000*a)

4.795569

4.795262

4.795663

4.797358

4.795518

4.795874

10000000 * memchr not finding anything in 15000 chars

206.716529

207.085587

207.052786

206.713319

206.690836

206.8518114

10000000 * strchr not finding anything in 15000 chars

265.872268

266.026152

265.951217

265.724881

265.726224

265.8601484

10000000 * memchr finding match at 5000

69.043152

69.043697

69.030276

69.034317

69.033701

69.0370286

10000000 * strchr finding match at 5000

88.719185

88.731907

88.708821

88.716855

88.717369

88.7188274

10000000 * memcpy of 15000 bytes

14.065595

14.097389

14.075248

14.070943

14.066137

14.0750624

900000000 * memcpy of 15 bytes

3.199715

3.185340

3.185889

3.185401

3.185494

3.1883678

1000000 * strcpy of 15000 bytes

6.195695

6.213036

6.228968

6.217930

6.198366

6.210799

100000000 * strcpy of 15 bytes

2.514313

2.520154

2.500079

2.512444

2.508749

2.5111478

AOSP master 2014/02/15 with cortex-strings A9 implementations

Test

Run 1

Run 2

Run 3

Run 4

Run 5

Average

10000000 * memset 15000*'a'

16.797480

16.781953

16.779048

16.781328

16.781877

16.7843372

500000000 * strlen(15*a)

8.553445

8.553149

8.553313

8.553026

8.553343

8.5532552

1000000 * strlen(15000*a)

4.795583

4.457439

4.795322

4.795538

4.795226

4.7278216

10000000 * memchr not finding anything in 15000 chars

73.935429

72.148515

73.938543

73.934419

73.935717

73.5785246

10000000 * strchr not finding anything in 15000 chars

265.722409

266.061927

265.721691

265.719065

265.720806

265.7891796

10000000 * memchr finding match at 5000

23.430706

23.434121

23.431322

23.431640

23.435415

23.4326408

10000000 * strchr finding match at 5000

88.712813

88.709342

88.716149

88.716462

88.713821

88.7137174

10000000 * memcpy of 15000 bytes

12.358517

12.579097

12.215877

11.929468

12.210282

12.2586482

900000000 * memcpy of 15 bytes

3.185449

3.189573

3.185687

3.185352

3.189495

3.1871112

1000000 * strcpy of 15000 bytes

6.194759

5.896051

6.204157

6.194715

6.206090

6.1391544

100000000 * strcpy of 15 bytes

2.499758

2.499710

2.503220

2.502829

2.505890

2.5022814

AOSP master 2014/02/15 with cortex-strings A9 and Thumb-2 implementations

Test

Run 1

Run 2

Run 3

Run 4

Run 5

Average

10000000 * memset 15000*'a'

16.834221

16.793361

16.779402

16.785332

16.776269

16.793717

500000000 * strlen(15*a)

7.383670

7.358098

7.339905

7.366886

7.380513

7.3658144

1000000 * strlen(15000*a)

4.457206

4.455247

4.469934

4.455709

4.455068

4.4586328

10000000 * memchr not finding anything in 15000 chars

73.937404

73.946469

71.540411

73.977204

73.946845

73.4696666

10000000 * strchr not finding anything in 15000 chars

265.782576

265.771352

266.228655

265.988942

265.807043

265.9157136

10000000 * memchr finding match at 5000

23.437018

23.431005

23.431498

23.430944

23.446166

23.4353262

10000000 * strchr finding match at 5000

88.715774

88.715173

88.718881

88.743164

88.723756

88.7233496

10000000 * memcpy of 15000 bytes

12.178588

12.586639

12.645465

11.928898

12.044970

12.276912

900000000 * memcpy of 15 bytes

3.185613

3.185682

3.185355

3.185211

3.185367

3.1854456

1000000 * strcpy of 15000 bytes

6.200580

6.195629

6.198868

6.195102

6.195087

6.1970532

100000000 * strcpy of 15 bytes

2.502610

2.505724

2.517184

2.516114

2.539147

2.5161558

Conclusions

  • The following functions from cortex-strings still perform better than AOSP master and should be merged:
    • strlen
    • memchr
    • memcpy
  • The following functions from AOSP master perform better than cortex-strings and should be merged the other way so glibc can benefit:
    • memset
  • There is no relevant difference in performance between both implementations of:
    • strcpy
  • cortex-strings currently doesn't implement strchr -- may be interesting to add given how significantly faster the similar memcpy function is.

Modifications to Bionic linaro-master branch

Given the results above, cortex-strings implementations of strlen, memchr and memcpy have been merged into Bionic linaro-master. memset and strcpy remain at AOSP versions. This should provide the best of both worlds.

Benchmark with the first post-merge build

Test

Run 1

Run 2

Run 3

Run 4

Run 5

Average

10000000 * memset 15000*'a'

11.221211

11.336537

11.215436

11.206137

11.236654

11.243195

500000000 * strlen(15*a)

7.372736

7.336301

7.366022

7.362991

7.373433

7.3622966

1000000 * strlen(15000*a)

4.535250

4.455168

4.455282

4.467081

4.455371

4.4736304

10000000 * memchr not finding anything in 15000 chars

73.633334

73.961439

73.938800

72.099747

73.944188

73.5155016

10000000 * strchr not finding anything in 15000 chars

266.383824

266.076087

265.742613

266.064350

265.735763

266.0005274

10000000 * memchr finding match at 5000

23.430329

23.431592

23.435061

23.435667

23.437083

23.4339464

10000000 * strchr finding match at 5000

88.705164

88.717890

88.728581

88.711096

88.716407

88.7158276

10000000 * memcpy of 15000 bytes

12.529101

11.961410

12.222402

12.183076

12.954330

12.3700638

900000000 * memcpy of 15 bytes

3.185187

3.185458

3.185480

3.185389

3.185759

3.1854546

1000000 * strcpy of 15000 bytes

6.486404

6.197687

6.195288

5.855629

6.210549

6.1891114

100000000 * strcpy of 15 bytes

2.503165

2.512032

2.500031

2.520011

2.501130

2.5072738

Platform/Android/CortexStringsInBionic (last modified 2014-02-15 23:02:49)