-
Notifications
You must be signed in to change notification settings - Fork 15
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
Log file for stress tests (on Windows)? #25
Comments
Unfortunately no, the program doesn't log the stress tests. I never thought it was necessary because the only interesting output would be when it fails. And when it fails, it stops. As for why redirection isn't working. I honestly have no idea. It's not something that I use for this program. y-cruncher has uh... never been great for logging. :( |
Ok, thanks for the answer. By the way, I also posted this question in the mersenneforum.org sub forum, but hadn't received an answer there (so i now linked to this issue) |
Hmm, what are you using to output the text in the binaries? Maybe I can find some more information of why this is isn't working and a possible workaround. In the meantime I've also tried to catch the output in PowerShell with:
But none of this worked either. |
From the Microsoft doc:
This article seems to be relevant for this issue as well: And apparently this even caused some problems for the WSL integration in Windows: IMO it's a bit stupid that this needs to be handled by the developer and doesn't "just work" out of the box, but oh well. |
Hi @Mysticial , Regarding additional effort for logging - if you don't catch critical exceptions, or you re-throw them, that should already deliver the needed informations to the environment. |
Lemme check the behavior. It's supposed to stop after the current iteration if any thread has errored. |
to reproduce
result: My cpu fits to "20-ZN3 ~ Yuzuki.exe" |
Oh I meant what the stress tester does when a thread errors. The behavior you're seeing with normal errors is expected. |
Also with stress test errors, y-cruncher always ends with "press key to continue". |
If you pass
|
thank you. But with pause:-2 it would be worse than without. Neither a result in the GUI nor as a file. |
Would it maybe be possible to replace the WriteConsoleW call with something like this? // Either write directly to the console or allow redirection / piping of the output
DWORD ignored;
bool32 isConsole = GetConsoleMode(handle, &ignored);
if (isConsole) {
WriteConsoleW(handle, data, block, &written, nullptr);
}
else {
WriteFile(handle, data, block - 1, &written, nullptr);
} |
Conceptually I think it will work. Just not exactly as you have written because of the length and encoding discrepancies. |
Yeah, it probably should be something like I'm currently looking into redirecting the WriteConsoleW calls to WriteFile using DLL injection with Detours, but without luck so far. |
I think I have something working locally. But it's probably gonna be some months before it gets out since the project is in the middle of something. |
I have managed to redirect the calls to WriteConsole to WriteFile using Detours now, however it suffers from a flaw in Detours itself (resp. an underlying mechanic), where Detours can only work in directories that contain ASCII characters. Unfortunately adding this manifest setting to only the "wrapper" exe that will inject the DLL to reroute the WriteConsole calls does not suffice, the original executable itself has to have this setting enabled as well. And the y-cruncher binaries unfortunately don't have it set. Maybe that's something you could consider adding for the next revision as well, as the reason why you chose WriteConsole seems to have been Unicode support in the first place? |
Detours seems specific to the DLL injection. So is this work-around only needed if you're DLL-injecting? The next version will have the Yes, |
Yes, Detours is for hooking into system calls and "detouring" them.
It does require Windows 10 1903 at least though. |
Here's the current implementation that's slated for v0.8.1 barring any further changes. It picks between Probably worth checking to see if
|
The above changes went into v0.8.1. Worth checking to see if this is done? |
Huuu, long time.
(Needed to backtick escape the spaces in the filename for PowerShell) This also works, and also displays the output at the same time. You can even control the main y-cruncher.exe with this command and it will pipe everything to the log file. I noticed one minor issue, it's introducing additional empty lines when running the tests this way, both in the output and in the logfile (with both commands):
Besides that, it seems to work fine! Although I haven't tested it with UTF8/UTF16 directory names. I will probably still stay with my Detour DLL I mentioned before, as this way I can have both the color output for the y-cruncher window and the log file, and I haven't heard back any problems with it so far. I assume to support both the color output and a log file out of the box you would need to write a dedicated log file function, instead of only changing the output from |
Looks like the problem is coming from the way y-cruncher overwrites lines. It does it by printing Properly fixing this will be trickier. It's too not difficult to fix the current stuff by simply buffering the lines until a newline is printed (and throwing away everything from the last As for the colors, I don't think that can be easily fixed. Though it might actually work on Linux since it uses escape codes and are thus part of the stream that's being printed. |
To be fair, the empty lines aren't really a problem, just a cosmetic issue. Anyone parsing the output should easily be able to work with the current output. |
I assume you're stripping color codes because this is being used for other applications too right? y-cruncher on Windows doesn't use color codes. |
No, I made this purely for y-cruncher. It's been a while, but I think I remember that when I directly forwarded the output to the logfile it was unreadable. // Edit |
Then maybe Windows itself is adding it? |
Maybe Windows or Detours does it when trying to read the output. 🤷 |
Will change the write file function to this:
This should fix the new lines in the piped file. But it won't fix the colors through Tee. |
I just noticed that the latest console on Windows 10 supports the POSIX color codes. That doesn't mean I can switch to it since I do maintain backwards compatibility with Windows 7 for now. |
Apparently the change to make piped log files look nice broke the status lines in BenchMate. BenchMate is piping stdout into custom handler. y-cruncher detects it as pipe instead of a console and thus suppresses the refreshing status lines that mess up log files. BenchMate has some special handling to copy the behavior of the console so that the updating status lines show up correctly within BenchMate's output window. This also explains why BenchMate loses the colors since it only captures the text that is piped whereas the colors are doing using WinAPI calls. Had a discussion about this with the BenchMate developer and I'll be adding new command line options to control both the behavior of the status lines as well as the way colors are done. For now the plan for v0.8.6 is that BenchMate will pass: This will allow BenchMate to get both the refreshing status-lines as well as the console colors. In your case, you can omit both options to preserve the behavior of v0.8.5. Though I'm not sure exactly what you're doing with the piping to log file. |
I'm just periodically pulling the content from the y-cruncher output window, save it to a log file and simultaneously check for errors. I don't redirect the whole output into a new window, which I think BenchMate does, the original y-cruncher window is still there. Do you have any ETA yet for 0.8.6? |
Nope. Barring a difficult-to-fix bug or some new interesting hardware, I don't plan on releasing anything until next year. |
How are you pulling the content of the console window? Is there an API for that? Or are you intercepting the WinAPI calls to BenchMate does DLL injection to intercept these. Since v0.8.6 is so far away, I pushed a minor patch just for BenchMate to let it trick y-cruncher into thinking it's printing to a console so it keeps doing the status prints. The proper fix will come in v0.8.6 with the extra flags to explicitly control that behavior. |
I'm using the Microsoft Detours package to inject a DLL that hooks into |
Is there any way to create a log file during stress testing?
In the Command Lines.txt there's an entry for
-o {output path}
, however this doesn't seem to work for stress testing, i.e. no output file is generated.(And if I put the
-o
parameter before loading the config file like so:00-x86.exe -o C:\Temp config stressTest.cfg
it tells me it's an invalid parameter, but that's just a side note.)I also tried to use output redirection via
> logfile.txt 2>&1
, but at least on Windows this produces only an empty log file, despite the binary being a console application. Resp. it does include the^C
from when I cancel the execution with CTRL+C.So, is there any way to create a log file for a stress test on Windows?
The text was updated successfully, but these errors were encountered: