Skip to content

Commit

Permalink
PARQUET-862: Provide defaut cache size values
Browse files Browse the repository at this point in the history
This patch allows to port parquet-cpp on non-intel architectures
and/or linux/unix flavors where CPU info is different or not
available. Tested on Alpinelinux (musl libc).

Author: Marc Vertes <mvertes@free.fr>

Closes apache#234 from mvertes/master and squashes the following commits:

1b087be [Marc Vertes] PARQUET-862: Provide defaut cache size values

Change-Id: I600915833d8f942f96e2cf38240493709c95b28c
  • Loading branch information
mvertes authored and wesm committed Feb 4, 2017
1 parent a0471b1 commit 20b5033
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cpp/src/parquet/util/cpu-info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,18 @@ void CpuInfo::Init() {
for (size_t i = 0; i < 3; ++i) {
cache_sizes_[i] = data[i];
}
#else
#ifndef _SC_LEVEL1_DCACHE_SIZE
// Provide reasonable default values if no info
cache_sizes_[0] = 32 * 1024; // Level 1: 32k
cache_sizes_[1] = 256 * 1024; // Level 2: 256k
cache_sizes_[2] = 3072 * 1024; // Level 3: 3M
#else
// Call sysconf to query for the cache sizes
cache_sizes_[0] = sysconf(_SC_LEVEL1_DCACHE_SIZE);
cache_sizes_[1] = sysconf(_SC_LEVEL2_CACHE_SIZE);
cache_sizes_[2] = sysconf(_SC_LEVEL3_CACHE_SIZE);
#endif
#endif

if (max_mhz != 0) {
Expand Down

0 comments on commit 20b5033

Please sign in to comment.