github-actions[bot] commented on code in PR #35713: URL: https://github.com/apache/doris/pull/35713#discussion_r1622552473
########## be/src/util/memcpy_inlined.h: ########## @@ -0,0 +1,147 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#pragma once +#ifdef __AVX2__ +#include <emmintrin.h> +#include <immintrin.h> +#endif + +#include <stddef.h> +#include <stdint.h> Review Comment: warning: inclusion of deprecated C++ header 'stdint.h'; consider using 'cstdint' instead [modernize-deprecated-headers] ```suggestion #include <cstdint> ``` ########## be/src/util/memcpy_inlined.h: ########## @@ -0,0 +1,147 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#pragma once +#ifdef __AVX2__ +#include <emmintrin.h> +#include <immintrin.h> +#endif + +#include <stddef.h> Review Comment: warning: inclusion of deprecated C++ header 'stddef.h'; consider using 'cstddef' instead [modernize-deprecated-headers] ```suggestion #include <cstddef> ``` ########## be/src/util/memcpy_inlined.h: ########## @@ -0,0 +1,147 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#pragma once +#ifdef __AVX2__ +#include <emmintrin.h> +#include <immintrin.h> +#endif + +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> Review Comment: warning: inclusion of deprecated C++ header 'string.h'; consider using 'cstring' instead [modernize-deprecated-headers] ```suggestion #include <cstring> ``` ########## be/src/util/memcpy_inlined.h: ########## @@ -0,0 +1,147 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#pragma once +#ifdef __AVX2__ +#include <emmintrin.h> +#include <immintrin.h> +#endif + +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +#include "common/compiler_util.h" +#include "gutil/integral_types.h" +#include "gutil/port.h" + +namespace doris { + +ALWAYS_INLINE inline void memcpy_inlined(void* __restrict _dst, const void* __restrict _src, + size_t size) { + auto dst = static_cast<uint8_t*>(_dst); + auto src = static_cast<const uint8_t*>(_src); + + [[maybe_unused]] tail : + /// Small sizes and tails after the loop for large sizes. + /// The order of branches is important but in fact the optimal order depends on the distribution of sizes in your application. + /// This order of branches is from the disassembly of glibc's code. + /// We copy chunks of possibly uneven size with two overlapping movs. + /// Example: to copy 5 bytes [0, 1, 2, 3, 4] we will copy tail [1, 2, 3, 4] first and then head [0, 1, 2, 3]. + if (size <= 16) { + if (size >= 8) { + /// Chunks of 8..16 bytes. + __builtin_memcpy(dst + size - 8, src + size - 8, 8); + __builtin_memcpy(dst, src, 8); + } else if (size >= 4) { + /// Chunks of 4..7 bytes. + __builtin_memcpy(dst + size - 4, src + size - 4, 4); + __builtin_memcpy(dst, src, 4); + } else if (size >= 2) { + /// Chunks of 2..3 bytes. + __builtin_memcpy(dst + size - 2, src + size - 2, 2); + __builtin_memcpy(dst, src, 2); + } else if (size >= 1) { + /// A single byte. + *dst = *src; + } + /// No bytes remaining. + } + else { Review Comment: warning: different indentation for 'if' and corresponding 'else' [readability-misleading-indentation] ```cpp else { ^ ``` ########## be/src/util/memcpy_inlined.h: ########## @@ -0,0 +1,147 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#pragma once +#ifdef __AVX2__ +#include <emmintrin.h> +#include <immintrin.h> +#endif + +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> Review Comment: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead [modernize-deprecated-headers] ```suggestion #include <cstdio> ``` ########## be/src/util/memcpy_inlined.h: ########## @@ -0,0 +1,147 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#pragma once +#ifdef __AVX2__ +#include <emmintrin.h> +#include <immintrin.h> +#endif + +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +#include "common/compiler_util.h" +#include "gutil/integral_types.h" +#include "gutil/port.h" + +namespace doris { + +ALWAYS_INLINE inline void memcpy_inlined(void* __restrict _dst, const void* __restrict _src, + size_t size) { + auto dst = static_cast<uint8_t*>(_dst); Review Comment: warning: 'auto dst' can be declared as 'auto *dst' [readability-qualified-auto] ```suggestion auto *dst = static_cast<uint8_t*>(_dst); ``` ########## be/src/util/memcpy_inlined.h: ########## @@ -0,0 +1,147 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#pragma once +#ifdef __AVX2__ +#include <emmintrin.h> +#include <immintrin.h> +#endif + +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +#include "common/compiler_util.h" +#include "gutil/integral_types.h" +#include "gutil/port.h" + +namespace doris { + +ALWAYS_INLINE inline void memcpy_inlined(void* __restrict _dst, const void* __restrict _src, Review Comment: warning: function 'memcpy_inlined' exceeds recommended size/complexity thresholds [readability-function-size] ```cpp ALWAYS_INLINE inline void memcpy_inlined(void* __restrict _dst, const void* __restrict _src, ^ ``` <details> <summary>Additional context</summary> **be/src/util/memcpy_inlined.h:36:** 108 lines including whitespace and comments (threshold 80) ```cpp ALWAYS_INLINE inline void memcpy_inlined(void* __restrict _dst, const void* __restrict _src, ^ ``` </details> ########## be/src/util/memcpy_inlined.h: ########## @@ -0,0 +1,147 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#pragma once +#ifdef __AVX2__ +#include <emmintrin.h> +#include <immintrin.h> +#endif + +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +#include "common/compiler_util.h" +#include "gutil/integral_types.h" +#include "gutil/port.h" + +namespace doris { + +ALWAYS_INLINE inline void memcpy_inlined(void* __restrict _dst, const void* __restrict _src, + size_t size) { + auto dst = static_cast<uint8_t*>(_dst); + auto src = static_cast<const uint8_t*>(_src); Review Comment: warning: 'auto src' can be declared as 'const auto *src' [readability-qualified-auto] ```suggestion const auto *src = static_cast<const uint8_t*>(_src); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org