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

Updated CRC32 Power Optimization Changes #2716

Closed
wants to merge 1 commit into from

Conversation

kamasubb
Copy link
Contributor

Support for PowerPC Architecture
Detecting AltiVec Support

@kamasubb
Copy link
Contributor Author

This pull request is in continuation to the work initiated in pull request #2353

@kamasubb
Copy link
Contributor Author

@siying Kindly review the changes

@facebook-github-bot
Copy link
Contributor

@siying has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@siying
Copy link
Contributor

siying commented Aug 10, 2017

@kamasubb can you figure out in Travis why the same .cc file is still built twice?

g++ -DROCKSDB_USE_RTTI -g -W -Wextra -Wall -Wsign-compare -Wshadow -Wno-unused-parameter -Werror -I. -I./include -std=c++11 -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX -fno-builtin-memcmp -DROCKSDB_FALLOCATE_PRESENT -DSNAPPY -DGFLAGS=google -DZLIB -DBZIP2 -DROCKSDB_MALLOC_USABLE_SIZE -DROCKSDB_PTHREAD_ADAPTIVE_MUTEX -DROCKSDB_BACKTRACE -DROCKSDB_RANGESYNC_PRESENT -DROCKSDB_SCHED_GETCPU_PRESENT -march=native -DROCKSDB_SUPPORT_THREAD_LOCAL -isystem ./third-party/gtest-1.7.0/fused-src -DTRAVIS -O2 -fno-omit-frame-pointer -momit-leaf-frame-pointer -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers -c util/threadpool_imp.cc -o util/threadpool_imp.cc.o
...
g++ -DROCKSDB_USE_RTTI -g -W -Wextra -Wall -Wsign-compare -Wshadow -Wno-unused-parameter -Werror -I. -I./include -std=c++11 -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX -fno-builtin-memcmp -DROCKSDB_FALLOCATE_PRESENT -DSNAPPY -DGFLAGS=google -DZLIB -DBZIP2 -DROCKSDB_MALLOC_USABLE_SIZE -DROCKSDB_PTHREAD_ADAPTIVE_MUTEX -DROCKSDB_BACKTRACE -DROCKSDB_RANGESYNC_PRESENT -DROCKSDB_SCHED_GETCPU_PRESENT -march=native -DROCKSDB_SUPPORT_THREAD_LOCAL -isystem ./third-party/gtest-1.7.0/fused-src -DTRAVIS -O2 -fno-omit-frame-pointer -momit-leaf-frame-pointer -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers -c -o util/threadpool_imp.o util/threadpool_imp.cc

Copy link
Contributor

@grooverdan grooverdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend taking the C implementation from antonblanchard/crc32-vpmsum#4 to avoid the complexities of adding asm to the implementation.

The POWER8 references will look dated once P9 and future processors come to market.

rocksdb::SyncPoint::GetInstance()->ClearCallBack(
"NewRandomAccessFile:O_DIRECT");
rocksdb::SyncPoint::GetInstance()->ClearCallBack(
"NewWritableFile:O_DIRECT");
rocksdb::SyncPoint::GetInstance()->ClearCallBack("NewWritableFile:O_DIRECT");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add pointless whitespace changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the previous pull request I was asked to run "make format"
Below is the output from make format for your reference. I ran make format on my changes and it is adding these white space changes.

build_tools/format-diff.sh
Detect lines that doesn't follow the format rules:
--- db/db_test_util.cc (before formatting)
+++ db/db_test_util.cc (after formatting)
@@ -292,8 +292,7 @@
!defined(OS_AIX)
rocksdb::SyncPoint::GetInstance()->ClearCallBack(
"NewRandomAccessFile:O_DIRECT");

  • rocksdb::SyncPoint::GetInstance()->ClearCallBack(
  •  "NewWritableFile:O_DIRECT");
    
  • rocksdb::SyncPoint::GetInstance()->ClearCallBack("NewWritableFile:O_DIRECT");
    #endif

    bool can_allow_mmap = IsMemoryMappedAccessSupported();
    --- tools/db_stress.cc (before formatting)
    +++ tools/db_stress.cc (after formatting)
    @@ -2370,15 +2370,15 @@
    #if !defined(NDEBUG) && !defined(OS_MACOSX) && !defined(OS_WIN) &&
    !defined(OS_SOLARIS) && !defined(OS_AIX)
    rocksdb::SyncPoint::GetInstance()->SetCallBack(

  • "NewWritableFile:O_DIRECT", [&](void* arg) {
  •  int* val = static_cast<int*>(arg);
    
  •  *val &= ~O_DIRECT;
    
  • });
  •  "NewWritableFile:O_DIRECT", [&](void* arg) {
    
  •    int* val = static_cast<int*>(arg);
    
  •    *val &= ~O_DIRECT;
    
  •  });
    
    rocksdb::SyncPoint::GetInstance()->SetCallBack(
  • "NewRandomAccessFile:O_DIRECT", [&](void* arg) {
  •  int* val = static_cast<int*>(arg);
    
  •  *val &= ~O_DIRECT;
    
  • });
  •  "NewRandomAccessFile:O_DIRECT", [&](void* arg) {
    
  •    int* val = static_cast<int*>(arg);
    
  •    *val &= ~O_DIRECT;
    
  •  });
    
    rocksdb::SyncPoint::GetInstance()->EnableProcessing();
    #endif

Does this mean that either the code that got merged did was not run with the "make format" or there is a code bug the "make format"

});
"NewWritableFile:O_DIRECT", [&](void* arg) {
int* val = static_cast<int*>(arg);
*val &= ~O_DIRECT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add pointless whitespace changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my response above for "db/db_test_util.cc"

@@ -371,6 +394,7 @@ uint32_t ExtendImpl(uint32_t crc, const char* buf, size_t size) {
}

// Detect if SS42 or not.
#ifndef HAVE_POWER8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no point wrapping this. There already is a HAVE_SSE42 inside the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wrapping ensures that the function isSSE42() is not defined on Power platform.
If we don't add this, then the isSSE42() is defined which does not have relevance.

}
#endif // __linux__

static bool isAltiVec() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return arch_ppc_probe(); would of been simpler and if its that simple why is this wrapped in a different function?

util/crc32c.cc Outdated
}

bool IsFastCrc32Supported() {
return isSSE42();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DumpSupportInfo is the only place this is used. I suggest that maybe a string describing the implementation is now a better choice for its output now that there are a variety of implementations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea.

#define PPC_FEATURE2_VEC_CRYPTO 0x02000000
#endif

#ifndef AT_HWCAP2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is always defined on linux. - can be removed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my above comment on freebsd.


typedef uint32_t (*Function)(uint32_t, const char*, size_t);

#if defined(HAVE_POWER8) && defined(HAS_ALTIVEC)
uint32_t ExtendPPCImpl(uint32_t crc, const char *buf, size_t size) {
return crc32c_ppc(crc, (const unsigned char *)buf, size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what the point of function wrapping here is.

#include <sys/auxv.h>

#ifndef PPC_FEATURE2_VEC_CRYPTO
#define PPC_FEATURE2_VEC_CRYPTO 0x02000000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is always defined on powerpc64 linux.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These symbols are present in the header files just above. During an earlier round of review Daniel Axtens had me add these as a backup in case the headers are not found. For example, on powerpc64 freebsd (which doesn't have all the same headers as linux) we hit compilation errors in ceph and had to fix things like this to be more careful.

@kamasubb
Copy link
Contributor Author

@siying
The double build is because of
BENCHTOOLOBJECTS = $(BENCH_LIB_SOURCES:.cc=.o) $(LIBOBJECTS) $(TESTUTIL)
EXPOBJECTS = $(EXP_LIB_SOURCES:.cc=.o) $(LIBOBJECTS) $(TESTUTIL)
$(TOOLS_LIBRARY): $(BENCH_LIB_SOURCES:.cc=.o) $(TOOL_LIB_SOURCES:.cc=.o) $(LIB_SOURCES:.cc=.o) $(TESTUTIL)

The fix to it is
BENCHTOOLOBJECTS = $(BENCH_LIB_SOURCES:.cc=.cc.o) $(LIBOBJECTS) $(TESTUTIL)
EXPOBJECTS = $(EXP_LIB_SOURCES:.cc=.cc.o) $(LIBOBJECTS) $(TESTUTIL)
$(TOOLS_LIBRARY): $(BENCH_LIB_SOURCES:.cc=.cc.o) $(TOOL_LIB_SOURCES:.cc=.cc.o) $(LIB_SOURCES:.cc=.cc.o) $(TESTUTIL)

@siying
Copy link
Contributor

siying commented Aug 17, 2017

@kamasubb the recent Travis build still has it built twice.

@kamasubb
Copy link
Contributor Author

@siying I am working on an approach that would reduce the changes required to Makefile.
The idea is to have explicit rules defined for crc32c_ppc.c and crc32c_ppc_asm.S.
These rules will be applied only for PowerPC architecture while the non-PowerPC architecture will remain as is. These explicit rules will be defined for shared_lib, static_lib and rocksdb_java.
Updated patch will be submitted for review in couple of days.

@facebook-github-bot
Copy link
Contributor

@kamasubb updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@kamasubb updated the pull request - view changes - changes since last import

@kamasubb
Copy link
Contributor Author

@sagar0 AppVeyor build failed due to heap issue. Kindly resolve the resource/memory issue
Below is snippet from log indicating the error for your reference
c:\projects\rocksdb\utilities\transactions\pessimistic_transaction_db.h(243): fatal error C1060: compiler is out of heap space [C:\projects\rocksdb\build\rocksdb-shared.vcxproj]

@kamasubb
Copy link
Contributor Author

@sagar0 If the AppVeyor build fail issue has been resolved, kindly re-run the AppVeyor build

@sagar0
Copy link
Contributor

sagar0 commented Aug 22, 2017

@kamasubb Our Appveyor builds have been failing continuously for a few days now, and we haven't gotten to fixing it yet.

@kestrels
Copy link

@siying When you get a chance, please let us know if you agree this approach is better. This should hopefully be easier to maintain and should no longer have any problems with ccache or objects being built multiple times. The Makefile changes where the object files were being named .cc.o, .c.o, and .S.o are gone. Now they should all be named .o.

@siying
Copy link
Contributor

siying commented Aug 22, 2017

@kestrels yes, I think not having two files with the same name but different extension .cc and .c sounds a good idea anyway.

Support for PowerPC Architecture
Detecting AltiVec Support
@facebook-github-bot
Copy link
Contributor

@kamasubb updated the pull request - view changes - changes since last import

@kamasubb
Copy link
Contributor Author

@siying When you get a chance, please review the new patch

@facebook-github-bot
Copy link
Contributor

@siying has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

facebook-github-bot pushed a commit that referenced this pull request Jan 12, 2018
Summary:
Java build on PPC64le has been broken since a few months, due to #2716. Fixing it with the least amount of changes.
(We should cleanup a little around this code when time permits).

This should fix the build failures seen in http://140.211.168.68:8080/job/Rocksdb/ .
Closes #3359

Differential Revision: D6712938

Pulled By: sagar0

fbshipit-source-id: 3046e8f072180693de2af4762934ec1ace309ca4
siying pushed a commit that referenced this pull request Jan 19, 2018
Summary:
Java build on PPC64le has been broken since a few months, due to #2716. Fixing it with the least amount of changes.
(We should cleanup a little around this code when time permits).

This should fix the build failures seen in http://140.211.168.68:8080/job/Rocksdb/ .
Closes #3359

Differential Revision: D6712938

Pulled By: sagar0

fbshipit-source-id: 3046e8f072180693de2af4762934ec1ace309ca4
miasantreble pushed a commit to miasantreble/rocksdb that referenced this pull request Jan 26, 2018
Summary:
Java build on PPC64le has been broken since a few months, due to facebook#2716. Fixing it with the least amount of changes.
(We should cleanup a little around this code when time permits).

This should fix the build failures seen in http://140.211.168.68:8080/job/Rocksdb/ .
Closes facebook#3359

Differential Revision: D6712938

Pulled By: sagar0

fbshipit-source-id: 3046e8f072180693de2af4762934ec1ace309ca4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants