(Option 1) Improve logging accuracy and reduce exists && isFile to 1 file query#295
(Option 1) Improve logging accuracy and reduce exists && isFile to 1 file query#295marler8997 wants to merge 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request, @marler8997! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
899b2b7 to
9f5b1a2
Compare
|
I'd like to hear more detail about the motivation behind these changes, because on the face of it this PR seems quite problematic. Let's break it down:
In summary, this patch seems to make Absent a very good reason (e.g. benchmarks showing significant improvement to real-world use cases) this PR should probably just be closed. |
|
Your evaluation seems a bit dramatic to me and also very one sided. You attempted to find everything wrong with this PR but didn't mention any of the benefits. Would you mind listing all the benefits as well? |
|
@marler8997 I'm afraid I don't see what those benefits are. This is one reason why I asked about the motivation behind the PR. Neither the patch nor the PR have any description other than the title, and this says only what has changed -- it says nothing about why this change was deemed necessary or what criteria were used to do so. This is information that presumably as author you already know, so it would be good to include it in the patch description, to help reviwers understand things more readily. As things stand, though, this patch looks like it decreases the clarity and maintainability of |
|
Based on your initial comment it's clear that you have a strong bias against this change. You've included alot of detail about why you don't like this change but spent no time analyzing what is good about it. I've found that when someone is in this state of mind it is impossible for them to discuss the subject objectively. It's been found that when people are in this state, the more evidence you present against their opinion, the more they will dig in their heels and cling to their initial opinion. Addressing your concerns and explaining the motivation isn't a problem for me, however, this would only cause you to find more a more wrong with the PR and be counter-productive. Unless you can re-evaluate this PR objectively and take just as much time to evaluate the pros as you did the cons, it's better that we don't start an argument over this. |
|
@marler8997 I've offered you a detailed set of feedback with clearly spelled out criteria behind it. Do you really feel it's either appropriate or helpful to respond with ad hominem about what you perceive as my state of mind? I'm prepared to listen to evidence. But have you considered that it's possible that the lack of objectivity could be on your side, not mine? What makes you think that this PR is a good contribution? |
|
I'm not going to argue with someone who is biased, it doesn't do anyone any good. The only way to prove to me that you aren't biased is to evaluate the opposing side to your viewpoint. Do that and then we can talk. |
I agree that the names are not that good. Turns out
The Phobos implementations of these functions have the same constraints.
I agree that benchmarks that shows the need for this should be provided. |
| fullExe = fullExe.defaultExtension(".exe"); | ||
|
|
||
| // Delete the old executable before we start building. | ||
| yap("stat ", fullExe); |
There was a problem hiding this comment.
So yap was a precedent already
There was a problem hiding this comment.
yap appears to be a utility function to report commands issued directly by rdmd. It's responsible for verbose output. The name makes sense for this usage (see the dictionary definition:-), albeit maybe not so obvious to a non-native speaker.
It just seems odd (and misleading) to use as a prefix for the newly introduced functions.
This seems to be the key point. Any data on the improvement on some example? I have a hunch that stat calls could be measurable in the case where we don't need to rebuild the project that consists of a multitude of files, use that as the baseline with Basically it should be: avgtime -r 100 rdmd --build-only some_project_entry_point.d avgtime is nice D utility program available here: |
It's not a bad choice for the actual
I'm not surprised, but that wasn't the concern. If the constraints are only in phobos, then rdmd's support automatically gets better whenever phobos' does. If the constraints are in rdmd then they affect rdmd even when phobos does not impose these constraints. So, the objection was to introducing new code in rdmd that carries these constraints. (There is already a similar version block where file suffixes are determined, but that's easier to maintain and could probably be fixed anyway. Ideally we shouldn't add more such rdmd-side limitations.) |
|
I'd be surprised if this PR had in any measurable performance improvement. The reason for it is logging accuracy. Since I've been working very closely with If you go through the code, you'll notice that a fair amount of file system operations are missing their corresponding |
|
@marler8997 OK, so the goal here is not improved performance, but ensuring that verbose output accurately reports every single output with the filesystem? That's a reasonable concern per se (although one might distinguish between querying the file system, versus modifying it, in terms of logging priority). But it's probably a good idea to try to spell out in detail exactly what's wanted and why so that reviewers can best advise on how to achieve this, and whether it really is a good idea. I'm AFK right now (writing from my phone) so it's hard to offer detailed thoughts and advice. I'll try to write more this evening or tomorrow, but in the meantime, a few pieces of feedback:
I'll follow up with more thoughts when I'm back in front of a computer, but in the meantime it would be good to have feedback on these questions and remarks. |
Mentioning that from the beginning and ideally in the commit message would have saved a lot of discussions here. |
|
On further consideration, two things spring to mind that as relevant: (1) We should recognize that the usage of yap("stat ", fullExe);
if (exists(fullExe))
{
...
}The correctness of this (2) Given that the total number of filesystem-related functions used by bool exists(string path)
{
import std.file: exists;
yap("stat ", path);
return std.file.exists(path);
}... but the correctness of the verbose output depends on the abstraction-breaking knowledge mentioned above. If we really, really want to report file system interactions correctly, we might reasonably ask if a manual solution like |
|
I've made a separate PR that only improves logging accuracy without reducing the 2 file system calls to 1 in the |
|
One further complicating factor in addition to those mentioned above: the So, even if it were possible to somehow track the commands invoked by rdmd and pipe that information back to |
|
isn't that one the same as #291 ? |
| bool yapExists(const(char)[] name) | ||
| { | ||
| return yapGetFileAttributes(name).exists(); | ||
| } |
There was a problem hiding this comment.
How about putting all these into one scope?
struct Yap { ... }
9f5b1a2 to
83de295
Compare
|
I've updated the names of this PR and #299 to reflect that they are 2 different options of the same change. #299 is basically the same thing but without the extra reduction of filesystem query in the |
83de295 to
223145a
Compare
223145a to
93a79b8
Compare
|
The objection is not (solely) to the The existing code has a pretty simple and consistent design principle: use standard library functions to interact with the filesystem, and manually add The downside of that is that the developer (and reviewers) have to take care of making sure the Neither of the current PRs on offer provides a comprehensive replacement for this approach. Both PRs mix up verbose wrapping of This means the code is inconsistent in style and design, and that makes the code less intuitive to read and reason about. This is before we even get to stuff like This is why, as suggested multiple times now, it would be better to address the immediate problem (i.e. add missing |
|
@WebDrake you've shared your opinion multiple times now, and I've told you multiple times that I disagree, please limit the repetition and allow someone else to chime in. |
CyberShadow
left a comment
There was a problem hiding this comment.
Thanks! I think this is a good general direction for improvement.
I would put the stat optimization as a separate commit or PR, but I wouldn't mind it either way. rdmd has generally tried to reduce the number of stat calls, which can be slow with a cold disk cache or a network filesystem, but stat-ing the same file twice in a row probably won't make much of a difference unless it's on an uncached network filesystem or something like that.
| } | ||
| } | ||
|
|
||
| struct Yap |
There was a problem hiding this comment.
yap wasn't a great name start with, and this is not making it better. This is a namespace for wrapping filesystem operations, so let's just name it Filesystem or such.
There was a problem hiding this comment.
Please also add a comment describing the motivation of having this structure.
There was a problem hiding this comment.
Added a comment in #299. I like the name Yap for the structure, let's come back to this if you still feel the same after this set of changes.
|
|
||
| struct Yap | ||
| { | ||
| static FileAttributes getFileAttributes(const(char)[] name) |
There was a problem hiding this comment.
Use static: to make it more clear that this is a namespace and has no non-static members.
| } | ||
|
|
||
| struct Yap | ||
| { |
There was a problem hiding this comment.
Move std.file imports here. That way, it will not be possible to accidentally use std.file functions bypassing logging.
There was a problem hiding this comment.
There's still a fair amount of std.file functions used in the rest of the file
thisExePath
tempDir
remove
FileException
DirEntry
dirEntries
There was a problem hiding this comment.
Please use selective imports for that.
remove is sticking out: should it be called via the wrapper instead? If not, then it should be a static or fully-qualified import to make it explicit.
There was a problem hiding this comment.
The remove case is awkward. It has a try/catch block with logic to handle what happens if the file is being used. It's in the first part of the rebuild function.
I can switch them to selective imports if you think that's better, but none of the other modules use selective imports, so I wasn't sure if I should follow convention or do the "safer" thing.
There was a problem hiding this comment.
Yes, please use selective imports. Using selective (or static) imports provides half of the justification for the filesystem operations wrapper: to prevent accidentally bypassing it. Without that, it's more difficult to justify this entire pull request.
There was a problem hiding this comment.
The remove call is already accompanied by a yap, so with a bit of refactoring of the !dryRun part it looks like a good candidate of being converted to a call to the wrapper.
There was a problem hiding this comment.
dirEntries should also probably be moved to the wrapper, since it's not much different from stat in principle.
There was a problem hiding this comment.
ok, done except moving the remove case to a wrapper. have another look at the current set of changes in #299 and let me know what you think
| static auto timeLastModified(R)(R name) | ||
| { | ||
| yap("stat ", name); | ||
| return std.file.timeLastModified(name); |
There was a problem hiding this comment.
This could also be written as simply return .timeLastModified(name);, but I guess it's probably better to be more explicit here.
| else stderr.writeln(stuff); | ||
| } | ||
|
|
||
| struct FileAttributes |
There was a problem hiding this comment.
Please document what this is used for.
|
Closing in favor of #299. Might add the file system call consolidation in a separate PR. |
No description provided.