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

Use of exceptions for flow control in BlockStore sublasses cause tests (and maybe other things) to take approx 200x as long when debugging #564

Closed
drmason789 opened this issue May 30, 2021 · 2 comments
Labels

Comments

@drmason789
Copy link

drmason789 commented May 30, 2021

B60D06DA-6A28-45F4-A074-94EC03A7C973.MP4

In the attached video, TestMetaDataIPI.TestFour and TestSix take 144ms and 110ms respectively when run.
When debugged, they take 25.3s and 28.9s respectively.

What's taking up all this time? When I do the crudest form of profiling, i.e. break and see what it's doing, I find it in implementations of BlockStore.CreateBlockIfNeeded.

This function is trying to get the block, creating a new one if an IndexOutOfBounds exception is thrown.

To mitigate this, introduce BlockStore.TryGetBlockAt(int offset, out ByteBuffer buffer) and make that avoid throwing IndexOutOfRangeExceptions, instead returning false when it can't find the block and true when it does.

This cuts the execution time of these tests down to about 40% of before.

Additionally, there is code in DirectoryNode.GetEntry that is catching a KeyNotFoundException and throwing a new, more informative exception when the key is missing. This exception handling can be avoided using _byname.TryGetValue(...).

This takes the test execution time down to about 20% of before.

@drmason789 drmason789 changed the title Use of exceptions for flow control BlockStore sublasses cause tests (and probably other things) to take 100x longer when debugging Use of exceptions for flow control BlockStore sublasses cause tests (and probably other things) to take approx 200x longer when debugging May 30, 2021
@drmason789 drmason789 changed the title Use of exceptions for flow control BlockStore sublasses cause tests (and probably other things) to take approx 200x longer when debugging Use of exceptions for flow control in BlockStore sublasses cause tests (and probably other things) to take approx 200x longer when debugging May 30, 2021
drmason789 added a commit to drmason789/npoi that referenced this issue May 30, 2021
@drmason789 drmason789 changed the title Use of exceptions for flow control in BlockStore sublasses cause tests (and probably other things) to take approx 200x longer when debugging Use of exceptions for flow control in BlockStore sublasses cause tests (and maybe other things) to take approx 200x longer when debugging May 30, 2021
@drmason789 drmason789 changed the title Use of exceptions for flow control in BlockStore sublasses cause tests (and maybe other things) to take approx 200x longer when debugging Use of exceptions for flow control in BlockStore sublasses cause tests (and maybe other things) to take approx 200x as long when debugging May 30, 2021
tonyqus added a commit that referenced this issue Aug 24, 2021
#564 avoidance of exceptions for flow control to substantially reduce time to debug tests
@drmason789
Copy link
Author

Why is help wanted?

@tonyqus
Copy link
Member

tonyqus commented Feb 21, 2022

Sorry, I think this is a mistake after long-time delaying. I forgot this issue is fixed by the PR.

@tonyqus tonyqus closed this as completed Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants