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

Adding parallel processing of many files. #57

Merged
merged 1 commit into from Apr 16, 2016

Conversation

genuinelucifer
Copy link
Contributor

Currently it works fine if one file is passed. But if I pass more than one file then i get only extern(C): in the output.
I'm trying to find the mistake.
I would be thankful for any suggestion(s) regarding approach and/or the coding style (since it is my first PR to this project, I might have missed many coding styles standard for this projects)...

@genuinelucifer
Copy link
Contributor Author

Most probably due to arguments (the way it is defined and used) it is getting a bit out of hand currently. Will try to do the necessary changes to make it work.

@genuinelucifer
Copy link
Contributor Author

@jacob-carlborg Although I am unable to find exactly where arguments is defined. So, that I could make copies of it and pass to every thread, its own local copy. Is it in one of the libraries used?

Compiler compiler;
bool helpFlag;
Language language;
string[] argsToRestore;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use spaces (four) for indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacob-carlborg
Copy link
Owner

inputFiles ~= arguments.argument.input;
startConversion(inputFiles.first);
int j = 0;
if(remainingArgs.length >0)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always put a space before the opening parenthesis in statements.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. Will do.

@genuinelucifer
Copy link
Contributor Author

I'll look into dstack and try to figure out how to implement this.

@genuinelucifer
Copy link
Contributor Author

@jacob-carlborg Please review. It is working fine for me now.

@jacob-carlborg
Copy link
Owner

Most things I commented on are not fixed as far as I can see.

if (arguments.argument.input.hasValue)
{
inputFiles ~= arguments.argument.input;
startConversion(inputFiles.first);
int j = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't thinks this is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, had used it in previous code, forgot to remove...

@jacob-carlborg
Copy link
Owner

I'm wondering if it's better that the -o flag specifies which directory to place all the resulting files in when there are multiple input files.

@genuinelucifer
Copy link
Contributor Author

Sure seems better if -o tells the directory in case of multiple files.

@genuinelucifer
Copy link
Contributor Author

I did the changes. Also, please tell me how much to keep the max value for Arguments class in mambo. For my usage, I kept it to 512 and worked. But, I don't know how to decide the exact amount to be kept in mambo.
.
Also, I tried to use parallel again. This time the problem is that, if I give 2 input files. The first output file is fine. But the second output file contains the combined output from 1st AND 2nd file. While using this version of task works as required. I'll try to come up with a solution to using parallel though if it is required.

@genuinelucifer
Copy link
Contributor Author

And one of the buildbots is passing and other one is failing. I saw the output but can't figure out what actually is the error that is shown. Please help.

@jacob-carlborg
Copy link
Owner

And one of the buildbots is passing and other one is failing. I saw the output but can't figure out what actually is the error that is shown. Please help.

The error messages are not very good. But the issue is that DStep fails to produce a result in the case of features/objc/method.feature, for some reason.

}

else
startConversion("");
{
auto conversionTask = task!startParsingFile(language, argsToRestore, "", false, arguments, compiler, compilerArgs);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary to use a task for this condition.

@genuinelucifer
Copy link
Contributor Author

Again one build is passing, other one is not. The tests are failing on clang 3.7 and the best part is I have clang 3.7 only... How do I run these feature tests on my machine? Or what could be the probable cause for this failure?

@jacob-carlborg
Copy link
Owner

One building is running on Linux and the other one on OS X. The one on OS X is running additional tests, converting Objective-C to D. It's one of those that is failing.

You either need OS X to run those test or install GNUStep on Linux. I think you can run basically the same tests by running dub test, @ciechowoj recently added that capability. That might give you better error messages.

@jacob-carlborg
Copy link
Owner

Also, please tell me how much to keep the max value for Arguments class in mambo. For my usage, I kept it to 512 and worked. But, I don't know how to decide the exact amount to be kept in mambo

That's a good question. You can always use int.max and it will most likely be limited by something else 😃. Otherwise, what's the maximum number of files one could expect there to be in a C library.

@ciechowoj
Copy link
Contributor

Again one build is passing, other one is not. The tests are failing on clang 3.7 and the best part is I have clang 3.7 only... How do I run these feature tests on my machine? Or what could be the probable cause for this failure?

If you are on linux try to install GNUStep and comment if OSX in features/step_definitions/common.rb.

You either need OS X to run those test or install GNUStep on Linux. I think you can run basically the same tests by running dub test, @ciechowoj recently added that capability. That might give you better error messages.

The unit tests seems to pass.

Testing with libclang version 3.6.0
Running unit tests
Running cucumber tests


int unitTest ()
{
    println("Running unit tests ");

    auto result = executeShell("dub test");

    if (result.status != 0)
        println(result.output);

    return result.status;
}

@genuinelucifer
Copy link
Contributor Author

@jacob-carlborg I have rebased the PR. Please consider merging if it's acceptable now.

@jacob-carlborg
Copy link
Owner

jacob-carlborg commented Apr 16, 2016

👌

@jacob-carlborg
Copy link
Owner

jacob-carlborg commented Apr 16, 2016

Actually, a couple of minor things:

  1. Could you please change the commit message. The feature is not parallel processing of input files, but rather multiple input files in the first place. I don't think "Enforcing" sounds good in this case
  2. Update the changelog
  3. Update the help text/usage information to somehow indicate that multiple input files are supported. Something like <input files...>

@genuinelucifer
Copy link
Contributor Author

genuinelucifer commented Apr 16, 2016 via email

@jacob-carlborg
Copy link
Owner

With the "help text" i meant the help text at the bottom of Application.d that is printed when the --help flag is given. But it was good that you update the readme as well.

@genuinelucifer
Copy link
Contributor Author

genuinelucifer commented Apr 16, 2016 via email

@jacob-carlborg
Copy link
Owner

Looking good now, I'll wait with merging until the tests are complete, just to be sure.

@jacob-carlborg jacob-carlborg merged commit dd3a5e8 into jacob-carlborg:master Apr 16, 2016
@jacob-carlborg
Copy link
Owner

Thanks.

@genuinelucifer
Copy link
Contributor Author

genuinelucifer commented Apr 16, 2016 via email

@genuinelucifer genuinelucifer deleted the parallel branch April 18, 2016 19:30
@jacob-carlborg
Copy link
Owner

@genuinelucifer I think a natural extension to this PR would be to be able to pass a directory to DStep, which scans the directory for files to translate.

@genuinelucifer
Copy link
Contributor Author

genuinelucifer commented Apr 19, 2016 via email

@jacob-carlborg
Copy link
Owner

Which one would you prefer?

The second approach. It's not possible to have a directory and a file with the same name.

@genuinelucifer
Copy link
Contributor Author

Oops. I thought it might be possible in linux. Never tried.
On Apr 20, 2016 12:12 AM, "jacob-carlborg" notifications@github.com wrote:

Which one would you prefer?

The second approach. It's not possible to have a directory and a file with
the same name.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#57 (comment)

@jacob-carlborg
Copy link
Owner

An alternative approach could be to allow this: dstep foo/*, and for recursively scan a directory: dstep foo/**/*. The first should already be handled by the shell but I don't think the second is handled by the shell. Also, the shell does no globbing on Windows.

@genuinelucifer
Copy link
Contributor Author

the shell does no globbing on Windows.

So, i should hard code the recursive search for both cases? Because i could
never make dstep work on Windows and hence i won't be able to test it. And
build bots are for mac and linux.
I guess it shouldn't be too hard. I'll try and submit a preliminary PR
probably within 1-2 days.

@jacob-carlborg
Copy link
Owner

Never mind the globbing, the shell already does that.

@genuinelucifer
Copy link
Contributor Author

genuinelucifer commented Apr 19, 2016 via email

@jacob-carlborg
Copy link
Owner

But I still think it's convenient to be able to pass a whole directory to translate. That should work on Windows as well, if we ever get DStep to work on Windows.

@genuinelucifer
Copy link
Contributor Author

genuinelucifer commented Apr 19, 2016 via email

@jacob-carlborg
Copy link
Owner

Yes, only header files.

@jacob-carlborg
Copy link
Owner

I think we can assume .h for all files. If the user wants to translate some other extension they can still use globbing or similar.

@genuinelucifer
Copy link
Contributor Author

genuinelucifer commented Apr 19, 2016 via email

@jacob-carlborg
Copy link
Owner

I noticed one thing that might be a problem with the current implementation of multiple files. If I have a file structure looking like this:

foo
├── bar
│   └── bar.h
└── foo
    └── foo.h

And run DStep like dstep foo/bar/bar.h foo/foo/foo.h -o bar then the resulting file structure will look like this:

bar
├── bar.d
└── foo.d

Looks like all files are placed in the top level of the target directory. That will cause problems if bar and foo in the source file structure have files with the same names. Then these files will overwrite each other in the target directory.

@genuinelucifer
Copy link
Contributor Author

genuinelucifer commented Apr 19, 2016 via email

@jacob-carlborg
Copy link
Owner

Oh hmm. But isn't it that the user should avoid? Translating files with same name at the same time?

I think it's a valid use case when using globbing and what I suggested as a new feature today, to handle a whole directory as input argument.

I mean even if we copy the directory structure then too it could be dificult (or undesired) in some situations.

I think it's undesired for a single input file. But for multiple input files, I'm not sure. Maybe a new flag for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants