Assertion Error
Vino.B via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Sep 13 08:12:57 PDT 2017
On Wednesday, 13 September 2017 at 11:03:38 UTC, Moritz Maxeiner
wrote:
> On Wednesday, 13 September 2017 at 07:39:46 UTC, Vino.B wrote:
>> On Tuesday, 12 September 2017 at 21:01:26 UTC, Moritz Maxeiner
>> wrote:
>>> On Tuesday, 12 September 2017 at 19:44:19 UTC, vino wrote:
>>>> Hi All,
>>>>
>>>> I have a small piece of code which executes perfectly 8 out
>>>> of 10 times, very rarely it throws an assertion error, so is
>>>> there a way to find which line of code is causing this error.
>>>
>>> You should be getting the line number as part of the crash,
>>> like here:
>>>
>>> --- test.d ---
>>> void main(string[] args)
>>> {
>>> assert(args.length > 1);
>>> }
>>> --------------
>>>
>>> -----------------
>>> $ dmd -run test.d
>>>
>>> core.exception.AssertError at test.d(3): Assertion failure
>>> [Stack trace]
>>> -----------------
>>>
>>> If you don't what are the steps to reproduce?
>>
>> Hi Max,
>>
>> I tried to run the code for at least 80+ time the code ran
>> without any issue, will let you know in case if I hit the same
>> issue in feature, Below is the piece of code, plese do let me
>> know if you find any issue with the below code.
>>
>> Program Code:
>> [...]
>> foreach (string Fs; parallel(SizeDirlst[0 .. $], 1))
>> {
>> auto FFs = Fs.strip;
>> auto MSizeDirList = task(&coSizeDirList, FFs, SizeDir);
>> MSizeDirList.executeInNewThread();
>> auto MSizeDirListData = MSizeDirList.workForce;
>> MSresult.get ~= MSizeDirListData;
>> }
>
> From reading I don't see anything that I would expect to
> assert, but I am wondering why you first parallelize your work
> with a thread pool (`parallel(...)`) and then inside each
> (implicitly created) task (that is already being serviced by a
> thread in the thread pool) you create another task, have it
> executed in a new thread, and make the thread pool thread wait
> for that thread to complete servicing that new task.
> This should yield the same result, but without the overhead of
> spawning additional threads:
>
> ---
> foreach (string Fs; parallel(SizeDirlst[0 .. $], 1))
> {
> MSresult.get ~= coSizeDirList(Fs.strip, SizeDir);
> }
> ---
Hi Max,
Below is the explanation of the above code.
The Fs that is passed to the function ptSizeDirList is any array
of 10 -15 file system (NetApp Filers)from 15 different servers
mounted on a single server (Network share).
The function ptSizeDirList pass each of the FS to the function
coSizeDirList in parallel thread to find the folder size under
each of these Fs,
Each of this FS has around 1000+ folders. so the requirement is
that we need the size of each of the folders under each of these
15 Fs along with the folder name in less than an hour or two as
this script is about to be schedule to run once every 3 hours,
and at present we are able to achieve the same in 10 mins / fs
Each Fs is of about 10-15 TB's
Hence this code was written.
More information about the Digitalmars-d-learn
mailing list