-
-
Notifications
You must be signed in to change notification settings - Fork 135
use cache in parseStack, prevent unnecessary reading of files #318
Conversation
Hi @Asuka999, thanks for the PR. I'm not sure if this has any behavior change, though. We already use the cache in Also, I'd rather not introduce any additional dependencies unless absolutely necessary. Including the |
Thanks for your reply. |
Ah, I see now - thanks for the clarification! I admittedly wasn't the most familiar with the parseStack method at first read, but now it makes sense. Existing behavior is that we won't read a file again if a prior parseStack call already read it (from a previous error capture), but if, within a single parseStack call, the stack has multiple frames from the same file, we will read that file multiple times. The concern, then, is that if we have a large source file with many function calls inside it, this could (unnecessarily) result in a significant disk read spike. This change will make each file be read just once, by the first frame to reference the file; subsequent frames will use it from the cache thanks to the I'm +1 on the change in general. I still don't want to include the promise library, though; maybe the filesize concern isn't the best justification, but it came to mind first from the I can merge this as-is and then follow on with a small refactor to eliminate the dependency, but if you want to do that part before merging feel free. Happy either way, just let me know. |
I have tested this PR after running into out of memory issues ( see #319 ) and it has fixed the problem for me. Although I agree that adding a major dependency like Promise is a bit heavy-weight. |
Merged this, then going to follow-on to add the tests I mentioned in #319 and avoid the promise dep. |
...ah.. so sorry that I still didn't think of a good way to solve it .. |
No worries, I was happy to wait but since it's affecting the memory leak issue I wanted to get the shippable fix + confirming tests done ASAP. |
cache
not used inparseStack