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

Using glibc memcpy increases memory allocation performance, instead of using strings::memcpy_inlined function in Starrocks #40414

Open
goldenbean opened this issue Jan 31, 2024 · 5 comments
Labels
type/enhancement Make an enhancement to StarRocks

Comments

@goldenbean
Copy link
Contributor

goldenbean commented Jan 31, 2024

Since glibc continues improving its performance a years-long, the latest version of glibc (2.35) delivered from ubuntu 22.04 seems having a better performance than the strings::memcpy_inlined function, which is currently using in Starrocks writen by Google in 2012.

I have done a bunch of tests with different compiler's parameters, as specially with SIMD instructions. Here is the results:

with -mavx2 only, reduce 43% time in average

test_memcpy: 1.679s 
test_memcpy_inlined: 1.443s  
test_memcpy: 0.814s 
test_memcpy_inlined: 1.443s  
test_memcpy: 0.804s 
test_memcpy_inlined: 1.396s 

with -mavx2 and -mavx512f

test_memcpy: 1.567s 
test_memcpy_inlined: 1.967s  
test_memcpy: 0.816s 
test_memcpy_inlined: 1.973s  
test_memcpy: 0.799s 
test_memcpy_inlined: 1.976s 

with no SIMD parameters. It means that the strings::memcpy_inlined function falls back to glibc memcpy, the performance is therefore equivalent to each other.

test_memcpy: 1.710s 
test_memcpy_inlined: 0.803s  
test_memcpy: 0.883s 
test_memcpy_inlined: 0.807s  
test_memcpy: 0.790s 
test_memcpy_inlined: 0.812s 

The tests are based on
Intel Xeon Silver 4214 46Core, 256GB Mem
Ubuntu 22.04, gcc 11.4.0, glibc 2.35

test code snippets

  size_t size = 0x40000000;  // 1G
  size *= 4;
  char *p = (char *)malloc(size);
  char *q = (char *)malloc(size);
  memset(p, 10, size);
  memset(q, 20, size);
  test_memcpy(p, q, size);
  test_memcpy_inlined(p, q, size);

CPU 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 ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities


@goldenbean goldenbean added the type/enhancement Make an enhancement to StarRocks label Jan 31, 2024
@stdpain
Copy link
Contributor

stdpain commented Jan 31, 2024

see detail in #13330

@kangkaisen
Copy link
Collaborator

Thanks for your test and report, we will do a comprehensive testing and analysis

@goldenbean
Copy link
Contributor Author

goldenbean commented Jan 31, 2024

Bravo ! and Glacias :)

@goldenbean
Copy link
Contributor Author

goldenbean commented Jan 31, 2024

see detail in #13330

@stdpain Would you mind to share or opensource your benchmark code in Starrocks? So, I could run it on our latest commercial servers, such as intel Gold 6130, Intel Platinum 8338C and Amd Genova, and give you feedback of what I will get

@kevincai
Copy link
Contributor

kevincai commented Feb 4, 2024

see detail in #13330

@stdpain Would you mind to share or opensource your benchmark code in Starrocks? So, I could run it on our latest commercial servers, such as intel Gold 6130, Intel Platinum 8338C and Amd Genova, and give you feedback of what I will get

@dirtysalt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Make an enhancement to StarRocks
Projects
None yet
Development

No branches or pull requests

4 participants