From c4f1465a814356173b541de5053dfe40b4a43297 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 14 Jun 2021 11:53:51 -0400 Subject: [PATCH] check symlink before reading file This is faster because when multiple files are in a directory, it gets cached. --- Annex/Link.hs | 13 +++++-------- ...ent_25_5525b58ec94084a926c71f749d1f4233._comment | 8 ++++++++ 2 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 doc/bugs/significant_performance_regression_impacting_datal/comment_25_5525b58ec94084a926c71f749d1f4233._comment diff --git a/Annex/Link.hs b/Annex/Link.hs index 50f2717fcb..c305b39bd7 100644 --- a/Annex/Link.hs +++ b/Annex/Link.hs @@ -301,7 +301,7 @@ unpaddedMaxPointerSz = 8192 - symlink does. Avoids a false positive in those cases. - -} isPointerFile :: RawFilePath -> IO (Maybe Key) -isPointerFile f = catchDefaultIO Nothing $ do +isPointerFile f = catchDefaultIO Nothing $ #if defined(mingw32_HOST_OS) checkcontentfollowssymlinks -- no symlinks supported on windows #else @@ -311,13 +311,10 @@ isPointerFile f = catchDefaultIO Nothing $ do closeFd (\fd -> readhandle =<< fdToHandle fd) #else - pointercontent <- checkcontentfollowssymlinks - if isJust pointercontent - then ifM (isSymbolicLink <$> R.getSymbolicLinkStatus f) - ( return Nothing - , return pointercontent - ) - else return Nothing + ifM (isSymbolicLink <$> R.getSymbolicLinkStatus f) + ( return Nothing + , checkcontentfollowssymlinks + ) #endif #endif where diff --git a/doc/bugs/significant_performance_regression_impacting_datal/comment_25_5525b58ec94084a926c71f749d1f4233._comment b/doc/bugs/significant_performance_regression_impacting_datal/comment_25_5525b58ec94084a926c71f749d1f4233._comment new file mode 100644 index 0000000000..ca226f11a4 --- /dev/null +++ b/doc/bugs/significant_performance_regression_impacting_datal/comment_25_5525b58ec94084a926c71f749d1f4233._comment @@ -0,0 +1,8 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 25""" + date="2021-06-14T15:52:37Z" + content=""" +Found an optimisation that sped it up 50%, but this edge case is still +`O(N^2)`, so *shrug*. +"""]]