How does vimscript execute functions through multiple threads? - neovim

I have a function for generating tags via ctags:
:function! UpdateCtags()
if !has('linux')
echohl ErrorMsg | echo 'This function only supports running under the linux operating system.' | echohl None
return
endif
echo 'Generating labels...'
let output = system('ctags -f ' . g:tags_file . ' -R /usr/include')
if v:shell_error == 0
echo 'Generated labels successfully.'
else
echohl ErrorMsg | echo output | echohl None
endif
:endfunction
I want to simply execute the UpdateCtags function through multiple threads, how can I do this?
My neovim version:
$ nvim -v
NVIM v0.7.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info

Related

boot.img too large when I compile AOSP11 source code for OTA

I trying to enable AB OTA in AOSP11 source code.
Followed below steps:
Step 1:
BOARD_USES_AB_IMAGE := true
Step 2 : CONFIG_ANDROID_AB=y in u boot source code.
Getting below compilation error :
libcameradevice curr board is yy356x
[ 91% 48807/53497] Target boot image from recovery: out/target/product/xx/boot.img
FAILED: out/target/product/xx/boot.img
/bin/bash -c "(out/host/linux-x86/bin/mkbootimg --kernel out/target/product/xx/kernel --ramdis
k out/target/product/xx/ramdisk-recovery.img --cmdline "console=ttyFIQ0 androidboot.baseband=N/
A androidboot.wificountrycode=CN androidboot.veritymode=enforcing androidboot.hardware=yy30board andro
idboot.console=ttyFIQ0 androidboot.verifiedbootstate=orange firmware_class.path=/vendor/etc/firmware i
nit=/init rootwait ro init=/init androidboot.selinux=permissive buildvariant=userdebug" --recovery_dt
bo out/target/product/xx/rebuild-dtbo.img --dtb out/target/product/xx/dtb.img --os_version
11 --os_patch_level 2021-08-05 --second kernel/resource.img --header_version 2 --output out/target/
product/xx/boot.img ) && (size=$(for i in out/target/product/xx/boot.img; do stat -c "%s" "$i" | tr -d '\n'; echo +; done; echo 0); total=$(( $( echo "$size" ) )); printname=$(ec
ho -n " out/target/product/xx/boot.img" | tr " " +); maxsize=$(( 100663296-0)); if [ "
$total" -gt "$maxsize" ]; then echo "error: $printname too large ($total > $maxsize)"; false;
elif [ "$total" -gt $((maxsize - 32768)) ]; then echo "WARNING: $printname approaching size li
mit ($total now; limit $maxsize)"; fi )"
error: +out/target/product/xx/boot.img too large (103485440 > 100663296)
[ 91% 48808/53497] //libcore/mmodules/intracoreapi:art-module-intra-core-api-stubs-source metalava mer
metalava detected access to files that are not explicitly specified. See /home/test/aosp/aa_android/
out/soong/.intermediates/libcore/mmodules/intracoreapi/art-module-intra-core-api-stubs-source/android_
common/art-module-intra-core-api-stubs-source-violations.txt for details.
01:25:09 ninja failed with: exit status 1
failed to build some targets (02:42:20 (hh:mm:ss))

swiftc: Possible values for "-target" command line option

There is Swift compiler option -target:
$ swiftc -h
...
-target <value> Generate code for the given target
...
Where from can I get all possible values for compiler option -target (i.e: x86_64-apple-ios11.0, x86_64-apple-macosx10.12, ...) ?
Thanks!
Look at https://github.com/apple/swift/blob/master/utils/build-script-impl
Search the build script for terms like SWIFT_HOST_VARIANT, SWIFT_HOST_VARIANT_SDK, SWIFT_HOST_VARIANT_ARCH and SWIFT_HOST_TRIPLE
#!/usr/bin/env bash
#===--- build-script-impl - Implementation details of build-script ---------===#
#
## This source file is part of the Swift.org open source project
# Each variable name is re-exported into this script in uppercase, where dashes
# are substituted by underscores. For example, `swift-install-components` is
# referred to as `SWIFT_INSTALL_COMPONENTS` in the remainder of this script.
KNOWN_SETTINGS=(
# name default description
# ... snip ...
darwin-deployment-version-osx "10.9" "minimum deployment target version for OS X"
darwin-deployment-version-ios "7.0" "minimum deployment target version for iOS"
# ... snip ...
function set_build_options_for_host() {
llvm_cmake_options=()
swift_cmake_options=()
cmark_cmake_options=()
lldb_cmake_options=()
swiftpm_bootstrap_options=()
SWIFT_HOST_VARIANT=
SWIFT_HOST_VARIANT_SDK=
SWIFT_HOST_VARIANT_ARCH=
SWIFT_HOST_TRIPLE=
local host="$1"
# Hosts which can be cross-compiled must specify:
# SWIFT_HOST_TRIPLE and llvm_target_arch (as well as usual HOST_VARIANT flags)
case ${host} in
freebsd-x86_64)
SWIFT_HOST_VARIANT="freebsd"
SWIFT_HOST_VARIANT_SDK="FREEBSD"
SWIFT_HOST_VARIANT_ARCH="x86_64"
;;
cygwin-x86_64)
SWIFT_HOST_VARIANT="cygwin"
SWIFT_HOST_VARIANT_SDK="CYGWIN"
SWIFT_HOST_VARIANT_ARCH="x86_64"
;;
# ... snip ...
linux-*)
SWIFT_HOST_VARIANT="linux"
SWIFT_HOST_VARIANT_SDK="LINUX"
case ${host} in
linux-x86_64)
SWIFT_HOST_VARIANT_ARCH="x86_64"
;;
# ... snip ...
linux-aarch64)
SWIFT_HOST_VARIANT_ARCH="aarch64"
;;
# ... snip ...
;;
macosx-* | iphoneos-* | iphonesimulator-* | \
appletvos-* | appletvsimulator-* | \
watchos-* | watchsimulator-*)
case ${host} in
macosx-x86_64)
xcrun_sdk_name="macosx"
llvm_target_arch=""
SWIFT_HOST_TRIPLE="x86_64-apple-macosx${DARWIN_DEPLOYMENT_VERSION_OSX}"
SWIFT_HOST_VARIANT="macosx"
SWIFT_HOST_VARIANT_SDK="OSX"
SWIFT_HOST_VARIANT_ARCH="x86_64"

LSF serial jobs on HPC performance worse than local sequential executions

I'm learning how to use HPC on our lab's clusters, which uses LSF. I tried a simple serial jobs each of which count the frequency of the words in a text file. I wrote a python code for counting the word frequency named count_word_freq.py, a jobs script named myjob.job as following:
python count_word_freq.py --in ~/books/1.txt --out ~/freqs/freq1.txt
python count_word_freq.py --in ~/books/2.txt --out ~/freqs/freq2.txt
python count_word_freq.py --in ~/books/3.txt --out ~/freqs/freq3.txt
python count_word_freq.py --in ~/books/4.txt --out ~/freqs/freq4.txt
python count_word_freq.py --in ~/books/5.txt --out ~/freqs/freq5.txt
and a lsf script to submit the serial jobs to the selfscheduler:
#!/bin/bash
#BSUB -J test01
#BSUB -P acc_pandeg01a
#BSUB -q alloc
#BSUB -W 20
#BSUB -n 20
#BSUB -m manda
#BSUB -o %J.stdout
#BSUB -eo %J.stderr
#BSUB -L /bin/bash
module load python
module load py_packages
module load selfsched
# And run the program; output will be on stdout
mpirun selfsched < myjobs001.jobs
The python code is as following:
def readBookAsFreqDict(infile):
dic = {}
with open(infile,"r") as file:
for line in file:
contents = line.split(" ")
for cont in contents:
if str.isalpha(cont):
if cont not in dic.keys():
dic[cont] = 1
else:
dic[cont] = dic[cont] + 1
return dic
import sys
import argparse
import time as T
if __name__ == "__main__":
start = T.time()
parser = argparse.ArgumentParser()
parser.add_argument('--i', type=str, help = 'input file')
parser.add_argument('--o', type=str, help = 'output file')
args = parser.parse_args()
dic = readBookAsFreqDict(args.i)
outfile = open(args.o,"w")
for key,freq in dic.iteritems():
outfile.write(key + ":" + str(freq) + "\n")
end = T.time()
print (end - start)
The 5 input texts are almost the same size of around 3.5 MB. My question is that the CPU time for running this serial job is 980s, which is worse than running it sequentially.
To my understanding, the selfscheduler can automatically assign the 5 jobs to empty nodes, thus can save the running time for running it sequentially. Is that because the execution time for each job is too short compared to the time to find an empty node? Is there any other approaches can be used to make it faster?
Thank you!

Postgresql extension Makefile returning error

I wrote a SQL extension following the instructions on PGXN, but I always get a make install error as following:
/bin/mkdir -p '/usr/share/postgresql/9.5/extension'
/bin/mkdir -p '/usr/share/postgresql/9.5/extension'
/bin/mkdir -p '/usr/share/doc/postgresql-doc-9.5/extension'
/usr/bin/install -c -m 644 .//myextname.control '/usr/share/postgresql/9.5/extension/'
/usr/bin/install -c -m 644 .//sql/myextname--1.0.0.sql .//sql/myextname--1.0.0.sql '/usr/share/postgresql/9.5/extension/'
/usr/bin/install: will not overwrite just-created ‘/usr/share/postgresql/9.5/extension/myextname--1.0.0.sql’ with ‘.//sql/myextname--1.0.0.sql’
make: *** [install] Error 1
My Makefile is as following:
EXTENSION = myextname
EXTVERSION = $(shell grep default_version $(EXTENSION).control | \
sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/")
DATA = $(filter-out $(wildcard sql/*--*.sql),$(wildcard sql/*.sql))
TESTS = $(wildcard test/sql/*.sql)
REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS))
REGRESS_OPTS = --inputdir=test
DOCS = $(wildcard doc/*.md)
MODULES = $(patsubst %.c,%,$(wildcard src/*.c))
PG_CONFIG = pg_config
PG91 = $(shell $(PG_CONFIG) --version | grep -qE " 8\\.| 9\\.0" && echo no || echo yes)
ifeq ($(PG91),yes)
all: sql/$(EXTENSION)--$(EXTVERSION).sql
sql/$(EXTENSION)--$(EXTVERSION).sql: $(strip sql/tables.sql \
sql/types.sql \
sql/domains.sql \
)
cat $^ > $#
DATA = $(wildcard sql/*--*.sql) sql/$(EXTENSION)--$(EXTVERSION).sql
EXTRA_CLEAN = sql/$(EXTENSION)--$(EXTVERSION).sql
endif
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
This blog says this error is caused by this line:
DATA = $(wildcard sql/*--*.sql) sql/$(EXTENSION)--$(EXTVERSION).sql
which evaluates into the same filename twice (and /usr/bin/install refuses to overwrite the first instance of the file).
But how can I fix it?
You seem to have copied the Makefile from PGXN, and it is probably much more complicated than you need.
For example, do you target PostgreSQL versions below 9.1?
You'll be much better off with a small, simple custom tailored Makefile like this:
MODULES = src/myextname
EXTENSION = myextname
DATA = sql/myextname--1.0.sql
DOCS = doc/myextname.md
REGRESS = myextname
REGRESS_OPTS = --inputdir=test
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
This (untested) Makefile sticks with the file organization suggested by PGXN.

Compile a static version of pngquant

I'm trying to create a statically linked version of pngquant in Oracle Linux Server release 7.1. I've compiled the static version of zlib and the static version of libpng.
Then, when I configure pngquant, I always get the information that it will be linked with a shared version of zlib.
$ ./configure --with-libpng=../libpng-1.6.21 --extra-cflags="-I../zlib-1.2.8" --extra-ldflags="../zlib-1.2.8/libz.a"
Compiler: gcc
Debug: no
SSE: yes
OpenMP: no
libpng: static (1.6.21)
zlib: shared (1.2.7)
lcms2: no
If I execute make, in the output it seems that the options are correctly passed to the compiler. However, the resulting binary requires libz.so to be executed. It seems that my directives are ignored or that the installed version always takes precedence.
Is there any way of forcing pngquant to be compiled with the static version of zlib?
I'm not sure, if I got it right, but here's a patch to pngquant's configure that worked for me. configure now accepts --with-zlib=<dir> as parameter. Store it to pngquant.patch and apply it with patch -uN -p1 -i pngquant.patch.
diff -ur pngquant-2.9.0/configure pngquant-2.9.0.fixed/configure
--- pngquant-2.9.0/configure 2017-03-06 09:37:30.000000000 +0100
+++ pngquant-2.9.0.fixed/configure 2017-03-07 09:57:20.246012152 +0100
## -48,6 +48,7 ##
help "--with-cocoa/--without-cocoa use Cocoa framework to read images"
fi
help "--with-libpng=<dir> search for libpng in directory"
+ help "--with-zlib=<dir> search for zlib in directory"
echo
help "CC=<compiler> use given compiler command"
help "CFLAGS=<flags> pass options to the compiler"
## -97,6 +98,9 ##
--with-libpng=*)
LIBPNG_DIR=${i#*=}
;;
+ --with-zlib=*)
+ ZLIB_DIR=${i#*=}
+ ;;
--prefix=*)
PREFIX=${i#*=}
;;
## -238,6 +242,19 ##
echo "${MAJ}${MIN}"
}
+# returns full zlib.h version string
+zlibh_string() {
+ echo "$(grep -m1 "define ZLIB_VERSION" "$1" | \
+ grep -Eo '"[^"]+"' | grep -Eo '[^"]+')"
+}
+
+# returns major minor version numbers from png.h
+zlibh_majmin() {
+ local MAJ=$(grep -m1 "define ZLIB_VER_MAJOR" "$1" | grep -Eo "[0-9]+")
+ local MIN=$(grep -m1 "define ZLIB_VER_MINOR" "$1" | grep -Eo "[0-9]+")
+ echo "${MAJ}${MIN}"
+}
+
error() {
status "$1" "error ... $2"
echo
## -420,11 +437,42 ##
error "libpng" "not found (try: $LIBPNG_CMD)"
fi
-# zlib
-if ! find_library "zlib" "z" "zlib.h" "libz.a" "libz.$SOLIBSUFFIX*"; then
- error "zlib" "not found (please install zlib-devel package)"
+# try if given flags are enough for zlib
+HAS_ZLIB=0
+if echo "#include \"zlib.h\"
+ int main(){
+ uLong test = zlibCompileFlags();
+ return 0;
+}" | "$CC" -xc -std=c99 -o /dev/null $CFLAGS $LDFLAGS - &> /dev/null; then
+ status "zlib" "custom flags"
+ HAS_ZLIB=1
fi
+if [ "$HAS_ZLIB" -eq 0 ]; then
+ # try static in the given directory
+ ZLIBH=$(find_h "$ZLIB_DIR" "zlib.h")
+ if [ -n "$ZLIBH" ]; then
+ ZLIBH_STRING=$(zlibh_string "$ZLIBH")
+ ZLIBH_MAJMIN=$(zlibh_majmin "$ZLIBH")
+ if [[ -n "$ZLIBH_STRING" && -n "$ZLIBH_MAJMIN" ]]; then
+ ZLIBA=$(find_f "$ZLIB_DIR" "libz${ZLIBH_MAJMIN}.a")
+ if [ -z "$ZLIBA" ]; then
+ ZLIBA=$(find_f "$ZLIB_DIR" "libz.a")
+ fi
+ if [ -n "$ZLIBA" ]; then
+ cflags "-I${ZLIBH%/*}"
+ lflags "${ZLIBA}"
+ status "zlib" "static (${ZLIBH_STRING})"
+ HAS_ZLIB=1
+ fi
+ fi
+ fi
+fi
+# zlib
+if ! find_library "zlib" "z" "zlib.h" "libz.a" "zlib.$SOLIBSUFFIX*"; then
+ error "zlib" "not found (please install zlib-devel package)"
+fi
+
# lcms2
if [ "$LCMS2" != 0 ]; then
if find_library "lcms2" "lcms2" "lcms2.h" "liblcms2.a" "liblcms2.$SOLIBSUFFIX*"; then
Sorry, the configure script does not support it. It shouldn't be too hard to modify configure to pass appropriate flags to pkg-config or do the same workaround it does for libpng.