wireguard-tools icon indicating copy to clipboard operation
wireguard-tools copied to clipboard

wg-quick: linux: use sed for trimming config lines

Open kkartaltepe opened this issue 3 years ago • 2 comments

Bash's longest matching operators combined with extended globs is extremely slow for very large lines. There are probably very few people for which this is noticable but in a file with 800 AllowIPs on a single line it keeps wg-quick from stalling for 5s when performing operations.

I'm not sure about the portability of this to other platforms beyond gnu linux. My understanding is the multiple -e flag style is the most portable and available on non-gnu systems but I have not tested.

I didnt see any performance regression but perhaps shelling out to sed is slower if your config has thousands of lines. I suspect its not.

kkartaltepe avatar Aug 18 '21 03:08 kkartaltepe

Ah sorry right after I sent this i noticed there was a typo and that the non-greedy match in sed was not working...

kkartaltepe avatar Aug 18 '21 03:08 kkartaltepe

Fixed up.

kkartaltepe avatar Aug 18 '21 04:08 kkartaltepe