tag:blogger.com,1999:blog-2428374771421713311.post7817191419243113520..comments2024-03-10T12:04:17.661-07:00Comments on The Oracle at Delphi: Simple question… very hard answer… Talk amongst yourselves…Anonymoushttp://www.blogger.com/profile/10119008505905401707noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-2428374771421713311.post-44709183142520332402010-03-22T05:19:50.000-07:002010-03-22T05:19:50.000-07:00I would put it in the concurrent work and see how ...I would put it in the concurrent work and see how it performs...Pawel Glowackinoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-80430792500304045682010-03-22T05:55:30.000-07:002010-03-22T05:55:30.000-07:00Performance is a separate issue. I said *correctne...Performance is a separate issue. I said *correctness*, not performance. Yes it is a critical issue, but without correctness, performance is irrelevant.Allen Bauerhttp://blogs.embarcadero.com/abauernoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-56040460682123938092010-03-22T06:06:34.000-07:002010-03-22T06:06:34.000-07:00I would first define tests:-) What do we want to t...I would first define tests:-) What do we want to test? "Library" should be something reusable across a number of projects. What kinds of projects are these? <br>I would start from use-cases of using such a library. In other words: cases of apps using the library being tested.Pawel Glowackinoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-65913144078179193442010-03-22T06:10:51.000-07:002010-03-22T06:10:51.000-07:00Off-topic I know, but *you* don't need to test...Off-topic I know, but *you* don't need to test primitives because the OS vendor does that. If you really want to know how they are tested then I'd look at the tests for Linux kernel.<br><br>Starting from scratch I think the first thing you need to do is to enumerate how your primitive could fail and then try to devise a way to make that failure manifest. Easy to say, not so easy to do. Since these primitives will very likely be quite hardware dependent you need a lab with a lot of different hardware!David Heffernannoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-56771441139926082222010-03-22T06:26:27.000-07:002010-03-22T06:26:27.000-07:00I am not an expert in the field, but Helgrind and ...I am not an expert in the field, but Helgrind and the UPPAAL project (http://www.uppaal.com/) might be relevant to the discussion.<br><br>Many hard real-time systems research groups deal with this kind of problems everyday, they probably have a lot to offer in this area.<br><br>The traditional "academic" approach would probably be to formalize some invariants and show that they hold in every possible situation. I am not sure this is always feasible.Jacopohttp://allievi.sssup.it/jacopo/noreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-68905382513154838342010-03-22T06:34:53.000-07:002010-03-22T06:34:53.000-07:00For primitives, I usually write a test contains as...For primitives, I usually write a test contains as much opportunities as possible that may/should cause a data race to cause an observable side effect. E.g., http://svn.freepascal.org/svn/fpc/trunk/tests/test/units/sysutils/trwsync.pp is the test I wrote for TMultiReadExclusiveWriteSynchronizer (I hereby release it to the Public Domain, so feel free to look at it and use it in any way).Jonas Maebenoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-82328739299238538892010-03-22T06:41:52.000-07:002010-03-22T06:41:52.000-07:00Is TMultiReadExclusiveWriteSynchronizer a primitiv...Is TMultiReadExclusiveWriteSynchronizer a primitive?<br><br>In fact Allen, what do you mean by primitive?David Heffernannoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-82780445730309449512010-03-22T06:59:01.000-07:002010-03-22T06:59:01.000-07:00Synchronisation primitives are functionality that ...Synchronisation primitives are functionality that does not do anything by itself save for providing functionality to synchronise multiple threads of execution. <br><br>There are obviously simple (mutex, semaphore, ...) and more complex (barrier, reader/writer locks, ...) primitives, and many primitives can be expressed/implemented using other primitives (semaphore using a mutex, barrier using mutexes or semaphores, ...).Jonas Maebenoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-51964754188151035872010-03-22T10:33:35.000-07:002010-03-22T10:33:35.000-07:001. synchronization + dead lock2. speed - compare t...1. synchronization + dead lock<br>2. speed - compare to using array of TThread(s)<br>3. memory leak?ahmoynoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-61563784966749654462010-03-26T02:17:12.000-07:002010-03-26T02:17:12.000-07:00I wrote a Delphi threading library for the company...I wrote a Delphi threading library for the company I work for. Instead of regular unit testing, I do as Primoz did: test the library's internals with varying numbers of threads, and run the tests in different ways, for long periods of time. Generally my experience was the same as his: problems were found very quickly.David Robbnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-12230054023054792492010-03-23T03:03:43.000-07:002010-03-23T03:03:43.000-07:00In this case, I think the term "integration t...In this case, I think the term "integration test" is more appropriate than "unit test".<br><br>I assume you already have a good handle on the idea of TDD and have at least a basic framework of tests in place. If not, that's a whole other discussion.<br><br>For this kind of fundamental core functionality, that HAS to work reliably every time, I think you need to re-engineer some of these in to long running tests and run them on as many different hardware/OS combinations as you can get your hands on for extended periods of time. Basically, a dedicated testing lab. And/or a USB key launchable suite that a random co-worker can run on their PC over night.<br><br>No matter how many ways I anticipate how something will fail, something unexpected almost always comes up.Bruce McGeenoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-53701835575395891872010-03-22T21:14:16.000-07:002010-03-22T21:14:16.000-07:00I would use Microsoft's CHESS (http://research...I would use Microsoft's CHESS (http://research.microsoft.com/en-us/projects/chess/).Josh Kelleynoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-88600732608351094982010-03-23T09:45:21.000-07:002010-03-23T09:45:21.000-07:00One obvious piece of this equation is how to execu...One obvious piece of this equation is how to execute the tests. The test bed, once written, needs to be ran across a range of single, dual+ core systems with various speeds and capabilities, along with a combination of OS releases.<br>(A single core running on XP will behave a lot different than a dual quad core Windows Server 2008)<br><br>As far as the test bed goes, I would lean towards massive stress testing. Something on the order of the MS web stress tester where you vary the number of threads (or processes depending on the type of access required) and workers in which some workers are set to continuously write to different types of shared value(s), some workers are set to continuously read from these shared values, and some set to randomly read/write these shared values. Randomized wait lengths introduced before and during a read or write block. Enabled workers would need to log start and successful completion utilizing some sort of non-synchronized logging mechanism which can be analyzed later for success rate.<br><br><br>$0.02 Good luck, sounds fun.Darian Millernoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-62154118991507526052010-03-23T14:16:39.000-07:002010-03-23T14:16:39.000-07:00Release it. Ship some time-bombed DCUs or a simila...Release it. Ship some time-bombed DCUs or a similar way of delivery. The biggest problems in any library are the <strong>design</strong> problems. Don't ignore them. <br><br>Also, in order to <em>"effectively test"</em> you must envisage real-world cases. But your 'real world' is very different than ours. And this is natural. Hence one more reason to have a public beta.<br><br>Have a look here:<br><br>http://msdn.microsoft.com/en-us/devlabs/cc950526.aspx<br><br>...and take ideas.<br><br>HTHm. Th.http://wings-of-wind.comnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-47581662777483545992010-03-23T15:48:46.000-07:002010-03-23T15:48:46.000-07:00In OmniThreadLibrary, I'm stress-testing all l...In OmniThreadLibrary, I'm stress-testing all lock-free code. The code runs with different number of threads, from one to *2, and repeats all tests "indefinitely". <br><br>Typically, all bugs were detected in less than 15 minutes. However, I'm running all such tests overnight, for at least 12 hours.Primozhttp://thedelphigeek.comnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-3168132329585111592010-03-23T15:49:55.000-07:002010-03-23T15:49:55.000-07:00Forgot to add: It is important to stress-test with...Forgot to add: It is important to stress-test with more threads than there are cores in the computer, because that causes threads to be paused at different places for a (comparatively) long time.Primozhttp://thedelphigeek.comnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-62801824167554289222010-03-23T05:04:01.000-07:002010-03-23T05:04:01.000-07:00I remember seeing a video on Channel 9. Microsoft ...I remember seeing a video on Channel 9. Microsoft was working on a tool which could test multithreaded code by finding out all possible sequences in which the code can execute. The tool could then execute all these paths.Gielnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-68585112443174536342010-03-23T05:04:48.000-07:002010-03-23T05:04:48.000-07:00Make them run "slow", and throw executio...Make them run "slow", and throw execution test cases in these slow scenarios.<br><br>Run those primitives in debugger mode, instruction by instruction, and at each step, have a variety of tests run against that primitive's state, so that your primitive isn't just tested at each of its high-level states, but at each of its actual CPU-level states (which is usually where hard to spot trouble lives).<br><br>For instance, for an atomic assignment, this is intended to spot that there isn't an intermediate state where the assignment isn't atomic, even on instructions that *usually* last no more than a fraction of a cycle (thanks to pipelining, thus potentially resulting in extremely infrequent issues).<br><br>If you don't have that exhaustive approach, but go for tradionnal unit tests in threads, odds are your correctness will only be statistical, and potentially merely circumstancial.<br><br>That or going for a mathematical proof of course, as already said.<br><br>Also, I think performance should be part of the unit test framework, not as much for pure performance sake, but to spot race conditions and implicit serializations (which would render your primitives entirely pointless if these are not serialization primitives you're testing!)Erichttp://delphitools.info/noreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-42659440141252639142010-03-23T05:14:33.000-07:002010-03-23T05:14:33.000-07:00This sounds like a perfect Stack Overflow question...This sounds like a perfect Stack Overflow question!<br><br>This line from Wikipedia entry on unit testing is pertinent: "Like all forms of software testing, unit tests can only show the presence of errors; they cannot show the absence of errors."<br><br>I'd start by unit-testing it like any other module. Have simple unit tests for the various use cases, add new tests as appropriate to catch 'normal' bugs that are found during the unit's life. <br><br>But, as you know, this isn't really going to catch many of the concurrency edge cases, except by accident, so there are a couple of different techniques to add.<br><br>a: eyeballs. There is really no substitute for major, frequent code reviews on this kind of stuff, with as many good engineers as you can find. If your tests (or 'live' use) does throw up a problem, you'll probably have to do this anyway to find it.<br><br>b: soak testing. Set up a machine (or several) running a serious multithreaded application (it probably doesn't matter what, but you should extend it according to the bugs you find), and run it 24/7. No VMs - this needs real metal.<br><br>c: Unask the question. Instead, ask "why am I reinventing the wheel?" I've been round this myself too often to mention in years gone by, and would rather eat catfood than write/debug another set of synchronization primitives.<br><br>I have the dubious honor of having found/fixed a fairly ugly BCB2009 RTL unicode string concurrency bug in the not-too-distant past. Found by eyeballing the code.Roddy Prattnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-3628380338934374002010-03-23T08:20:13.000-07:002010-03-23T08:20:13.000-07:00It's a null question. Without knowing what fu...It's a null question. Without knowing what functionality the "Concurrency Library" is supposed to provide it's impossible to devise tests or envisage what tests might be necessary.<br><br>"How would you test a Data Access library?"<br>"How would you test a Mathematics library?"<br>"How would you test a Graphics library?"<br>"How would you test a Language library?"<br><br>You can't test a name/label, you can only test functionality.<br><br>So, reverting to the more specific question about synch primitives, still the question remains, what are the synch primitives involved? What are they supposed to do? How are they supposed to work?<br><br>Once armed with that information, the tests should be quite straightforward to devise I should think.Jolyon Smithnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-60248469943458337892010-03-22T12:06:13.000-07:002010-03-22T12:06:13.000-07:00i would not use windows standard synchronization p...i would not use windows standard synchronization primitives, but use something similar to http://golang.org/ insteadalexnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-40936355335425479972010-03-22T19:51:48.000-07:002010-03-22T19:51:48.000-07:00Give the problem to mathematicians, they can prove...Give the problem to mathematicians, they can prove or disprove this kind of things :) Seriously, I would do that.Márton Balassanoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-49534517775188751432010-03-23T17:52:40.000-07:002010-03-23T17:52:40.000-07:00I would follow the advice given by Brian Goetz in ...I would follow the advice given by Brian Goetz in "Java concurrency in practice". A recommended book for all concurrency issues, and a great reference to the Java concurrency design, which is very clever, IMO.<br><br>I haven't read that part of the book, yet, myself. But it seems to give a thorough review to various testing methods and principles.<br><br>A short quote:<br><br>"Most tests of concurrent classes fall into one or both of the classic categories of _safety_ and _liveness_. In Ch.1 we defined safety as "nothing bad ever happens" and liveness as "something good eventually happens"."Jouni Arohttp://www.prosysopc.comnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-72623736114042427062010-03-24T19:34:48.000-07:002010-03-24T19:34:48.000-07:00Besides stress testing, the obvious solution would...Besides stress testing, the obvious solution would be to write a basic emulator of a multi-core system for your test. Most importantly, that would potentially give you complete control over the Time factor, in so far that you could emulate any specific instructions being carried out both concurrently and in a clearly defined order. Problems would have to be detected when evaluating the test data output.Henricknoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-18834176332125650272011-11-23T17:03:04.000-08:002011-11-23T17:03:04.000-08:00HRWJOYQCC1F5HTFXZUHow long you can you keep your u...HRWJOYQCC1F5HTFXZU<br>How long you can you keep your ugg boots clean and newcheap uggshttp://www.cheapuggsboots2012.org/noreply@blogger.com