FU Logo
  • Startseite
  • Kontakt
  • Impressum
  • Home
  • Listenauswahl
  • Anleitungen

Re: [Seqan-dev] FaiIndex + getIdByName/readRegion not threads-safe

<-- thread -->
<-- date -->
  • From: "Weese, David" <weese@campus.fu-berlin.de>
  • To: SeqAn Development <seqan-dev@lists.fu-berlin.de>
  • Date: Wed, 25 Sep 2013 10:48:42 +0200
  • Reply-to: SeqAn Development <seqan-dev@lists.fu-berlin.de>
  • Subject: Re: [Seqan-dev] FaiIndex + getIdByName/readRegion not threads-safe

Hi Johannes,

there is a mutable private string inside the NameCache that is not thread-safe. So although getIdByName is used with a constant name store cache, there will be some concurrent write accesses if you use it with multiple threads. Internally a name store cache is a set of ids (unsigned ints) that are sorted lexicographically with respect to the corresponding names in the name store (a StringSet).
The std::set::find() only supports to search for keys of the set, i.e. ids. That means if a random string needs to be looked up we first store it temporarily in a private mutable string inside the less operator and search for the id -1 to signal the less operator that this string should be compared with the strings inside the name store. If the std::set would be more generic in the types that find and the less operator would accept we wouldn't need to do it this way.

So right now, you should put your lookups inside an critical section until we found a better solution.

Cheers,
David

--
David Weese, Ph.D.              david.weese@fu-berlin.de
Freie Universität Berlin        http://www.inf.fu-berlin.de/
Institut für Informatik         Phone: +49 30 838 75137
Takustraße 9                    Algorithmic Bioinformatics
14195 Berlin                    Room 020

Am 18.09.2013 um 14:53 schrieb Johannes Dröge <johdro@mpi-inf.mpg.de>:

Hi Seqan team,

I recently ported my code to use an off-memory sequence store with your FaiIndex class. Here is the problem: Whenever I use more than two threads to read a region using getIdByName+readRegion, the region returned is incorrect. The class does not seem to be thread-safe, although I cannot image why read-only functions like the above should not be run in parallel. I could wrap the lookup into a class with a locking mechanism but I imagine it would be easy and quick to fix the class without introducing unnecessary locks.

When I give readRegion an object of type "const FaiIndex", it segfaults. IMO, whenever your index is read-only, the methods should be thread-safe or not available at all.

Gruß Johannes

_______________________________________________
seqan-dev mailing list
seqan-dev@lists.fu-berlin.de
https://lists.fu-berlin.de/listinfo/seqan-dev

Attachment: smime.p7s
Description: S/MIME cryptographic signature

<-- thread -->
<-- date -->
  • Follow-Ups:
    • Re: [Seqan-dev] FaiIndex + getIdByName/readRegion not threads-safe
      • From: Johannes Dröge <johdro@mpi-inf.mpg.de>
  • References:
    • [Seqan-dev] FaiIndex + getIdByName/readRegion not threads-safe
      • From: Johannes Dröge <johdro@mpi-inf.mpg.de>
  • seqan-dev - September 2013 - Archives indexes sorted by:
    [ thread ] [ subject ] [ author ] [ date ]
  • Complete archive of the seqan-dev mailing list
  • More info on this list...

Hilfe

  • FAQ
  • Dienstbeschreibung
  • ZEDAT Beratung
  • postmaster@lists.fu-berlin.de

Service-Navigation

  • Startseite
  • Listenauswahl

Einrichtung Mailingliste

  • ZEDAT-Portal
  • Mailinglisten Portal